diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php index 7be200b769c53..f180b82e8aaea 100644 --- a/app/code/Magento/Catalog/Block/Product/ListProduct.php +++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php @@ -296,7 +296,7 @@ public function prepareSortableFieldsByCategory($category) } $availableOrders = $this->getAvailableOrders(); if (!$this->getSortBy()) { - $categorySortBy = $category->getDefaultSortBy(); + $categorySortBy = $this->getDefaultSortBy() ?: $category->getDefaultSortBy(); if ($categorySortBy) { if (!$availableOrders) { $availableOrders = $this->_getConfig()->getAttributeUsedForSortByArray(); diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php index e4b335cc9d6d4..74df2024cfcf7 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php @@ -356,7 +356,7 @@ public function removeOrderFromAvailableOrders($order) } /** - * Compare defined order field vith current order field + * Compare defined order field with current order field * * @param string $order * @return bool diff --git a/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php b/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php index dfb862d4d2141..abf8f015bf4f4 100644 --- a/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php +++ b/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php @@ -8,7 +8,6 @@ use Magento\Catalog\Model\Config; use Magento\Catalog\Model\Layer\CollectionFilterInterface; use Magento\Catalog\Model\Product\Visibility; -use Magento\Framework\DB\Select; use Magento\Store\Model\StoreManagerInterface; class CollectionFilter implements CollectionFilterInterface @@ -63,7 +62,6 @@ public function filter( ->addTaxPercents() ->addStoreFilter() ->addUrlRewrite() - ->setVisibility($this->productVisibility->getVisibleInSearchIds()) - ->setOrder('relevance', Select::SQL_DESC); + ->setVisibility($this->productVisibility->getVisibleInSearchIds()); } } diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php index bc2dde2da2ce2..0b7d2f3a453a6 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php @@ -874,13 +874,11 @@ protected function collectRawData() } if ($this->_attributeTypes[$code] !== 'multiselect') { - if (is_scalar($attrValue)) { - if (!in_array($fieldName, $this->_getExportMainAttrCodes())) { - $additionalAttributes[$fieldName] = $fieldName . - ImportProduct::PAIR_NAME_VALUE_SEPARATOR . $attrValue; - } - $data[$itemId][$storeId][$fieldName] = $attrValue; + if (!in_array($fieldName, $this->_getExportMainAttrCodes())) { + $additionalAttributes[$fieldName] = $fieldName . + ImportProduct::PAIR_NAME_VALUE_SEPARATOR . $attrValue; } + $data[$itemId][$storeId][$fieldName] = $attrValue; } else { $this->collectMultiselectValues($item, $code, $storeId); if (!empty($this->collectedMultiselectsData[$storeId][$itemId][$code])) { diff --git a/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer/Composite.php b/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer/Composite.php index 1997d39b47efc..f1559822bbc3b 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer/Composite.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer/Composite.php @@ -40,7 +40,8 @@ public function __construct(ObjectManagerInterface $objectManager, $customizers public function prepareData($collection, $productIds) { foreach ($this->customizers as $className) { - $this->objectManager->get($className)->prepareData($collection, $productIds); + $customCollection = clone $collection; + $this->objectManager->get($className)->prepareData($customCollection, $productIds); } } diff --git a/app/code/Magento/CatalogSearch/Block/Result.php b/app/code/Magento/CatalogSearch/Block/Result.php index 072b76a797339..a1149d83202bb 100644 --- a/app/code/Magento/CatalogSearch/Block/Result.php +++ b/app/code/Magento/CatalogSearch/Block/Result.php @@ -133,12 +133,13 @@ public function setListOrders() /* @var $category \Magento\Catalog\Model\Category */ $availableOrders = $category->getAvailableSortByOptions(); unset($availableOrders['position']); + $availableOrders['relevance'] = __('Relevance'); $this->getListBlock()->setAvailableOrders( $availableOrders )->setDefaultDirection( 'desc' - )->setSortBy( + )->setDefaultSortBy( 'relevance' );