Skip to content

Commit

Permalink
Merge pull request #1212 from magento-nord/NORD-FIXES
Browse files Browse the repository at this point in the history
Fixed isues:
- MAGETWO-69946 Product list widget is not working with SKU field
  • Loading branch information
balex13 authored Jun 21, 2017
2 parents 09a4858 + 4eb8398 commit 75d1e40
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function addNotGlobalAttribute(
public function getMappedSqlField()
{
$result = '';
if ($this->getAttribute() == 'category_ids') {
if (in_array($this->getAttribute(), ['category_ids', 'sku'])) {
$result = parent::getMappedSqlField();
} elseif (isset($this->joinedAttributes[$this->getAttribute()])) {
$result = $this->joinedAttributes[$this->getAttribute()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ protected function setUp()
'',
false
);
$eavConfig->expects($this->once())->method('getAttribute')->willReturn($this->attributeMock);
$eavConfig->expects($this->any())->method('getAttribute')->willReturn($this->attributeMock);
$ruleMock = $this->getMock(\Magento\SalesRule\Model\Rule::class, [], [], '', false);
$storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class);
$storeMock = $this->getMock(\Magento\Store\Api\Data\StoreInterface::class);
$storeManager->expects($this->once())->method('getStore')->willReturn($storeMock);
$storeManager->expects($this->any())->method('getStore')->willReturn($storeMock);
$this->resourceMock = $this->getMock(
\Magento\Indexer\Model\ResourceModel\FrontendResource::class,
[],
Expand All @@ -49,8 +49,8 @@ protected function setUp()
false
);
$productResource = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product::class, [], [], '', false);
$productResource->expects($this->once())->method('loadAllAttributes')->willReturnSelf();
$productResource->expects($this->once())->method('getAttributesByCode')->willReturn([]);
$productResource->expects($this->any())->method('loadAllAttributes')->willReturnSelf();
$productResource->expects($this->any())->method('getAttributesByCode')->willReturn([]);
$this->model = $objectManagerHelper->getObject(
\Magento\CatalogWidget\Model\Rule\Condition\Product::class,
[
Expand Down Expand Up @@ -88,4 +88,10 @@ public function testAddToCollection()
$this->resourceMock->expects($this->once())->method('getMainTable')->willReturn('catalog_product_index_eav');
$this->model->addToCollection($collectionMock);
}

public function testGetMappedSqlFieldSku()
{
$this->model->setAttribute('sku');
$this->assertEquals('e.sku', $this->model->getMappedSqlField());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,13 @@ public function testGetMappedSqlFieldCategoryIdsAttribute()
$this->conditionProduct->setAttribute('category_ids');
$this->assertEquals('e.entity_id', $this->conditionProduct->getMappedSqlField());
}

/**
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
*/
public function testGetMappedSqlFieldSkuAttribute()
{
$this->conditionProduct->setAttribute('sku');
$this->assertEquals('e.sku', $this->conditionProduct->getMappedSqlField());
}
}

0 comments on commit 75d1e40

Please sign in to comment.