Skip to content

Commit e0a56a7

Browse files
committed
Merge pull request #26 from magento-dragons/PR
[DRAGONS] Bugs
2 parents 0be91a5 + f34eb55 commit e0a56a7

File tree

7 files changed

+88
-26
lines changed

7 files changed

+88
-26
lines changed

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\CatalogSearch\Model\Adapter\Mysql\Filter;
77

88
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
910
use Magento\CatalogSearch\Model\Search\TableMapper;
1011
use Magento\Eav\Model\Config;
1112
use Magento\Framework\App\ResourceConnection;
@@ -97,7 +98,7 @@ public function process(FilterInterface $filter, $isNegation, $query)
9798
*/
9899
private function processQueryWithField(FilterInterface $filter, $isNegation, $query)
99100
{
100-
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
101+
/** @var Attribute $attribute */
101102
$attribute = $this->config->getAttribute(Product::ENTITY, $filter->getField());
102103
if ($filter->getField() === 'price') {
103104
$resultQuery = str_replace(
@@ -114,24 +115,16 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
114115
$this->connection->quoteIdentifier($alias . '.' . $attribute->getAttributeCode()),
115116
$query
116117
);
117-
} elseif ($filter->getType() === FilterInterface::TYPE_TERM
118-
&& in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true)
118+
} elseif (
119+
$filter->getType() === FilterInterface::TYPE_TERM &&
120+
in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true)
119121
) {
120-
$alias = $this->tableMapper->getMappingAlias($filter);
121-
if (is_array($filter->getValue())) {
122-
$value = sprintf(
123-
'%s IN (%s)',
124-
($isNegation ? 'NOT' : ''),
125-
implode(',', $filter->getValue())
126-
);
127-
} else {
128-
$value = ($isNegation ? '!' : '') . '= ' . $filter->getValue();
129-
}
130-
$resultQuery = sprintf(
131-
'%1$s.value %2$s',
132-
$alias,
133-
$value
134-
);
122+
$resultQuery = $this->processTermSelect($filter, $isNegation);
123+
} elseif (
124+
$filter->getType() === FilterInterface::TYPE_RANGE &&
125+
in_array($attribute->getBackendType(), ['decimal', 'int'], true)
126+
) {
127+
$resultQuery = $this->processRangeNumeric($filter, $query, $attribute);
135128
} else {
136129
$table = $attribute->getBackendTable();
137130
$select = $this->connection->select();
@@ -161,4 +154,57 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
161154

162155
return $resultQuery;
163156
}
157+
158+
/**
159+
* @param FilterInterface $filter
160+
* @param string $query
161+
* @param Attribute $attribute
162+
* @return string
163+
*/
164+
private function processRangeNumeric(FilterInterface $filter, $query, $attribute)
165+
{
166+
$tableSuffix = $attribute->getBackendType() === 'decimal' ? '_decimal' : '';
167+
$table = $this->resource->getTableName("catalog_product_index_eav{$tableSuffix}");
168+
$select = $this->connection->select();
169+
170+
$currentStoreId = $this->scopeResolver->getScope()->getId();
171+
172+
$select->from(['main_table' => $table], 'entity_id')
173+
->columns([$filter->getField() => 'main_table.value'])
174+
->where('main_table.attribute_id = ?', $attribute->getAttributeId())
175+
->where('main_table.store_id = ?', $currentStoreId)
176+
->having($query);
177+
178+
$resultQuery = 'search_index.entity_id IN (
179+
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
180+
)';
181+
182+
return $resultQuery;
183+
}
184+
185+
/**
186+
* @param FilterInterface $filter
187+
* @param bool $isNegation
188+
* @return string
189+
*/
190+
private function processTermSelect(FilterInterface $filter, $isNegation)
191+
{
192+
$alias = $this->tableMapper->getMappingAlias($filter);
193+
if (is_array($filter->getValue())) {
194+
$value = sprintf(
195+
'%s IN (%s)',
196+
($isNegation ? 'NOT' : ''),
197+
implode(',', $filter->getValue())
198+
);
199+
} else {
200+
$value = ($isNegation ? '!' : '') . '= ' . $filter->getValue();
201+
}
202+
$resultQuery = sprintf(
203+
'%1$s.value %2$s',
204+
$alias,
205+
$value
206+
);
207+
208+
return $resultQuery;
209+
}
164210
}

app/code/Magento/GroupedProduct/view/adminhtml/layout/groupedproduct_popup_grid.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@
2424
<arguments>
2525
<argument name="id" xsi:type="string">grouped_grid_popup</argument>
2626
</arguments>
27-
<block class="Magento\Backend\Block\Widget\Grid\Column" as="entity_id">
27+
<block class="Magento\Backend\Block\Widget\Grid\Column" as="entity_ids">
2828
<arguments>
29-
<argument name="header" xsi:type="string" translate="true">ID</argument>
3029
<argument name="type" xsi:type="string">skip-list</argument>
3130
<argument name="renderer" xsi:type="string">Magento\Backend\Block\Widget\Grid\Column\Renderer\Checkbox</argument>
31+
<argument name="name" xsi:type="string">entity_ids</argument>
32+
<argument name="index" xsi:type="string">entity_id</argument>
33+
</arguments>
34+
</block>
35+
<block class="Magento\Backend\Block\Widget\Grid\Column" as="entity_id">
36+
<arguments>
37+
<argument name="header" xsi:type="string" translate="true">ID</argument>
3238
<argument name="index" xsi:type="string">entity_id</argument>
3339
</arguments>
3440
</block>

app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ define([
132132

133133
if (!target.is('input')) {
134134
target.closest('[data-role=row]')
135-
.find('[data-column=entity_id] input')
135+
.find('[data-column=entity_ids] input')
136136
.prop('checked', function (element, value) {
137137
return !value;
138138
})
@@ -142,7 +142,7 @@ define([
142142

143143
popup.on(
144144
'change',
145-
'[data-role=row] [data-column=entity_id] input',
145+
'[data-role=row] [data-column=entity_ids] input',
146146
$.proxy(function (event) {
147147
var element = $(event.target),
148148
product = {};
@@ -175,12 +175,12 @@ define([
175175
return $(element).val();
176176
}).toArray();
177177
ajaxSettings.data.filter = $.extend(ajaxSettings.data.filter || {}, {
178-
'entity_id': ids
178+
'entity_ids': ids
179179
});
180180
})
181181
.on('gridajax', function (event, ajaxRequest) {
182182
ajaxRequest.done(function () {
183-
popup.find('[data-role=row] [data-column=entity_id] input')
183+
popup.find('[data-role=row] [data-column=entity_ids] input')
184184
.each(function (index, element) {
185185
var $element = $(element);
186186
$element.prop('checked', !!selectedProductList[$element.val()]);

dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
<constraint name="Magento\Catalog\Test\Constraint\AssertProductVisibleInCategory" />
130130
<constraint name="Magento\Bundle\Test\Constraint\AssertBundleProductPage" />
131131
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInStock" />
132-
<constraint name="Magento\Bundle\Test\Constraint\AssertGroupedPriceOnBundleProductPage" />
133132
<constraint name="Magento\Bundle\Test\Constraint\AssertBundleItemsOnProductPage" />
134133
<constraint name="Magento\Bundle\Test\Constraint\AssertBundlePriceView" />
135134
<constraint name="Magento\Bundle\Test\Constraint\AssertBundlePriceType" />

dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function processAssert(
5858
. "\nActual: " . $actualPrice . "\n"
5959
);
6060
}
61+
$checkoutCartPage->getTotalsBlock()->waitForShippingPriceBlock();
6162
$actualPrices['sub_total'] = $checkoutCartPage->getTotalsBlock()->getSubtotal();
6263
$actualPrices['grand_total'] = $checkoutCartPage->getTotalsBlock()->getGrandTotal();
6364
$expectedPrices['sub_total'] = $cartPrice['sub_total'];

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,14 @@ public function waitForUpdatedTotals()
251251
sleep(1);
252252
$this->waitForElementNotVisible($this->blockWaitElement);
253253
}
254+
255+
/**
256+
* Wait for shipping block to appear
257+
*
258+
* @return bool|null
259+
*/
260+
public function waitForShippingPriceBlock()
261+
{
262+
$this->waitForElementVisible($this->shippingPriceBlockSelector, Locator::SELECTOR_CSS);
263+
}
254264
}

dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Grid extends GridInterface
3737
*
3838
* @var string
3939
*/
40-
protected $selectItem = '[data-column=entity_id] input';
40+
protected $selectItem = '[data-column=entity_ids] input';
4141

4242
/**
4343
* Press 'Add Selected Products' button

0 commit comments

Comments
 (0)