-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Component: CatalogEvent: distributed-cdDistributed Contribution DayDistributed Contribution DayIssue: ready for confirmationReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 releasebug reportstale issue
Description
See below example
$product = $this->productRepository->get('test-sku');
// $product->getCustomAttribute('custom_attr_code')->getValue() == 0
$product->setCustomAttribute('custom_attr_code', 1); // changing value from 0 to 1
$this->productRepository->save($product);
// $product->get('custom_attr_code') == 0
// and $product->getCustomAttribute('custom_attr_code')->getValue() == 0
ANY values in $_data[self::CUSTOM_ATTRIBUTES]
is lost, and not saved properly.
This is because the product repository issues a product model load
which loads all attributes, custom or not, into the _data
array. Anytime the app calls ProductInterface::getCustomAttributes
(which it does try to do when saving, to grab any values there) any custom attribute 'key' in $_data['custom_attributes']['key']
is overwritten because that key exists in $_data['key']
. This overwriting happens here.
andreaschiffo, KeyShang, brideo, NiklasBr, Tiberriver256 and 4 more
Metadata
Metadata
Assignees
Labels
Component: CatalogEvent: distributed-cdDistributed Contribution DayDistributed Contribution DayIssue: ready for confirmationReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 releasebug reportstale issue