diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php index 98aa6bb7e710ab1492fff90a66ae24dd7f5391ea..e692ea59d2d6ef1b97ea0b81a6458c8773907cf4 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php @@ -6,6 +6,7 @@ namespace Magento\CatalogSearch\Model\Adapter\Mysql\Filter; use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\ResourceModel\Eav\Attribute; use Magento\CatalogSearch\Model\Search\TableMapper; use Magento\Eav\Model\Config; use Magento\Framework\App\ResourceConnection; @@ -97,7 +98,7 @@ class Preprocessor implements PreprocessorInterface */ private function processQueryWithField(FilterInterface $filter, $isNegation, $query) { - /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ + /** @var Attribute $attribute */ $attribute = $this->config->getAttribute(Product::ENTITY, $filter->getField()); if ($filter->getField() === 'price') { $resultQuery = str_replace( @@ -114,24 +115,16 @@ class Preprocessor implements PreprocessorInterface $this->connection->quoteIdentifier($alias . '.' . $attribute->getAttributeCode()), $query ); - } elseif ($filter->getType() === FilterInterface::TYPE_TERM - && in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true) + } elseif ( + $filter->getType() === FilterInterface::TYPE_TERM && + in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true) ) { - $alias = $this->tableMapper->getMappingAlias($filter); - if (is_array($filter->getValue())) { - $value = sprintf( - '%s IN (%s)', - ($isNegation ? 'NOT' : ''), - implode(',', $filter->getValue()) - ); - } else { - $value = ($isNegation ? '!' : '') . '= ' . $filter->getValue(); - } - $resultQuery = sprintf( - '%1$s.value %2$s', - $alias, - $value - ); + $resultQuery = $this->processTermSelect($filter, $isNegation); + } elseif ( + $filter->getType() === FilterInterface::TYPE_RANGE && + in_array($attribute->getBackendType(), ['decimal', 'int'], true) + ) { + $resultQuery = $this->processRangeNumeric($filter, $query, $attribute); } else { $table = $attribute->getBackendTable(); $select = $this->connection->select(); @@ -161,4 +154,57 @@ class Preprocessor implements PreprocessorInterface return $resultQuery; } + + /** + * @param FilterInterface $filter + * @param string $query + * @param Attribute $attribute + * @return string + */ + private function processRangeNumeric(FilterInterface $filter, $query, $attribute) + { + $tableSuffix = $attribute->getBackendType() === 'decimal' ? '_decimal' : ''; + $table = $this->resource->getTableName("catalog_product_index_eav{$tableSuffix}"); + $select = $this->connection->select(); + + $currentStoreId = $this->scopeResolver->getScope()->getId(); + + $select->from(['main_table' => $table], 'entity_id') + ->columns([$filter->getField() => 'main_table.value']) + ->where('main_table.attribute_id = ?', $attribute->getAttributeId()) + ->where('main_table.store_id = ?', $currentStoreId) + ->having($query); + + $resultQuery = 'search_index.entity_id IN ( + select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter + )'; + + return $resultQuery; + } + + /** + * @param FilterInterface $filter + * @param bool $isNegation + * @return string + */ + private function processTermSelect(FilterInterface $filter, $isNegation) + { + $alias = $this->tableMapper->getMappingAlias($filter); + if (is_array($filter->getValue())) { + $value = sprintf( + '%s IN (%s)', + ($isNegation ? 'NOT' : ''), + implode(',', $filter->getValue()) + ); + } else { + $value = ($isNegation ? '!' : '') . '= ' . $filter->getValue(); + } + $resultQuery = sprintf( + '%1$s.value %2$s', + $alias, + $value + ); + + return $resultQuery; + } } diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/layout/groupedproduct_popup_grid.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/groupedproduct_popup_grid.xml index 87435ac42e867730101a2752f0cd1c95747d0fb2..e47123ca4322c75030941a8382f9fb8072a703ac 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/layout/groupedproduct_popup_grid.xml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/groupedproduct_popup_grid.xml @@ -24,11 +24,17 @@ <arguments> <argument name="id" xsi:type="string">grouped_grid_popup</argument> </arguments> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="entity_id"> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="entity_ids"> <arguments> - <argument name="header" xsi:type="string" translate="true">ID</argument> <argument name="type" xsi:type="string">skip-list</argument> <argument name="renderer" xsi:type="string">Magento\Backend\Block\Widget\Grid\Column\Renderer\Checkbox</argument> + <argument name="name" xsi:type="string">entity_ids</argument> + <argument name="index" xsi:type="string">entity_id</argument> + </arguments> + </block> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="entity_id"> + <arguments> + <argument name="header" xsi:type="string" translate="true">ID</argument> <argument name="index" xsi:type="string">entity_id</argument> </arguments> </block> diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js b/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js index b7badba6e79c142c8c1a92e0d60cdb41500507d4..1e497ed7b8231de9c057b986dc1f6c0387aa6aa2 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js +++ b/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js @@ -132,7 +132,7 @@ define([ if (!target.is('input')) { target.closest('[data-role=row]') - .find('[data-column=entity_id] input') + .find('[data-column=entity_ids] input') .prop('checked', function (element, value) { return !value; }) @@ -142,7 +142,7 @@ define([ popup.on( 'change', - '[data-role=row] [data-column=entity_id] input', + '[data-role=row] [data-column=entity_ids] input', $.proxy(function (event) { var element = $(event.target), product = {}; @@ -175,12 +175,12 @@ define([ return $(element).val(); }).toArray(); ajaxSettings.data.filter = $.extend(ajaxSettings.data.filter || {}, { - 'entity_id': ids + 'entity_ids': ids }); }) .on('gridajax', function (event, ajaxRequest) { ajaxRequest.done(function () { - popup.find('[data-role=row] [data-column=entity_id] input') + popup.find('[data-role=row] [data-column=entity_ids] input') .each(function (index, element) { var $element = $(element); $element.prop('checked', !!selectedProductList[$element.val()]); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml index 1654b19df2435385286d09db719cb4314f15fdba..530018bf81c4741e9785564800a14f39a3397ac1 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml @@ -129,7 +129,6 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductVisibleInCategory" /> <constraint name="Magento\Bundle\Test\Constraint\AssertBundleProductPage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInStock" /> - <constraint name="Magento\Bundle\Test\Constraint\AssertGroupedPriceOnBundleProductPage" /> <constraint name="Magento\Bundle\Test\Constraint\AssertBundleItemsOnProductPage" /> <constraint name="Magento\Bundle\Test\Constraint\AssertBundlePriceView" /> <constraint name="Magento\Bundle\Test\Constraint\AssertBundlePriceType" /> diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php index 7a4e4b605ef4b7c64a09c0ac6d613159167002c2..252a96620ece4f2838e057bd5ec1753d4f6729e1 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php @@ -58,6 +58,7 @@ class AssertCatalogPriceRuleAppliedShoppingCart extends AbstractConstraint . "\nActual: " . $actualPrice . "\n" ); } + $checkoutCartPage->getTotalsBlock()->waitForShippingPriceBlock(); $actualPrices['sub_total'] = $checkoutCartPage->getTotalsBlock()->getSubtotal(); $actualPrices['grand_total'] = $checkoutCartPage->getTotalsBlock()->getGrandTotal(); $expectedPrices['sub_total'] = $cartPrice['sub_total']; diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php index 8b2bfcbd56d4f4f3b90a03d9ecdad7b39d322efd..738bb89e949b6476bf67fbb1407b2be3e06ae192 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php @@ -251,4 +251,14 @@ class Totals extends Block sleep(1); $this->waitForElementNotVisible($this->blockWaitElement); } + + /** + * Wait for shipping block to appear + * + * @return bool|null + */ + public function waitForShippingPriceBlock() + { + $this->waitForElementVisible($this->shippingPriceBlockSelector, Locator::SELECTOR_CSS); + } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php index 55b341dc6d3b72224065b2c9b41e3bc05264834a..caa07b91ce7efd9d88bc031c324ca400c69d1d7c 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php @@ -37,7 +37,7 @@ class Grid extends GridInterface * * @var string */ - protected $selectItem = '[data-column=entity_id] input'; + protected $selectItem = '[data-column=entity_ids] input'; /** * Press 'Add Selected Products' button