cloudinary / cloudinary_magento

Cloudinary's Magento extension. Upload product images to the cloud, manipulate them to match your graphic design and optimize images for better user experience
MIT License
16 stars 17 forks source link

Data reset in after_save observer #52

Closed choussamaster closed 4 years ago

choussamaster commented 5 years ago

We enable everyday some products with a cronjob that changed the status of product We noticed that url-rewriting are no more generated in the product save() function after debuging the problem come from the observer of cloudinary and exactly from this line https://github.com/cloudinary/cloudinary_magento/blob/4d7cc09a22dcdc5c4c4f24ab3e7e36cd535e2b3e/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php#L26 It reload the product default data, so the product is no more considered with changed data, and the default magento function "refreshProductRewrite" will no more reindex when removing this line all work fine

eyalktCloudinary commented 5 years ago

Hi @choussamaster , can you elaborate on the issue you're seeing and the use case? What do you mean by the following line?

"url-rewriting are no more generated"

In addition, what steps does the cronjob performs?

choussamaster commented 5 years ago

no entry are created for the product in catalog > URL Rewrite Management This is the test case : Enable cloudinary and auto upload functions Create a product programmatically or via import (magmi) with status disabled check that no rule for the new product id exist in "catalog > URL Rewrite Management" in "id path" column, or delete existing url from database Enable the product programmatically <?php require_once 'app/Mage.php'; Mage::app('admin'); if(Mage::helper('core')->isModuleEnabled('Cloudinary_Cloudinary')) Mage::helper('cloudinary_cloudinary/autoloader')->register(); $productsId = 438151; $product = Mage::getModel('catalog/product')->load($productId); $product->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED); $product->save();

check if url rewriting urls for the enabled product are generated in "catalog > URL Rewrite Management"
the result of this bug is that url of enabled product are not url rewrited ex : "/catalog/product/view/id/53033/category/605" and we have to reindex manually every day

eyalktCloudinary commented 5 years ago

@choussamaster Can you elaborate on this test step -

check that no rule for the new product id exist in "catalog > URL Rewrite Management" in "id path" column, or delete existing url from database

What is the purpose of that step? Why do you delete the product's "URL Rewrite" record?

choussamaster commented 5 years ago

the purpose of this step is just to check if the product has not url_rewrited url generated yet (it's the case of product created via magmi import or programmatically) with a disabled status, then urls are generated automatically when the product is being activated

eyalktCloudinary commented 5 years ago

@choussamaster Thank you for the feedback. We've investigated and found your suggestion regarding the removal of the mentioned line effective -

https://github.com/cloudinary/cloudinary_magento/blob/4d7cc09a22dcdc5c4c4f24ab3e7e36cd535e2b3e/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php#L26

We've added the bug-fix to our roadmap, as such change needs to be thoroughly tested.

eyalktCloudinary commented 4 years ago

Closing due to time elapsed. Seems to be fixed.