From 952b333b9908121f17e966078737c21b8620cce6 Mon Sep 17 00:00:00 2001 From: Lewis Voncken Date: Mon, 27 Aug 2018 23:31:03 +0200 Subject: [PATCH 01/11] [FEATURE] [issue-3283] Added Filter Support for Yes/No (boolean) attributes --- .../Magento/Catalog/Model/ResourceModel/Eav/Attribute.php | 2 +- .../Model/ResourceModel/Product/Indexer/Eav/Source.php | 2 +- .../templates/catalog/product/attribute/js.phtml | 2 +- .../Front/ProductAttributeFormBuildFrontTabObserver.php | 8 ++++---- .../adminhtml/ui_component/product_attribute_add_form.xml | 6 ++++-- .../Swatches/view/adminhtml/web/js/product-attributes.js | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php index d8243c05dc7ba..f9ec6500b1635 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php @@ -462,7 +462,7 @@ protected function _isOriginalIndexable() $backendType = $this->getOrigData('backend_type'); $frontendInput = $this->getOrigData('frontend_input'); - if ($backendType == 'int' && $frontendInput == 'select') { + if ($backendType == 'int' && ($frontendInput == 'select' || $frontendInput == 'boolean')) { return true; } elseif ($backendType == 'varchar' && $frontendInput == 'multiselect') { return true; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php index 5b68730209b40..77836c58d5070 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php @@ -84,7 +84,7 @@ protected function _getIndexableAttributes($multiSelect) if ($multiSelect == true) { $select->where('ea.backend_type = ?', 'varchar')->where('ea.frontend_input = ?', 'multiselect'); } else { - $select->where('ea.backend_type = ?', 'int')->where('ea.frontend_input = ?', 'select'); + $select->where('ea.backend_type = ?', 'int')->where('ea.frontend_input IN( ? )', ['select', 'boolean']); } return $this->getConnection()->fetchCol($select); diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml index 8a5f1919f78be..3cbfa0f29d74f 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml @@ -55,7 +55,7 @@ function bindAttributeInputType() { checkOptionsPanelVisibility(); switchDefaultValueField(); - if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price')){ + if($('frontend_input') && ($('frontend_input').value=='boolean' || $('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price')){ if($('is_filterable') && !$('is_filterable').getAttribute('readonly')){ $('is_filterable').disabled = false; } diff --git a/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php b/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php index 6b64610caf5ed..97c9d46882cd3 100644 --- a/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php +++ b/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php @@ -54,8 +54,8 @@ public function execute(\Magento\Framework\Event\Observer $observer) [ 'name' => 'is_filterable', 'label' => __("Use in Layered Navigation"), - 'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'), - 'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'), + 'title' => __('Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price'), + 'note' => __('Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price.'), 'values' => [ ['value' => '0', 'label' => __('No')], ['value' => '1', 'label' => __('Filterable (with results)')], @@ -70,8 +70,8 @@ public function execute(\Magento\Framework\Event\Observer $observer) [ 'name' => 'is_filterable_in_search', 'label' => __("Use in Search Results Layered Navigation"), - 'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'), - 'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'), + 'title' => __('Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price'), + 'note' => __('Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price.'), 'values' => $this->optionList->toOptionArray(), ] ); diff --git a/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attribute_add_form.xml b/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attribute_add_form.xml index 000e10197af1b..0d7476081d19e 100644 --- a/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attribute_add_form.xml +++ b/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attribute_add_form.xml @@ -11,6 +11,7 @@ + boolean select multiselect price @@ -19,7 +20,7 @@ - Can be used only with catalog input type Dropdown, Multiple Select and Price. + Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price. string is_filterable @@ -36,6 +37,7 @@ + boolean select multiselect price @@ -45,7 +47,7 @@ - Can be used only with catalog input type Dropdown, Multiple Select and Price. + Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price. is_filterable_in_search diff --git a/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js b/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js index 1a58e4b6f2e7a..4c9df6ef657d7 100644 --- a/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js +++ b/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js @@ -45,7 +45,7 @@ define([ get tabsFront() { return this.attrTabsFront.length ? this.attrTabsFront.closest('li') : $('#front_fieldset-wrapper'); }, - selectFields: ['select', 'multiselect', 'price', 'swatch_text', 'swatch_visual'], + selectFields: ['boolean', 'select', 'multiselect', 'price', 'swatch_text', 'swatch_visual'], /** * @this {swatchProductAttributes} From a2d9a6a5f84d680c23d4f269596baf40ac709395 Mon Sep 17 00:00:00 2001 From: Lewis Voncken Date: Tue, 28 Aug 2018 09:32:16 +0200 Subject: [PATCH 02/11] [TASK] Updated Title and Comment of the is_filterable and is_filterable_in_search fields according to the PHP Code Sniffer --- .../Front/ProductAttributeFormBuildFrontTabObserver.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php b/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php index 97c9d46882cd3..fc1edeb1e2392 100644 --- a/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php +++ b/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php @@ -54,8 +54,8 @@ public function execute(\Magento\Framework\Event\Observer $observer) [ 'name' => 'is_filterable', 'label' => __("Use in Layered Navigation"), - 'title' => __('Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price'), - 'note' => __('Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price.'), + 'title' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price'), + 'note' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price.'), 'values' => [ ['value' => '0', 'label' => __('No')], ['value' => '1', 'label' => __('Filterable (with results)')], @@ -70,8 +70,8 @@ public function execute(\Magento\Framework\Event\Observer $observer) [ 'name' => 'is_filterable_in_search', 'label' => __("Use in Search Results Layered Navigation"), - 'title' => __('Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price'), - 'note' => __('Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price.'), + 'title' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price'), + 'note' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price.'), 'values' => $this->optionList->toOptionArray(), ] ); From 9f19592b3a1dc33a8a3a23c694880e5e6c5ca6a3 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolowski Date: Mon, 10 Sep 2018 13:12:15 +0200 Subject: [PATCH 03/11] Fix category tree in cart price rule #17493 --- .../Catalog/view/adminhtml/web/js/category-checkbox-tree.js | 1 + .../Controller/Adminhtml/Promo/Widget/CategoriesJson.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/category-checkbox-tree.js b/app/code/Magento/Catalog/view/adminhtml/web/js/category-checkbox-tree.js index 72cad03eabe1b..1d64418e36ff5 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/category-checkbox-tree.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/category-checkbox-tree.js @@ -230,6 +230,7 @@ define([ categoryLoader.on('beforeload', function (treeLoader, node) { treeLoader.baseParams.id = node.attributes.id; + treeLoader.baseParams.selected = options.jsFormObject.updateElement.value; }); /* eslint-disable */ diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget/CategoriesJson.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget/CategoriesJson.php index d049d74bd2601..3d1ac9744ef8b 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget/CategoriesJson.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget/CategoriesJson.php @@ -77,10 +77,11 @@ public function execute() if (!($category = $this->_initCategory())) { return; } + $selected = $this->getRequest()->getPost('selected', ''); $block = $this->_view->getLayout()->createBlock( \Magento\Catalog\Block\Adminhtml\Category\Checkboxes\Tree::class )->setCategoryIds( - [$categoryId] + explode(',', $selected) ); $this->getResponse()->representJson( $block->getTreeJson($category) From 6e4a4b2d85e25c58e72914a7904a5dc9aa7e43f5 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolowski Date: Tue, 18 Sep 2018 11:24:26 +0200 Subject: [PATCH 04/11] Fix table rate failing for zip+4 address #17770 --- .../Carrier/Tablerate/RateQuery.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/RateQuery.php b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/RateQuery.php index 5b03ef0cb02bd..aa561bf4499c1 100644 --- a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/RateQuery.php +++ b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/RateQuery.php @@ -42,6 +42,7 @@ public function prepareSelect(\Magento\Framework\DB\Select $select) ') OR (', [ "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode", + "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode_prefix", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''", // Handle asterisk in dest_zip field @@ -51,7 +52,7 @@ public function prepareSelect(\Magento\Framework\DB\Select $select) "dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode", - "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'" + "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode_prefix" ] ) . ')'; $select->where($orWhere); @@ -85,6 +86,7 @@ public function getBindings() ':country_id' => $this->request->getDestCountryId(), ':region_id' => (int)$this->request->getDestRegionId(), ':postcode' => $this->request->getDestPostcode(), + ':postcode_prefix' => $this->getDestPostcodePrefix() ]; // Render condition by condition name @@ -112,4 +114,18 @@ public function getRequest() { return $this->request; } + + /** + * Returns the entire postcode if it contains no dash + * or the part of it prior to the dash in the other case + * @return string + */ + private function getDestPostcodePrefix() + { + if (!preg_match("/^(.+)-(.+)$/", $this->request->getDestPostcode(), $zipParts)) { + return $this->request->getDestPostcode(); + } + + return $zipParts[1]; + } } From a251a8d36ec2c10d175302cac3675e97990bce47 Mon Sep 17 00:00:00 2001 From: Pieter Hoste Date: Sun, 23 Sep 2018 14:10:01 +0200 Subject: [PATCH 05/11] Backport 2.2 - Introducing a dedicated cron.log file for logging cron related info, this reduces output in the system.log file. (cherry picked from commit a4f58c8806d93ff20f921e02785a78bda00adf46) --- app/code/Magento/Cron/etc/di.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml index a37f3760b70a5..3e3bdc2053576 100644 --- a/app/code/Magento/Cron/etc/di.xml +++ b/app/code/Magento/Cron/etc/di.xml @@ -16,6 +16,18 @@ + + + /var/log/cron.log + + + + + + Magento\Cron\Model\VirtualLoggerHandler + + + @@ -25,6 +37,7 @@ shellBackground + Magento\Cron\Model\VirtualLogger From 3e066db75e495f96d264bf1347b9fec01a44032e Mon Sep 17 00:00:00 2001 From: Pieter Hoste Date: Tue, 25 Sep 2018 19:57:09 +0200 Subject: [PATCH 06/11] Backport 2.2 - Don't set a source model on the attribute when it's not needed. This avoids accidentally persisting the source model to the database when using multiselect attributes. (cherry picked from commit 477ca51d052464e862301d945c8bb3550b6fa829) --- .../Eav/Model/Entity/Attribute/AbstractAttribute.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php index 0f3a1f2220644..65b60be0d96fd 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php @@ -594,9 +594,11 @@ public function getSource() { if (empty($this->_source)) { if (!$this->getSourceModel()) { - $this->setSourceModel($this->_getDefaultSourceModel()); + $this->_source = $this->_getDefaultSourceModel(); + } else { + $this->_source = $this->getSourceModel(); } - $source = $this->_universalFactory->create($this->getSourceModel()); + $source = $this->_universalFactory->create($this->_source); if (!$source) { throw new LocalizedException( __( From 6b3a59b242bb37980aa2bb8eb25c1119bfb8d577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Corr=C3=AAa=20Gomes?= Date: Fri, 5 Oct 2018 11:24:11 -0400 Subject: [PATCH 07/11] Setup Wizard > Menu Logo Bugfix --- setup/view/magento/setup/navigation/side-menu.phtml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/setup/view/magento/setup/navigation/side-menu.phtml b/setup/view/magento/setup/navigation/side-menu.phtml index 58d12a4de448a..f34a6c7c72e69 100644 --- a/setup/view/magento/setup/navigation/side-menu.phtml +++ b/setup/view/magento/setup/navigation/side-menu.phtml @@ -20,12 +20,8 @@ ng-show="" >