From 086ebae18d44c16fd38d9ea95300f58535af6145 Mon Sep 17 00:00:00 2001 From: Illia Grybkov Date: Wed, 7 Oct 2015 18:43:08 +0300 Subject: [PATCH 1/3] MAGETWO-43513: Creating a configurable product via import converts it to simple products --- .../CatalogImportExport/Model/Export/Product.php | 10 ++++------ .../Model/Export/RowCustomizer/Composite.php | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) 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); } } From 66d58aafbb5437ca464d81659f52e783e7a6b2fc Mon Sep 17 00:00:00 2001 From: Andrii Kasian Date: Fri, 9 Oct 2015 11:17:45 +0300 Subject: [PATCH 2/3] MAGETWO-43877: Search results are not ordered properly for sorting options --- app/code/Magento/Catalog/Block/Product/ListProduct.php | 2 +- app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php | 2 +- app/code/Magento/CatalogSearch/Block/Result.php | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) 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/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' ); From 4326efb4ff605a78a2a3657bb48b3f90d523aace Mon Sep 17 00:00:00 2001 From: Andrii Kasian Date: Mon, 12 Oct 2015 15:05:41 +0300 Subject: [PATCH 3/3] MAGETWO-43877: Search results are not ordered properly for sorting options --- .../Magento/Catalog/Model/Layer/Search/CollectionFilter.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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()); } }