Skip to content

Commit

Permalink
Merge pull request #2637 from magento-borg/MAGETWO-45950-product-join…
Browse files Browse the repository at this point in the history
…-query

[borg] MAGETWO-45950: Product ResourceCollection wrong Join Query
  • Loading branch information
cpartica authored Jun 2, 2018
2 parents bed4c32 + e718a1a commit 943e2cd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
13 changes: 0 additions & 13 deletions app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,19 +513,6 @@ public function getStoreId()
return $this->_storeManager->getStore()->getId();
}

/**
* Get collection instance
*
* @return object
* @deprecated 101.1.0 because collections should be used directly via factory
*/
public function getResourceCollection()
{
$collection = parent::getResourceCollection();
$collection->setStoreId($this->getStoreId());
return $collection;
}

/**
* Get product url model
*
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@
<argument name="customFilters" xsi:type="array">
<item name="category_id" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductCategoryFilter</item>
<item name="store" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductStoreFilter</item>
<item name="store_id" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductStoreFilter</item>
<item name="website_id" xsi:type="object">Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\ProductWebsiteFilter</item>
</argument>
</arguments>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Model;

class ProductRepositoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Catalog\Api\ProductRepositoryInterface
*/
private $productRepository;

/**
* @var \Magento\Framework\Api\SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;

/**
* Sets up common objects
*/
protected function setUp()
{
$this->productRepository = \Magento\Framework\App\ObjectManager::getInstance()->create(
\Magento\Catalog\Api\ProductRepositoryInterface::class
);

$this->searchCriteriaBuilder = \Magento\Framework\App\ObjectManager::getInstance()->create(
\Magento\Framework\Api\SearchCriteriaBuilder::class
);
}

/**
* Checks filtering by store_id
*
* @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php
*/
public function testFilterByStoreId()
{
$searchCriteria = $this->searchCriteriaBuilder
->addFilter('store_id', '1', 'eq')
->create();
$list = $this->productRepository->getList($searchCriteria);
$count = $list->getTotalCount();

$this->assertGreaterThanOrEqual(1, $count);
}
}

0 comments on commit 943e2cd

Please sign in to comment.