Skip to content

Commit

Permalink
Merge pull request magento#440 from magento-folks/switcher_stable
Browse files Browse the repository at this point in the history
[Folks] Add scope selector on Product Page
  • Loading branch information
irenelagno committed Mar 17, 2016
2 parents ad9a2af + ef98a7a commit 6c3c600
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private function initAttributeValues($entityType, $entity, $storeId)
'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;
Expand Down
14 changes: 9 additions & 5 deletions app/code/Magento/Catalog/Model/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,16 @@ public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveO
$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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ protected function setUp()
->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',
Expand Down

0 comments on commit 6c3c600

Please sign in to comment.