Skip to content

Commit

Permalink
MAGETWO-86311: Sort configurable attribute options by sort_order #12963
Browse files Browse the repository at this point in the history
  • Loading branch information
ishakhsuvarov authored Jan 5, 2018
2 parents 09cc206 + e011274 commit d39c7d5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public function getSelect(AbstractAttribute $superAttribute, int $productId, Sco
]
),
[]
)->joinInner(
['attribute_option' => $this->attributeResource->getTable('eav_attribute_option')],
'attribute_option.option_id = entity_value.value',
[]
)->order(
'attribute_option.sort_order ASC'
)->where(
'super_attribute.product_id = ?',
$productId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->select = $this->getMockBuilder(Select::class)
->setMethods(['from', 'joinInner', 'joinLeft', 'where', 'columns'])
->setMethods(['from', 'joinInner', 'joinLeft', 'where', 'columns', 'order'])
->disableOriginalConstructor()
->getMock();
$this->connectionMock->expects($this->atLeastOnce())
Expand Down Expand Up @@ -112,10 +112,28 @@ public function testGetSelect()
{
$this->select->expects($this->exactly(1))->method('from')->willReturnSelf();
$this->select->expects($this->exactly(1))->method('columns')->willReturnSelf();
$this->select->expects($this->exactly(5))->method('joinInner')->willReturnSelf();
$this->select->expects($this->exactly(6))->method('joinInner')->willReturnSelf();
$this->select->expects($this->exactly(3))->method('joinLeft')->willReturnSelf();
$this->select->expects($this->exactly(1))->method('order')->willReturnSelf();
$this->select->expects($this->exactly(2))->method('where')->willReturnSelf();

$this->attributeResourceMock->expects($this->exactly(9))
->method('getTable')
->will(
$this->returnValueMap(
[
['catalog_product_super_attribute', 'catalog_product_super_attribute value'],
['catalog_product_entity', 'catalog_product_entity value'],
['catalog_product_super_link', 'catalog_product_super_link value'],
['eav_attribute', 'eav_attribute value'],
['catalog_product_entity', 'catalog_product_entity value'],
['catalog_product_super_attribute_label', 'catalog_product_super_attribute_label value'],
['eav_attribute_option', 'eav_attribute_option value'],
['eav_attribute_option_value', 'eav_attribute_option_value value']
]
)
);

$this->abstractAttributeMock->expects($this->atLeastOnce())
->method('getAttributeId')
->willReturn('getAttributeId value');
Expand All @@ -138,10 +156,27 @@ public function testGetSelectWithBackendModel()
{
$this->select->expects($this->exactly(1))->method('from')->willReturnSelf();
$this->select->expects($this->exactly(0))->method('columns')->willReturnSelf();
$this->select->expects($this->exactly(5))->method('joinInner')->willReturnSelf();
$this->select->expects($this->exactly(6))->method('joinInner')->willReturnSelf();
$this->select->expects($this->exactly(1))->method('joinLeft')->willReturnSelf();
$this->select->expects($this->exactly(1))->method('order')->willReturnSelf();
$this->select->expects($this->exactly(2))->method('where')->willReturnSelf();

$this->attributeResourceMock->expects($this->exactly(7))
->method('getTable')
->will(
$this->returnValueMap(
[
['catalog_product_super_attribute', 'catalog_product_super_attribute value'],
['catalog_product_entity', 'catalog_product_entity value'],
['catalog_product_super_link', 'catalog_product_super_link value'],
['eav_attribute', 'eav_attribute value'],
['catalog_product_entity', 'catalog_product_entity value'],
['catalog_product_super_attribute_label', 'catalog_product_super_attribute_label value'],
['eav_attribute_option', 'eav_attribute_option value']
]
)
);

$this->abstractAttributeMock->expects($this->atLeastOnce())
->method('getAttributeId')
->willReturn('getAttributeId value');
Expand Down

0 comments on commit d39c7d5

Please sign in to comment.