-
Notifications
You must be signed in to change notification settings - Fork 56
Description
Preconditions
- PHP 7.0
- Magento 2.2.4
Steps to reproduce
mg2-codegen template:generate crudEAV
magento/admin->content->gridItem->item->edit
If have more than one store and form item have input select.
There is a problem: I select any value from any input select field for the US store view and save it. Then I switch to other store view (for example UK store) and select the same value for the same input select field and save it, this value is not saved. The problem lies in $objectInstance->load($data['entity_id']); method, that loads object with attributes which belong to one store view, regardless the store view this object is saved form.
In order to fix this issue the following should be done: in resource model change method protected function _getLoadAttributesSelect($object, $table)
from that
protected function _getLoadAttributesSelect($object, $table)
{
if ($this->_storeManager->hasSingleStore()) {
$storeId = (int) $this->_storeManager->getStore(true)->getId();
} else {
$storeId = (int) $object->getStoreId();
}
$storeIds = [$this->getDefaultStoreId()];
if ($storeId != $this->getDefaultStoreId()) {
$storeIds[] = $storeId;
}
$select = $this->getConnection()->select()->from(
$table,
[]
)->where(
$this->getEntityIdField() . ' =?',
$object->getId()
)->where('store_id IN (?)', $storeIds);
return $select;
}