diff --git a/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php b/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php index 7ec725b01de3478930e8c36f004c82e099267118..559bf8d6a259661a6120891a05cbcdfcec32595b 100644 --- a/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php +++ b/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php @@ -140,7 +140,7 @@ class ScopeOverriddenValue 'a.attribute_id = t.attribute_id', ['attribute_code' => 'a.attribute_code'] ) - ->where($metadata->getLinkField() . ' = ?', $entity->getId()) + ->where($metadata->getLinkField() . ' = ?', $entity->getData($metadata->getLinkField())) ->where('t.attribute_id IN (?)', $attributeCodes) ->where('t.store_id IN (?)', $storeIds); $selects[] = $select; diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index 9f1087544ae23f61f53666da32615257770ab176..76d048ebf2e984083e6f2f60788a99f93c280084 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -498,12 +498,16 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa $product->setCanSaveCustomOptions(true); } - $validationResult = $this->resourceModel->validate($product); - if (true !== $validationResult) { - throw new \Magento\Framework\Exception\CouldNotSaveException( - __('Invalid product data: %1', implode(',', $validationResult)) - ); + $useValidation = \Magento\Store\Model\Store::ADMIN_CODE === $this->storeManager->getStore()->getCode(); + if ($useValidation) { + $validationResult = $this->resourceModel->validate($product); + if (true !== $validationResult) { + throw new \Magento\Framework\Exception\CouldNotSaveException( + __('Invalid product data: %1', implode(',', $validationResult)) + ); + } } + try { if ($tierPrices !== null) { $product->setData('tier_price', $tierPrices); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 43aa01721c584d04d6422ef2ef1983c5e051d172..cb4fe91cae552cc20dee8c97dccf3be09be54da2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -256,7 +256,9 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase ->setMethods([]) ->getMockForAbstractClass(); $storeMock->expects($this->any())->method('getWebsiteId')->willReturn('1'); + $storeMock->expects($this->any())->method('getCode')->willReturn(\Magento\Store\Model\Store::ADMIN_CODE); $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($storeMock); + $this->storeManagerMock->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']); $this->mediaGalleryProcessor = $this->getMock( 'Magento\Catalog\Model\Product\Gallery\Processor',