Skip to content

Commit 6c3c600

Browse files
committed
Merge pull request #440 from magento-folks/switcher_stable
[Folks] Add scope selector on Product Page
2 parents ad9a2af + ef98a7a commit 6c3c600

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-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);

app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ protected function setUp()
256256
->setMethods([])
257257
->getMockForAbstractClass();
258258
$storeMock->expects($this->any())->method('getWebsiteId')->willReturn('1');
259+
$storeMock->expects($this->any())->method('getCode')->willReturn(\Magento\Store\Model\Store::ADMIN_CODE);
259260
$this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($storeMock);
261+
$this->storeManagerMock->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']);
260262

261263
$this->mediaGalleryProcessor = $this->getMock(
262264
'Magento\Catalog\Model\Product\Gallery\Processor',

0 commit comments

Comments
 (0)