From 97e24715b7bf605d77e8ff2d3fecad437f1916a4 Mon Sep 17 00:00:00 2001 From: Artem Brunevski Date: Tue, 5 Sep 2017 15:42:52 +0200 Subject: [PATCH] Update Product.php Used version: 1.0.0.1 Description: There are two product: - product_a with attribute_set_x - product_b with attribute_set_y As a store administrator tried to change product_a from product grid. Expected: only attribute_set_x attributes should be changed Actual: attribute_set_x attributes changed but also attribute_set_y attributes changed to default values Problem: All available attributes loaded in catalog product resource model (it is singleton) in app/code/community/BL/CustomGrid/Model/Grid/Type/Product.php:72 Then during saving product all attributes values change to default values even if they are not in product attribute set Solution: Reset previously loaded attributes cache before product initialization --- .../BL/CustomGrid/Model/Grid/Editor/Product.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/code/community/BL/CustomGrid/Model/Grid/Editor/Product.php b/app/code/community/BL/CustomGrid/Model/Grid/Editor/Product.php index eea1baa..ea5f7ff 100644 --- a/app/code/community/BL/CustomGrid/Model/Grid/Editor/Product.php +++ b/app/code/community/BL/CustomGrid/Model/Grid/Editor/Product.php @@ -206,7 +206,15 @@ public function loadEditedProduct($entityId, BL_CustomGrid_Model_Grid_Editor_Con /** @var Mage_Catalog_Model_Product $product */ $product = Mage::getModel('catalog/product'); - $product->setStoreId($storeId)->setData('_edit_mode', true)->load($entityId); + $product->setStoreId($storeId)->setData('_edit_mode', true); + + /** + * Reset cached attributes in resource singleton and load new from product attributes set + */ + $product->getResource() + ->unsetAttributes(); + + $product->load($entityId); return $product; }