|
| 1 | +diff -Nuar a/vendor/magento/module-catalog/Model/ResourceModel/AbstractResource.php b/vendor/magento/module-catalog/Model/ResourceModel/AbstractResource.php |
| 2 | +index c71225b4fc6..3f0ee96d70e 100644 |
| 3 | +--- a/vendor/magento/module-catalog/Model/ResourceModel/AbstractResource.php |
| 4 | ++++ b/vendor/magento/module-catalog/Model/ResourceModel/AbstractResource.php |
| 5 | +@@ -24,14 +24,14 @@ use Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface; |
| 6 | + abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity |
| 7 | + { |
| 8 | + /** |
| 9 | +- * Store manager |
| 10 | ++ * Store manager to get the store information |
| 11 | + * |
| 12 | + * @var \Magento\Store\Model\StoreManagerInterface |
| 13 | + */ |
| 14 | + protected $_storeManager; |
| 15 | + |
| 16 | + /** |
| 17 | +- * Model factory |
| 18 | ++ * Model factory to create a model object |
| 19 | + * |
| 20 | + * @var \Magento\Catalog\Model\Factory |
| 21 | + */ |
| 22 | +@@ -325,7 +325,25 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity |
| 23 | + */ |
| 24 | + protected function _updateAttribute($object, $attribute, $valueId, $value) |
| 25 | + { |
| 26 | +- return $this->_saveAttributeValue($object, $attribute, $value); |
| 27 | ++ $entity = $attribute->getEntity(); |
| 28 | ++ $row = $this->getAttributeRow($entity, $object, $attribute); |
| 29 | ++ $hasSingleStore = $this->_storeManager->hasSingleStore(); |
| 30 | ++ $storeId = $hasSingleStore |
| 31 | ++ ? $this->getDefaultStoreId() |
| 32 | ++ : (int) $this->_storeManager->getStore($object->getStoreId())->getId(); |
| 33 | ++ if ($valueId > 0 && array_key_exists('store_id', $row) && $storeId === $row['store_id']) { |
| 34 | ++ $table = $attribute->getBackend()->getTable(); |
| 35 | ++ $connection = $this->getConnection(); |
| 36 | ++ $connection->update( |
| 37 | ++ $table, |
| 38 | ++ ['value' => $this->_prepareValueForSave($value, $attribute)], |
| 39 | ++ sprintf('%s=%d', $connection->quoteIdentifier('value_id'), $valueId) |
| 40 | ++ ); |
| 41 | ++ |
| 42 | ++ return $this; |
| 43 | ++ } else { |
| 44 | ++ return $this->_saveAttributeValue($object, $attribute, $value); |
| 45 | ++ } |
| 46 | + } |
| 47 | + |
| 48 | + /** |
0 commit comments