Skip to content

Commit 48de6ea

Browse files
author
Alex Akimov
committed
MAGETWO-49956: Store Selector for Product Page
- Implemented workaround for product validation issue on custom store view;
1 parent c981737 commit 48de6ea

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private function initAttributeValues($entityType, $entity, $storeId)
140140
'a.attribute_id = t.attribute_id',
141141
['attribute_code' => 'a.attribute_code']
142142
)
143-
->where($metadata->getLinkField() . ' = ?', $entity->getId())
143+
->where($metadata->getLinkField() . ' = ?', $entity->getData($metadata->getLinkField()))
144144
->where('t.attribute_id IN (?)', $attributeCodes)
145145
->where('t.store_id IN (?)', $storeIds);
146146
$selects[] = $select;

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,16 @@ public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveO
498498
$product->setCanSaveCustomOptions(true);
499499
}
500500

501-
$validationResult = $this->resourceModel->validate($product);
502-
if (true !== $validationResult) {
503-
throw new \Magento\Framework\Exception\CouldNotSaveException(
504-
__('Invalid product data: %1', implode(',', $validationResult))
505-
);
501+
$useValidation = \Magento\Store\Model\Store::ADMIN_CODE === $this->storeManager->getStore()->getCode();
502+
if ($useValidation) {
503+
$validationResult = $this->resourceModel->validate($product);
504+
if (true !== $validationResult) {
505+
throw new \Magento\Framework\Exception\CouldNotSaveException(
506+
__('Invalid product data: %1', implode(',', $validationResult))
507+
);
508+
}
506509
}
510+
507511
try {
508512
if ($tierPrices !== null) {
509513
$product->setData('tier_price', $tierPrices);

0 commit comments

Comments
 (0)