-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1082 from magento-frontend/PR_26042017
Fixed issues: - MAGETWO-63197: ConfigureSecureUrlsTest is failing and next functional tests are also failing after it - MAGETWO-66501: Build to create 2.2 packages is broken - MAGETWO-63667: Can't get store-specific data via catalog API - MAGETWO-62404: Product image does not displays on Product detail page - MAGETWO-65540: When duplicating a product wrong images are assigned to the new duplicate product
- Loading branch information
Showing
13 changed files
with
324 additions
and
17 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...talog/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductStoreFilter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor; | ||
|
||
use Magento\Catalog\Model\ResourceModel\Product\Collection; | ||
use Magento\Framework\Api\Filter; | ||
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor\CustomFilterInterface; | ||
use Magento\Framework\Data\Collection\AbstractDb; | ||
|
||
class ProductStoreFilter implements CustomFilterInterface | ||
{ | ||
/** | ||
* Apply store Filter to Product Collection | ||
* | ||
* @param Filter $filter | ||
* @param AbstractDb $collection | ||
* @return bool Whether the filter is applied | ||
*/ | ||
public function apply(Filter $filter, AbstractDb $collection) | ||
{ | ||
/** @var Collection $collection */ | ||
$collection->addStoreFilter($filter->getValue()); | ||
return true; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...log/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductWebsiteFilter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor; | ||
|
||
use Magento\Catalog\Model\ResourceModel\Product\Collection; | ||
use Magento\Framework\Api\Filter; | ||
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor\CustomFilterInterface; | ||
use Magento\Framework\Data\Collection\AbstractDb; | ||
|
||
class ProductWebsiteFilter implements CustomFilterInterface | ||
{ | ||
/** | ||
* Apply website Filter to Product Collection | ||
* | ||
* @param Filter $filter | ||
* @param AbstractDb $collection | ||
* @return bool Whether the filter is applied | ||
*/ | ||
public function apply(Filter $filter, AbstractDb $collection) | ||
{ | ||
$value = $filter->getValue(); | ||
if (strpos($value, ',') !== false) { | ||
$value = explode(',', $value); | ||
} | ||
/** @var Collection $collection */ | ||
$collection->addWebsiteFilter($value); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductWebsiteFilterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Catalog\Test\Unit\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor; | ||
|
||
use Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductWebsiteFilter; | ||
use Magento\Catalog\Model\ResourceModel\Product\Collection; | ||
use Magento\Framework\Api\Filter; | ||
|
||
class ProductWebsiteFilterTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var ProductWebsiteFilter */ | ||
private $model; | ||
|
||
protected function setUp() | ||
{ | ||
$this->model = new ProductWebsiteFilter(); | ||
} | ||
|
||
public function testApply() | ||
{ | ||
/** @var Filter|\PHPUnit_Framework_MockObject_MockObject $filterMock */ | ||
$filterMock = $this->getMockBuilder(Filter::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
/** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */ | ||
$collectionMock = $this->getMockBuilder(Collection::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$filterMock->expects($this->once()) | ||
->method('getValue') | ||
->willReturn('1,2'); | ||
|
||
$collectionMock->expects($this->once()) | ||
->method('addWebsiteFilter') | ||
->with(['1', '2']); | ||
|
||
$this->assertTrue($this->model->apply($filterMock, $collectionMock)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_websites_and_stores.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
require __DIR__ . '/../../Store/_files/second_website_with_two_stores.php'; | ||
|
||
$website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Website::class); | ||
/** @var $website \Magento\Store\Model\Website */ | ||
$websiteId = $website->load('test', 'code')->getId(); | ||
|
||
/** @var $product \Magento\Catalog\Model\Product */ | ||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); | ||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) | ||
->setAttributeSetId(4) | ||
->setWebsiteIds([$websiteId]) | ||
->setName('Simple Product on second website') | ||
->setSku('simple-2') | ||
->setPrice(10) | ||
->setDescription('Description with <b>html tag</b>') | ||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) | ||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) | ||
->setCategoryIds([2]) | ||
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]) | ||
->save(); | ||
|
||
/** @var $product \Magento\Catalog\Model\Product */ | ||
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); | ||
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) | ||
->setAttributeSetId(4) | ||
->setWebsiteIds([1]) | ||
->setName('Simple Product') | ||
->setSku('simple-1') | ||
->setPrice(10) | ||
->setDescription('Description with <b>html tag</b>') | ||
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) | ||
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) | ||
->setCategoryIds([2]) | ||
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]) | ||
->save(); |
Oops, something went wrong.