Skip to content
Snippets Groups Projects
Commit e011274e authored by Ievgen Shakhsuvarov's avatar Ievgen Shakhsuvarov
Browse files

MAGETWO-86311: Sort configurable attribute options by sort_order #12963

 - Merge Pull Request magento/magento2#12963 from wardcapp/magento2:magento-2.2/patch-MAGETWO-61484
 - Merged commits:
   1. 9794d38f
parents 79d8e9a0 9794d38f
No related merge requests found
...@@ -91,6 +91,12 @@ class OptionSelectBuilder implements OptionSelectBuilderInterface ...@@ -91,6 +91,12 @@ class OptionSelectBuilder implements OptionSelectBuilderInterface
] ]
), ),
[] []
)->joinInner(
['attribute_option' => $this->attributeResource->getTable('eav_attribute_option')],
'attribute_option.option_id = entity_value.value',
[]
)->order(
'attribute_option.sort_order ASC'
)->where( )->where(
'super_attribute.product_id = ?', 'super_attribute.product_id = ?',
$productId $productId
......
...@@ -66,7 +66,7 @@ class OptionSelectBuilderTest extends \PHPUnit\Framework\TestCase ...@@ -66,7 +66,7 @@ class OptionSelectBuilderTest extends \PHPUnit\Framework\TestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMockForAbstractClass(); ->getMockForAbstractClass();
$this->select = $this->getMockBuilder(Select::class) $this->select = $this->getMockBuilder(Select::class)
->setMethods(['from', 'joinInner', 'joinLeft', 'where', 'columns']) ->setMethods(['from', 'joinInner', 'joinLeft', 'where', 'columns', 'order'])
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->connectionMock->expects($this->atLeastOnce()) $this->connectionMock->expects($this->atLeastOnce())
...@@ -112,10 +112,28 @@ class OptionSelectBuilderTest extends \PHPUnit\Framework\TestCase ...@@ -112,10 +112,28 @@ class OptionSelectBuilderTest extends \PHPUnit\Framework\TestCase
{ {
$this->select->expects($this->exactly(1))->method('from')->willReturnSelf(); $this->select->expects($this->exactly(1))->method('from')->willReturnSelf();
$this->select->expects($this->exactly(1))->method('columns')->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(3))->method('joinLeft')->willReturnSelf();
$this->select->expects($this->exactly(1))->method('order')->willReturnSelf();
$this->select->expects($this->exactly(2))->method('where')->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()) $this->abstractAttributeMock->expects($this->atLeastOnce())
->method('getAttributeId') ->method('getAttributeId')
->willReturn('getAttributeId value'); ->willReturn('getAttributeId value');
...@@ -138,10 +156,27 @@ class OptionSelectBuilderTest extends \PHPUnit\Framework\TestCase ...@@ -138,10 +156,27 @@ class OptionSelectBuilderTest extends \PHPUnit\Framework\TestCase
{ {
$this->select->expects($this->exactly(1))->method('from')->willReturnSelf(); $this->select->expects($this->exactly(1))->method('from')->willReturnSelf();
$this->select->expects($this->exactly(0))->method('columns')->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('joinLeft')->willReturnSelf();
$this->select->expects($this->exactly(1))->method('order')->willReturnSelf();
$this->select->expects($this->exactly(2))->method('where')->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()) $this->abstractAttributeMock->expects($this->atLeastOnce())
->method('getAttributeId') ->method('getAttributeId')
->willReturn('getAttributeId value'); ->willReturn('getAttributeId value');
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment