1
diff --git a/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php b/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php
index 8d3db36e35dec..e122f61ff1b29 100644
--- a/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php
+++ b/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php
@@ -9,6 +9,7 @@
use Magento\Framework\Data\Collection\EntityFactoryInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Helper;
+use Magento\Framework\DB\Select;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
@@ -26,22 +27,16 @@
class Collection extends AbstractCollection
{
/**
- * Store for filter
- *
* @var int
*/
protected $_storeId;
/**
- * Store manager
- *
* @var StoreManagerInterface
*/
protected $_storeManager;
/**
- * Search resource helper
- *
* @var Helper
*/
protected $_resourceHelper;
@@ -116,21 +111,22 @@ public function getStoreId()
*/
public function setQueryFilter($query)
{
- $this->getSelect()->reset(
- \Magento\Framework\DB\Select::FROM
- )->distinct(
- true
- )->from(
- ['main_table' => $this->getTable('search_query')]
- )->where(
- 'num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?',
- $this->_resourceHelper->addLikeEscape($query, ['position' => 'start'])
- )->order(
- 'popularity ' . \Magento\Framework\DB\Select::SQL_DESC
- );
+ $this->getSelect()
+ ->reset(Select::FROM)
+ ->distinct(true)
+ ->from(['main_table' => $this->getTable('search_query')])
+ ->reset(Select::COLUMNS)
+ ->columns(['query_text', 'num_results', 'popularity'])
+ ->where(
+ 'num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?',
+ $this->_resourceHelper->addLikeEscape($query, ['position' => 'start'])
+ )
+ ->order('popularity ' . \Magento\Framework\DB\Select::SQL_DESC);
+
if ($this->getStoreId()) {
$this->getSelect()->where('store_id = ?', (int)$this->getStoreId());
}
+
return $this;
}
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php
index 5caaf9742aed2..bd78b151197f5 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php
@@ -42,8 +42,6 @@ class ProductTest extends \PHPUnit\Framework\TestCase
private $productRepository;
/**
- * Stock item attributes which must be exported
- *
* @var array
*/
public static $stockItemAttributes = [
@@ -132,7 +130,9 @@ public function testExportWithJsonAndMarkupTextAttribute(string $attributeData,
$attribute = $eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'text_attribute');
$attribute->setDefaultValue($attributeData);
/** @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface $productAttributeRepository */
- $productAttributeRepository = $objectManager->get(\Magento\Catalog\Api\ProductAttributeRepositoryInterface::class);
+ $productAttributeRepository = $objectManager->get(
+ \Magento\Catalog\Api\ProductAttributeRepositoryInterface::class
+ );
$productAttributeRepository->save($attribute);
$product->setCustomAttribute('text_attribute', $attribute->getDefaultValue());
$productRepository->save($product);
@@ -154,14 +154,14 @@ public function exportWithJsonAndMarkupTextAttributeDataProvider(): array
{
return [
'json' => [
- '{"type": "basic", "unit": "inch", "sign": "(\")", "size": "1.5\""}',
- '"text_attribute={""type"": ""basic"", ""unit"": ""inch"", ""sign"": ""(\"")"", ""size"": ""1.5\""""}"'
+ '{"type": "basic", "unit": "inch", "sign": "(")", "size": "1.5""}',
+ '"text_attribute={""type"": ""basic"", ""unit"": ""inch"", ""sign"": ""("")"", ""size"": ""1.5""""}"'
],
'markup' => [
'Element type is basic, measured in inches ' .
- '(marked with sign (\")) with size 1.5\", mid-price range
',
+ '(marked with sign (")) with size 1.5", mid-price range',
'"text_attribute=Element type is basic, measured in inches ' .
- '(marked with sign (\"")) with size 1.5\"", mid-price range
"'
+ '(marked with sign ("")) with size 1.5"", mid-price range"'
],
];
}
@@ -607,7 +607,7 @@ public function testExportProductWithTwoWebsites(): void
$productAction->updateWebsites([$productId], [$secondStore->getWebsiteId()], 'add');
$product->setStoreId($secondStore->getId());
$product->setPrice('9.99');
- $product->getResource()->save($product);
+ $this->productRepository->save($product);
$exportData = $this->model->export();