From c6829c0bc9e310b6e95662f8eb4a313c862776df Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov Date: Tue, 22 Sep 2015 13:05:46 +0300 Subject: [PATCH 01/52] MAGETWO-35324: Success message for contact us form does not disappear even after closing browser --- app/code/Magento/Contact/Block/ContactForm.php | 8 ++++++++ app/code/Magento/Contact/Controller/Index/Index.php | 3 --- app/code/Magento/Contact/Controller/Index/Post.php | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Contact/Block/ContactForm.php b/app/code/Magento/Contact/Block/ContactForm.php index 907bccb5a494b..6517c2092743c 100644 --- a/app/code/Magento/Contact/Block/ContactForm.php +++ b/app/code/Magento/Contact/Block/ContactForm.php @@ -21,4 +21,12 @@ public function __construct(Template\Context $context, array $data = []) parent::__construct($context, $data); $this->_isScopePrivate = true; } + + /** + * @return string + */ + public function getFormAction() + { + return $this->getUrl('contact/index/post'); + } } diff --git a/app/code/Magento/Contact/Controller/Index/Index.php b/app/code/Magento/Contact/Controller/Index/Index.php index b6e6e3f0ffaa0..247728f63f881 100644 --- a/app/code/Magento/Contact/Controller/Index/Index.php +++ b/app/code/Magento/Contact/Controller/Index/Index.php @@ -16,9 +16,6 @@ class Index extends \Magento\Contact\Controller\Index public function execute() { $this->_view->loadLayout(); - $this->_view->getLayout() - ->getBlock('contactForm') - ->setFormAction($this->_url->getUrl('*/*/post', ['_secure' => true])); $this->_view->renderLayout(); } } diff --git a/app/code/Magento/Contact/Controller/Index/Post.php b/app/code/Magento/Contact/Controller/Index/Post.php index b6fae4cad8a63..f5114cd6f68b9 100644 --- a/app/code/Magento/Contact/Controller/Index/Post.php +++ b/app/code/Magento/Contact/Controller/Index/Post.php @@ -65,14 +65,14 @@ public function execute() $this->messageManager->addSuccess( __('Thanks for contacting us with your comments and questions. We\'ll respond to you very soon.') ); - $this->_redirect('*/*/'); + $this->_redirect('contact/index'); return; } catch (\Exception $e) { $this->inlineTranslation->resume(); $this->messageManager->addError( __('We can\'t process your request right now. Sorry, that\'s all we know.') ); - $this->_redirect('*/*/'); + $this->_redirect('contact/index'); return; } } From e4d12a337b64d1a084d851580913b47c587eada1 Mon Sep 17 00:00:00 2001 From: Volodymyr Kholoshenko Date: Tue, 22 Sep 2015 13:50:20 +0300 Subject: [PATCH 02/52] MAGETWO-42712: Configurable product special price changes to regular price with the selection of configurable attributes --- .../view/frontend/web/js/SwatchRenderer.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Swatches/view/frontend/web/js/SwatchRenderer.js b/app/code/Magento/Swatches/view/frontend/web/js/SwatchRenderer.js index c6feb68cd6265..df8fa96a64910 100644 --- a/app/code/Magento/Swatches/view/frontend/web/js/SwatchRenderer.js +++ b/app/code/Magento/Swatches/view/frontend/web/js/SwatchRenderer.js @@ -173,15 +173,15 @@ define(["jquery", "jquery/ui"], function ($) { moreButton: 'swatch-more', loader: 'swatch-option-loading' }, - jsonConfig: {}, // option's json config - jsonSwatchConfig: {}, // swatch's json config - selectorProduct: '.product-info-main', // selector of parental block of prices and swatches (need to know where to seek for price block) - selectorProductPrice: '.price', // selector of price wrapper (need to know where set price) - numberToShow: false, // number of controls to show (false or zero = show all) - onlySwatches: false, // show only swatch controls - enableControlLabel: true, // enable label for control - moreButtonText: 'More', // text for more button - mediaCallback: '' // Callback url for media + jsonConfig: {}, // option's json config + jsonSwatchConfig: {}, // swatch's json config + selectorProduct: '.product-info-main', // selector of parental block of prices and swatches (need to know where to seek for price block) + selectorProductPrice: '.price-final-price .price', // selector of price wrapper (need to know where set price) + numberToShow: false, // number of controls to show (false or zero = show all) + onlySwatches: false, // show only swatch controls + enableControlLabel: true, // enable label for control + moreButtonText: 'More', // text for more button + mediaCallback: '' // Callback url for media }, /** From 5623cada498ab409a9ab0de9ef09665e3cabee4b Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 22 Sep 2015 15:21:14 +0300 Subject: [PATCH 03/52] MAGETWO-36656: Sorting files inside of the grid - MAGETWO-42921: Implementation --- .../product/edit/downloadable/links.phtml | 33 +++++++++++--- .../product/edit/downloadable/samples.phtml | 43 +++++++++++++------ 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml index 697c74ccb9d1d..48ff83f1e3816 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml @@ -42,6 +42,7 @@ + getCanReadPrice() !== false) : ?> @@ -50,7 +51,6 @@ - @@ -80,6 +80,11 @@ require([ ], function(jQuery, registry, mageTemplate){ registry.get('downloadable', function (Downloadable) { var linkTemplate = ''+ + ''+ ''+ - ''+ ''+ @@ -181,6 +185,7 @@ require([ data.link_type = 'file'; data.sample_type = 'none'; data.number_of_downloads = 'getConfigMaxDownloads() ?>'; + data.sort_order = this.itemCount + 1; } data.id = this.itemCount; @@ -196,10 +201,9 @@ require([ data.sample_file_checked = ' checked="checked"'; } - Element.insert(this.tbody, { - 'bottom': this.template({ - data: data - }) + + var rowElement = Element.insert(this.tbody, { + 'bottom': this.template({data: data}) }); scopeTitle = $('downloadable_link_'+data.id+'_title'); @@ -296,6 +300,20 @@ require([ this.togglePriceFields(); this.bindRemoveButtons(); }, + sorting: function () { + var list = jQuery(this.tbody); + list.sortable({ + axis: 'y', + handle: '[data-role=draggable-handle]', + items: 'tr', + update: function (event, data) { + list.find('[data-container=link-order]').each(function (i, el) { + jQuery(el).val(i + 1); + }); + }, + tolerance: 'pointer' + }); + }, remove : function(event){ var element = $(Event.findElement(event, 'tr')); alertAlreadyDisplayed = false; @@ -332,8 +350,9 @@ require([ elm.disabled = flag; }); } - } + }; + linkItems.sorting(); linkItems.bindRemoveButtons(); linksUploader = function (id, url) { diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml index dc7a5bfebe25b..86d68e07dbe59 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml @@ -17,9 +17,9 @@ $block->getConfigJson(); ?>
isSingleStoreMode() ? ' data-config-scope="' . __('[STORE VIEW]') . '"' : ''; ?>> - +
- getStoreId() && $block->getUsedDefault()) ? 'disabled="disabled"' : '' ?>> + getStoreId() && $block->getUsedDefault()) ? 'disabled="disabled"' : '' ?>> getStoreId()): ?>
getUsedDefault() ? 'checked="checked"' : '' ?> /> @@ -34,9 +34,9 @@ $block->getConfigJson();
 
#'+ ''+ ''+ @@ -161,7 +166,6 @@ require([ ''+ ''+ ''+ ''+ '
- - - + + + @@ -50,7 +50,7 @@ $block->getConfigJson();
 
- +
@@ -65,6 +65,8 @@ require([ ], function (jQuery, registry, mageTemplate) { registry.get('downloadable', function (Downloadable) { var sampleTemplate = ''+ + '#'+ ''+ ''+ ''+ @@ -80,8 +82,8 @@ require([ '
'+ '
'+ '
'+ - '' + - '' + + '' + + '' + ' - - -
- - -
", - "buttons":[]}}' - class="no-display"> - getVariationWizard([ - 'attributes' => $attributes, - 'configurations' => $productMatrix - ]); - ?> + +
+
", + "buttons":[]}}' + class="no-display"> + getVariationWizard([ + 'attributes' => $attributes, + 'configurations' => $productMatrix + ]); + ?> +
+
getMessageHtml() ?>
- +
+ +
-getChildHtml('accordion') ?> + getChildHtml() ?>
isReadonly()): ?> - + }); + From ae5656d5c986a78f3fc6a5a98bb5f21bb61f290e Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Thu, 24 Sep 2015 14:02:00 +0300 Subject: [PATCH 11/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42347: Move Downloadable Tab to section - fix configurable tab --- .../Product/Edit/Tab/Super/Config.php | 4 +- .../catalog/product/edit/super/config.phtml | 84 ++++++++----------- 2 files changed, 39 insertions(+), 49 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config.php index 456972bd31ddc..b44246b26799e 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config.php @@ -207,7 +207,7 @@ public function getConfigurableSettings($product) */ public function getTabLabel() { - return __('Associated Products'); + return __('Configurations'); } /** @@ -217,7 +217,7 @@ public function getTabLabel() */ public function getTabTitle() { - return __('Associated Products'); + return __('Configurations'); } /** diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml index 634f06de8c4aa..958fa3d1efe3d 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml @@ -9,59 +9,49 @@ /** @var $block \Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config */ ?>
-
-
- - - -
- -
-
-
-
- -
-
-
- -
-
- - - -
+
+
+
+
-
- getChildHtml('generator'); ?> - - -
-
-
-
- -
-
- +
+
+ +
+
+ + + +
+
+
+ getChildHtml('generator'); ?> + +
+
+
+
+
+ - -
+
-
+ + +
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php index f248edcea3127..dc2bc02f594af 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php @@ -9,7 +9,19 @@ */ namespace Magento\Catalog\Block\Adminhtml\Product\Edit; -class Tabs extends \Magento\Backend\Block\Widget\Tabs +use Magento\Backend\Block\Template\Context; +use Magento\Backend\Block\Widget\Accordion; +use Magento\Backend\Block\Widget\Tabs as WigetTabs; +use Magento\Backend\Model\Auth\Session; +use Magento\Catalog\Helper\Catalog; +use Magento\Catalog\Helper\Data; +use Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory; +use Magento\Framework\Json\EncoderInterface; +use Magento\Framework\Module\Manager; +use Magento\Framework\Registry; +use Magento\Framework\Translate\InlineInterface; + +class Tabs extends WigetTabs { const BASIC_TAB_GROUP_CODE = 'basic'; @@ -28,62 +40,64 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs /** * Core registry * - * @var \Magento\Framework\Registry + * @var Registry */ protected $_coreRegistry = null; /** * Catalog data * - * @var \Magento\Catalog\Helper\Data + * @var Data */ protected $_catalogData = null; /** * Adminhtml catalog * - * @var \Magento\Catalog\Helper\Catalog + * @var Catalog */ protected $_helperCatalog = null; /** - * @var \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory + * @var CollectionFactory */ protected $_collectionFactory; /** - * @var \Magento\Framework\Module\Manager + * @var Manager */ protected $_moduleManager; /** - * @var \Magento\Framework\Translate\InlineInterface + * @var InlineInterface */ protected $_translateInline; + private $accordionBlockId = 'tabs-accordion-info'; + /** - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder - * @param \Magento\Backend\Model\Auth\Session $authSession - * @param \Magento\Framework\Module\Manager $moduleManager - * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $collectionFactory - * @param \Magento\Catalog\Helper\Catalog $helperCatalog - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Translate\InlineInterface $translateInline + * @param Context $context + * @param EncoderInterface $jsonEncoder + * @param Session $authSession + * @param Manager $moduleManager + * @param CollectionFactory $collectionFactory + * @param Catalog $helperCatalog + * @param Data $catalogData + * @param Registry $registry + * @param InlineInterface $translateInline * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Framework\Json\EncoderInterface $jsonEncoder, - \Magento\Backend\Model\Auth\Session $authSession, - \Magento\Framework\Module\Manager $moduleManager, - \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $collectionFactory, - \Magento\Catalog\Helper\Catalog $helperCatalog, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Framework\Registry $registry, - \Magento\Framework\Translate\InlineInterface $translateInline, + Context $context, + EncoderInterface $jsonEncoder, + Session $authSession, + Manager $moduleManager, + CollectionFactory $collectionFactory, + Catalog $helperCatalog, + Data $catalogData, + Registry $registry, + InlineInterface $translateInline, array $data = [] ) { $this->_moduleManager = $moduleManager; @@ -323,20 +337,22 @@ protected function _translateHtml($html) return $html; } - public function decorateTab($tab) + public function getAccordion($parentTab) { $accordion = $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Accordion') - ->setId($tab->getId()); - - $accordion->addItem( - $tab->getUiId(), - [ - 'title' => $tab->getTabTitle(), - 'content' => $this->getTabContent($tab), - 'open' => false - ] - ); - + ->setId($this->accordionBlockId . $parentTab->getId()); + foreach ($this->_tabs as $childTab) { + if ($childTab->getParentTab() === $parentTab->getId()) { + $accordion->addItem( + $childTab->getUiId(), + [ + 'title' => $childTab->getTabTitle(), + 'content' => $this->getTabContent($childTab), + 'open' => false + ] + ); + } + } return $accordion->toHtml(); } } diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs.phtml index 634ad1373b743..b51fc1b7cbb0a 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs.phtml @@ -9,111 +9,101 @@ /** @var $block \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs */ ?> - + -
- - getId() . '-' . $tabGroupCode; - $isBasic = $tabGroupCode == \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs::BASIC_TAB_GROUP_CODE; - $activeCollapsible = $block->isAdvancedTabGroupActive() ? true : false; - ?> +
+ + getId() . '-' . $tabGroupCode; + $isBasic = $tabGroupCode == \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs::BASIC_TAB_GROUP_CODE; + $activeCollapsible = $block->isAdvancedTabGroupActive() ? true : false; + ?> -
- data-mage-init='{"collapsible":{ - "active": "", - "openedState": "_show", - "closedState": "_hide", - "animate": 200, - "collapsible": true - }}' - > +
+ data-mage-init='{"collapsible":{ + "active": "", + "openedState": "_show", + "closedState": "_hide", + "animate": 200, + "collapsible": true + }}' + > -
getUiId('title') ?> data-role="title"> -
- - - - +
getUiId('title') ?> data-role="title"> +
+ + + + +
-
- -
- -
- + + +
getUiId('tab', 'content', $_tab->getId()) ?> + > + getTabContent($_tab); ?> + getAccordion($_tab); ?> +
+ + + +
+ +
diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php index a2ffd3d027eea..195993f1738a0 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php @@ -5,12 +5,18 @@ */ namespace Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab; +use Magento\Backend\Block\Template\Context; +use Magento\Backend\Block\Widget; +use Magento\Backend\Block\Widget\Tab\TabInterface; +use Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs; +use Magento\Framework\Registry; + /** * Adminhtml catalog product downloadable items tab and form * * @author Magento Core Team */ -class Downloadable extends \Magento\Backend\Block\Widget implements \Magento\Backend\Block\Widget\Tab\TabInterface +class Downloadable extends Widget implements TabInterface { /** * Reference to product objects that is being edited @@ -34,23 +40,23 @@ class Downloadable extends \Magento\Backend\Block\Widget implements \Magento\Bac * * @var string */ - protected $accordionBlockId = 'downloadableInfo'; + protected $blockId = 'downloadableInfo'; /** * Core registry * - * @var \Magento\Framework\Registry + * @var Registry */ protected $_coreRegistry = null; /** - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Framework\Registry $registry + * @param Context $context + * @param Registry $registry * @param array $data */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Framework\Registry $registry, + Context $context, + Registry $registry, array $data = [] ) { $this->_coreRegistry = $registry; @@ -132,7 +138,7 @@ public function isHidden() */ public function getGroupCode() { - return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs::ADVANCED_TAB_GROUP_CODE; + return Tabs::ADVANCED_TAB_GROUP_CODE; } /** @@ -142,6 +148,6 @@ public function getGroupCode() */ public function getContentTabId() { - return 'tab_content_' . $this->accordionBlockId; + return 'tab_content_' . $this->blockId; } } diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_simple.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_simple.xml index 136c8c3a07307..ec6afcb9d83ce 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_simple.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_simple.xml @@ -10,7 +10,7 @@ downloadable_items - Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable + downloadable_items diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_virtual.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_virtual.xml index 136c8c3a07307..ec6afcb9d83ce 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_virtual.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_virtual.xml @@ -10,7 +10,7 @@ downloadable_items - Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable + downloadable_items diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml index fd96155ced6ba..e275db3303bc1 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml @@ -141,7 +141,7 @@ var uploaderTemplate = '
' + new Downloadable.FileList(this.idName, null); } - } + }; Downloadable.FileList = Class.create(); Downloadable.FileList.prototype = { @@ -193,7 +193,7 @@ var uploaderTemplate = '
' + $(this.containerId + '-old').show(); }.bind(this)); } - } + }; var alertAlreadyDisplayed = false; @@ -207,6 +207,9 @@ var uploaderTemplate = '
' + }); +
getUiId('tab', 'content', $block->getId()) ?> +>
getMessageHtml() ?>
@@ -231,3 +234,4 @@ var uploaderTemplate = '
' + }); +
From 65bd44c5f34f874b28323fe5e29f8cbd6140e50c Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Thu, 24 Sep 2015 20:56:04 +0300 Subject: [PATCH 13/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42347: Move Downloadable Tab to section --- .../templates/product/edit/bundle.phtml | 51 ++++++++----------- .../layout/catalog_product_simple.xml | 4 ++ .../layout/catalog_product_virtual.xml | 4 ++ .../layout/catalog_product_grouped.xml | 10 ++-- .../templates/product/grouped/container.phtml | 1 + 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle.phtml b/app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle.phtml index 91aec2386ca0c..67b5e66322655 100644 --- a/app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle.phtml +++ b/app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle.phtml @@ -16,40 +16,29 @@ if(typeof Bundle=='undefined') { -
-
-
- - getTabLabel() ?> - +
+
+
+ +
+ +
-
-
-
- -
- -
-
-
- getOptionsBoxHtml() ?> -
- - getAddButtonHtml() ?> -
+
+ getOptionsBoxHtml() ?>
-
+ + getAddButtonHtml() ?> +
diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_simple.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_simple.xml index ec6afcb9d83ce..ceaad1a33390c 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_simple.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_simple.xml @@ -8,6 +8,10 @@ + + + + downloadable_items downloadable_items diff --git a/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_virtual.xml b/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_virtual.xml index ec6afcb9d83ce..ceaad1a33390c 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_virtual.xml +++ b/app/code/Magento/Downloadable/view/adminhtml/layout/catalog_product_virtual.xml @@ -8,6 +8,10 @@ + + + + downloadable_items downloadable_items diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml index df1ff2634e284..78ddbe16ddd30 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml @@ -12,15 +12,13 @@ - - - - - + + + grouped - catalog.product.edit.grouped.container + catalog.product.edit.tab.super.container diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml b/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml index 9bd1f8212c1f3..eb538c21eb220 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml @@ -5,6 +5,7 @@ */ // @codingStandardsIgnoreFile +// @deprecated ?> From 4fe20b8af2391c47d1a20f20213f593814e3b4b5 Mon Sep 17 00:00:00 2001 From: Michail Slabko Date: Fri, 25 Sep 2015 11:29:26 +0300 Subject: [PATCH 14/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42349: Change behavior for weight field --- .../view/adminhtml/web/js/bundle-product.js | 5 +- .../Catalog/Block/Adminhtml/Product/Edit.php | 3 +- .../Edit/Action/Attribute/Tab/Attributes.php | 4 +- .../Adminhtml/Product/Helper/Form/Weight.php | 66 +++++++++--------- app/code/Magento/Catalog/Helper/Product.php | 18 ----- .../Model/Product/Edit/WeightResolver.php | 34 +++++++++ .../Model/Product/TypeTransitionManager.php | 17 ++++- .../Product/Helper/Form/WeightTest.php | 69 +++++-------------- .../Product/TypeTransitionManagerTest.php | 41 +++++++---- app/code/Magento/Catalog/etc/di.xml | 1 - .../adminhtml/web/catalog/type-switcher.js | 20 +++--- .../web/js/product/weight-handler.js | 19 +++++ .../Plugin/Downloadable.php | 12 +++- .../Plugin/DownloadableTest.php | 30 +++++--- app/code/Magento/Downloadable/etc/di.xml | 5 -- .../Block/Adminhtml/Product/ProductForm.xml | 5 +- .../Test/Fixture/CatalogProductSimple.xml | 2 +- .../Test/Fixture/CatalogProductVirtual.xml | 2 +- .../Handler/CatalogProductSimple/Curl.php | 4 +- .../Test/Repository/CatalogProductSimple.xml | 8 +-- .../Test/Repository/CatalogProductVirtual.xml | 14 ++-- .../CreateVirtualProductEntityTest.xml | 16 ++--- .../UpdateVirtualProductEntityTest.xml | 22 +++--- .../Test/Fixture/ConfigurableProduct.xml | 2 +- .../Test/Repository/ConfigurableProduct.xml | 2 +- .../Test/Fixture/DownloadableProduct.xml | 2 +- .../Test/Repository/DownloadableProduct.xml | 14 ++-- .../CreateDownloadableProductEntityTest.xml | 28 ++++---- .../UpdateDownloadableProductEntityTest.xml | 12 ++-- .../Test/Legacy/_files/obsolete_methods.php | 1 + .../Framework/Data/Form/Element/Radios.php | 26 ++++++- 31 files changed, 285 insertions(+), 219 deletions(-) create mode 100644 app/code/Magento/Catalog/Model/Product/Edit/WeightResolver.php create mode 100644 app/code/Magento/Catalog/view/adminhtml/web/js/product/weight-handler.js diff --git a/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-product.js b/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-product.js index 5b6515db33fa5..4d4c1526c8aa4 100644 --- a/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-product.js +++ b/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-product.js @@ -8,11 +8,12 @@ /*global $H*/ define([ "jquery", + "Magento_Catalog/js/product/weight-handler", "jquery/ui", "mage/translate", "Magento_Theme/js/sortable", "prototype" -], function($){ +], function ($, weightHandler) { 'use strict'; $.widget('mage.bundleProduct', { @@ -188,7 +189,7 @@ define([ return this; }, _hideProductTypeSwitcher: function () { - $('#weight_and_type_switcher, label[for=weight_and_type_switcher]').hide(); + weightHandler.hideWeightSwitcher(); }, _bindCheckboxHandlers: function () { this._on({ diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php index 6dd100f0eca6d..8cd6cc4fffa45 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php @@ -310,7 +310,8 @@ public function getTypeSwitcherData() return $this->jsonEncoder->encode( [ 'tab_id' => 'product_info_tabs_downloadable_items', - 'is_virtual_id' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight::VIRTUAL_FIELD_HTML_ID, + 'weight_switcher' => '[data-role=weight-switcher]', + 'product_has_weight_flag' => \Magento\Catalog\Model\Product\Edit\WeightResolver::HAS_WEIGHT, 'weight_id' => 'weight', 'current_type' => $this->getProduct()->getTypeId(), 'attributes' => $this->_getAttributes(), diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php index 3f5f4d9f3a94c..8e65e16c01148 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php @@ -145,8 +145,8 @@ protected function _getAdditionalElementHtml($element) HTML; if ($elementId === 'weight') { $html .= <<require(["jquery"],function($) { - $('#weight_and_type_switcher, label[for=weight_and_type_switcher]').hide(); + HTML; } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Weight.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Weight.php index 1b787f05ffd5a..f61e738affbd6 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Weight.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Weight.php @@ -6,30 +6,20 @@ /** * Product form weight field helper - * - * @author Magento Core Team */ namespace Magento\Catalog\Block\Adminhtml\Product\Helper\Form; use Magento\Framework\Data\Form; +use Magento\Catalog\Model\Product\Edit\WeightResolver; class Weight extends \Magento\Framework\Data\Form\Element\Text { - const VIRTUAL_FIELD_HTML_ID = 'weight_and_type_switcher'; - /** - * Is virtual checkbox element + * Weight switcher radio-button element * * @var \Magento\Framework\Data\Form\Element\Checkbox */ - protected $_virtual; - - /** - * Catalog helper - * - * @var \Magento\Catalog\Helper\Product - */ - protected $_helper; + protected $weightSwitcher; /** * @var \Magento\Framework\Locale\Format @@ -52,44 +42,52 @@ public function __construct( \Magento\Framework\Locale\Format $localeFormat, array $data = [] ) { - $this->_helper = $helper; $this->localeFormat = $localeFormat; - $this->_virtual = $factoryElement->create('checkbox'); - $this->_virtual->setId( - self::VIRTUAL_FIELD_HTML_ID + $this->weightSwitcher = $factoryElement->create('radios'); + $this->weightSwitcher->setValue( + WeightResolver::HAS_WEIGHT + )->setValues( + [ + ['value' => WeightResolver::HAS_WEIGHT, 'label' => __('Yes')], + ['value' => WeightResolver::HAS_NO_WEIGHT, 'label' => __('No')] + ] + )->setId( + 'weight-switcher' )->setName( - 'is_virtual' + 'product_has_weight' )->setLabel( - $this->_helper->getTypeSwitcherControlLabel() + __('Does this have a weight?') ); parent::__construct($factoryElement, $factoryCollection, $escaper, $data); $this->addClass('validate-zero-or-greater'); } /** - * Add Is Virtual checkbox html to weight field + * Add Weight Switcher radio-button element html to weight field * * @return string */ public function getElementHtml() { if (!$this->getForm()->getDataObject()->getTypeInstance()->hasWeight()) { - $this->_virtual->setChecked('checked'); + $this->weightSwitcher->setValue(WeightResolver::HAS_NO_WEIGHT); } if ($this->getDisabled()) { - $this->_virtual->setDisabled($this->getDisabled()); + $this->weightSwitcher->setDisabled($this->getDisabled()); } - return '
' . - parent::getElementHtml() . - '' . - '
' . - $this->_virtual->getElementHtml() . - $this->_virtual->getLabelHtml() . - '
'; + return '
' . + '
' . + $this->weightSwitcher->getLabelHtml() . + $this->weightSwitcher->getElementHtml() . + '
' . + '
' . + parent::getElementHtml() . + '' . + '
'; } /** @@ -100,7 +98,7 @@ public function getElementHtml() */ public function setForm($form) { - $this->_virtual->setForm($form); + $this->weightSwitcher->setForm($form); return parent::setForm($form); } diff --git a/app/code/Magento/Catalog/Helper/Product.php b/app/code/Magento/Catalog/Helper/Product.php index cc0305c3545cc..1083bc63a5158 100644 --- a/app/code/Magento/Catalog/Helper/Product.php +++ b/app/code/Magento/Catalog/Helper/Product.php @@ -52,11 +52,6 @@ class Product extends \Magento\Framework\Url\Helper\Data */ protected $_coreRegistry; - /** - * @var string - */ - protected $_typeSwitcherLabel; - /** * @var \Magento\Catalog\Model\Attribute\Config */ @@ -103,7 +98,6 @@ class Product extends \Magento\Framework\Url\Helper\Data * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Catalog\Model\Attribute\Config $attributeConfig - * @param string $typeSwitcherLabel * @param array $reindexPriceIndexerData * @param array $reindexProductCategoryIndexerData * @param ProductRepositoryInterface $productRepository @@ -117,14 +111,12 @@ public function __construct( \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\Registry $coreRegistry, \Magento\Catalog\Model\Attribute\Config $attributeConfig, - $typeSwitcherLabel, $reindexPriceIndexerData, $reindexProductCategoryIndexerData, ProductRepositoryInterface $productRepository, CategoryRepositoryInterface $categoryRepository ) { $this->_catalogSession = $catalogSession; - $this->_typeSwitcherLabel = $typeSwitcherLabel; $this->_attributeConfig = $attributeConfig; $this->_coreRegistry = $coreRegistry; $this->_assetRepo = $assetRepo; @@ -582,14 +574,4 @@ public function getAttributesAllowedForAutogeneration() { return $this->_attributeConfig->getAttributeNames('used_in_autogeneration'); } - - /** - * Get label for virtual control - * - * @return \Magento\Framework\Phrase - */ - public function getTypeSwitcherControlLabel() - { - return __($this->_typeSwitcherLabel); - } } diff --git a/app/code/Magento/Catalog/Model/Product/Edit/WeightResolver.php b/app/code/Magento/Catalog/Model/Product/Edit/WeightResolver.php new file mode 100644 index 0000000000000..5ae02476396aa --- /dev/null +++ b/app/code/Magento/Catalog/Model/Product/Edit/WeightResolver.php @@ -0,0 +1,34 @@ +hasData('product_has_weight')) { + throw new \LogicException( + __('Product don\'t have "%1" key. It must be fulfilled during product edit', 'product_has_weight') + ); + } + return (bool) ($product->getData('product_has_weight') == self::HAS_WEIGHT); + } +} diff --git a/app/code/Magento/Catalog/Model/Product/TypeTransitionManager.php b/app/code/Magento/Catalog/Model/Product/TypeTransitionManager.php index 99dd6a233fa65..28ef579e61072 100644 --- a/app/code/Magento/Catalog/Model/Product/TypeTransitionManager.php +++ b/app/code/Magento/Catalog/Model/Product/TypeTransitionManager.php @@ -11,6 +11,7 @@ namespace Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Type; class TypeTransitionManager { @@ -21,12 +22,20 @@ class TypeTransitionManager */ protected $compatibleTypes; + /** + * @var Edit\WeightResolver + */ + protected $weightResolver; + /** * @param array $compatibleTypes */ - public function __construct(array $compatibleTypes) - { + public function __construct( + \Magento\Catalog\Model\Product\Edit\WeightResolver $weightResolver, + array $compatibleTypes + ) { $this->compatibleTypes = $compatibleTypes; + $this->weightResolver = $weightResolver; } /** @@ -39,7 +48,9 @@ public function processProduct(Product $product) { if (in_array($product->getTypeId(), $this->compatibleTypes)) { $product->setTypeInstance(null); - $productTypeId = $product->hasIsVirtual() ? \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL : \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE; + $productTypeId = $this->weightResolver->resolveProductHasWeight($product) + ? Type::TYPE_SIMPLE + : Type::TYPE_VIRTUAL; $product->setTypeId($productTypeId); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php index 173d209c2278d..414ae187de5da 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php @@ -7,8 +7,6 @@ class WeightTest extends \PHPUnit_Framework_TestCase { - const VIRTUAL_FIELD_HTML_ID = 'weight_and_type_switcher'; - /** * @var \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight */ @@ -17,7 +15,7 @@ class WeightTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Framework\Data\Form\Element\Checkbox */ - protected $_virtual; + protected $weightSwitcher; public function testSetForm() { @@ -36,34 +34,18 @@ public function testSetForm() $form = new \Magento\Framework\Data\Form($factory, $collectionFactory, $formKey); - $helper = $this->getMock( - 'Magento\Catalog\Helper\Product', - ['getTypeSwitcherControlLabel'], - [], - '', - false, - false - ); - $helper->expects( - $this->any() - )->method( - 'getTypeSwitcherControlLabel' - )->will( - $this->returnValue('Virtual / Downloadable') - ); - - $this->_virtual = $this->getMock( - 'Magento\Framework\Data\Form\Element\Checkbox', + $this->weightSwitcher = $this->getMock( + 'Magento\Framework\Data\Form\Element\Radios', ['setId', 'setName', 'setLabel', 'setForm'], [], '', false, false ); - $this->_virtual->expects($this->any())->method('setId')->will($this->returnSelf()); - $this->_virtual->expects($this->any())->method('setName')->will($this->returnSelf()); - $this->_virtual->expects($this->any())->method('setLabel')->will($this->returnSelf()); - $this->_virtual->expects( + $this->weightSwitcher->expects($this->any())->method('setId')->will($this->returnSelf()); + $this->weightSwitcher->expects($this->any())->method('setName')->will($this->returnSelf()); + $this->weightSwitcher->expects($this->any())->method('setLabel')->will($this->returnSelf()); + $this->weightSwitcher->expects( $this->any() )->method( 'setForm' @@ -79,14 +61,14 @@ public function testSetForm() )->method( 'create' )->with( - $this->equalTo('checkbox') + $this->equalTo('radios') )->will( - $this->returnValue($this->_virtual) + $this->returnValue($this->weightSwitcher) ); $this->_model = $objectManager->getObject( 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Weight', - ['factoryElement' => $factory, 'factoryCollection' => $collectionFactory, 'helper' => $helper] + ['factoryElement' => $factory, 'factoryCollection' => $collectionFactory,] ); $this->_model->setForm($form); @@ -120,33 +102,17 @@ public function testGetEscapedValue() 'groupSymbol' => '.', ]); - $helper = $this->getMock( - 'Magento\Catalog\Helper\Product', - ['getTypeSwitcherControlLabel'], - [], - '', - false, - false - ); - $helper->expects( - $this->any() - )->method( - 'getTypeSwitcherControlLabel' - )->will( - $this->returnValue('Virtual / Downloadable') - ); - - $this->_virtual = $this->getMock( - 'Magento\Framework\Data\Form\Element\Checkbox', + $this->weightSwitcher = $this->getMock( + 'Magento\Framework\Data\Form\Element\Radios', ['setId', 'setName', 'setLabel'], [], '', false, false ); - $this->_virtual->expects($this->any())->method('setId')->will($this->returnSelf()); - $this->_virtual->expects($this->any())->method('setName')->will($this->returnSelf()); - $this->_virtual->expects($this->any())->method('setLabel')->will($this->returnSelf()); + $this->weightSwitcher->expects($this->any())->method('setId')->will($this->returnSelf()); + $this->weightSwitcher->expects($this->any())->method('setName')->will($this->returnSelf()); + $this->weightSwitcher->expects($this->any())->method('setLabel')->will($this->returnSelf()); $factory = $this->getMock('Magento\Framework\Data\Form\Element\Factory', [], [], '', false); $factory->expects( @@ -154,9 +120,9 @@ public function testGetEscapedValue() )->method( 'create' )->with( - $this->equalTo('checkbox') + $this->equalTo('radios') )->will( - $this->returnValue($this->_virtual) + $this->returnValue($this->weightSwitcher) ); $this->_model = $objectManager->getObject( @@ -164,7 +130,6 @@ public function testGetEscapedValue() [ 'factoryElement' => $factory, 'factoryCollection' => $collectionFactory, - 'helper' => $helper, 'localeFormat' => $localeFormat ] ); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php index f33b89d1c3b67..9571e02c7284c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/TypeTransitionManagerTest.php @@ -19,32 +19,45 @@ class TypeTransitionManagerTest extends \PHPUnit_Framework_TestCase */ protected $productMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $weightResolver; + protected function setUp() { - $this->model = new TypeTransitionManager( - [ - 'simple' => \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, - 'virtual' => \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, - ] - ); $this->productMock = $this->getMock( 'Magento\Catalog\Model\Product', - ['hasIsVirtual', 'getTypeId', 'setTypeId', 'setTypeInstance', '__wakeup'], + ['getTypeId', 'setTypeId', 'setTypeInstance', '__wakeup'], + [], + '', + false + ); + $this->weightResolver = $this->getMock( + 'Magento\Catalog\Model\Product\Edit\WeightResolver', + ['resolveProductHasWeight'], [], '', false ); + $this->model = new TypeTransitionManager( + $this->weightResolver, + [ + 'simple' => \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, + 'virtual' => \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, + ] + ); } /** - * @param bool $isVirtual + * @param bool $hasWeight * @param string $currentTypeId * @param string $expectedTypeId * @dataProvider processProductDataProvider */ - public function testProcessProduct($isVirtual, $currentTypeId, $expectedTypeId) + public function testProcessProduct($hasWeight, $currentTypeId, $expectedTypeId) { - $this->productMock->expects($this->any())->method('hasIsVirtual')->will($this->returnValue($isVirtual)); + $this->weightResolver->expects($this->any())->method('resolveProductHasWeight')->willReturn($hasWeight); $this->productMock->expects($this->once())->method('getTypeId')->will($this->returnValue($currentTypeId)); $this->productMock->expects($this->once())->method('setTypeInstance')->with(null); $this->productMock->expects($this->once())->method('setTypeId')->with($expectedTypeId); @@ -58,22 +71,22 @@ public function processProductDataProvider() { return [ [ - false, + true, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, ], [ - false, + true, \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE ], [ - true, + false, \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL ], [ - true, + false, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL ] diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index caa0844fbb8f2..1897cef81da68 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -64,7 +64,6 @@ - Virtual Magento\Catalog\Model\Session\Proxy diff --git a/app/code/Magento/Catalog/view/adminhtml/web/catalog/type-switcher.js b/app/code/Magento/Catalog/view/adminhtml/web/catalog/type-switcher.js index fb525cc6a5019..7a78b6b41fcea 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/catalog/type-switcher.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/catalog/type-switcher.js @@ -13,14 +13,18 @@ define([ * @constructor */ var TypeSwitcher = function (data) { - this._data = data; this.$type = $('#product_type_id'); this.$weight = $('#' + data.weight_id); - this.$is_virtual = $('#' + data.is_virtual_id); + this.$weight_switcher = $(data.weight_switcher); this.$tab = $('#' + data.tab_id); + this.productHasWeight = function () { + return $('input:checked', this.$weight_switcher).val() == data.product_has_weight_flag; + }; + this.notifyProductWeightIsChanged = function () { + return $('input:checked', this.$weight_switcher).trigger('change'); + }; - // @todo: move $is_virtual checkbox logic to separate widget - if (this.$is_virtual.is(':checked')) { + if (!this.productHasWeight()) { this.baseType = { virtual: this.$type.val(), real: 'simple' @@ -47,16 +51,16 @@ define([ $('[data-form=edit-product] [data-role=tabs]').on('contentUpdated', function() { self._switchToType($type.val()); - self.$is_virtual.trigger('change'); + self.notifyProductWeightIsChanged(); }); $("#product_info_tabs").on("beforePanelsMove tabscreate tabsactivate", function() { self._switchToType($type.val()); - self.$is_virtual.trigger('change'); + self.notifyProductWeightIsChanged(); }); - this.$is_virtual.on('change click', function() { - if ($(this).is(':checked')) { + $('input', this.$weight_switcher).on('change click', function() { + if (!self.productHasWeight()) { $type.val(self.baseType.virtual).trigger('change'); if ($type.val() != 'bundle') { // @TODO move this check to Magento_Bundle after refactoring as widget self.disableElement(self.$weight); diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/product/weight-handler.js b/app/code/Magento/Catalog/view/adminhtml/web/js/product/weight-handler.js new file mode 100644 index 0000000000000..2f38a6aab1ff1 --- /dev/null +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/product/weight-handler.js @@ -0,0 +1,19 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery' +], function ($) { + 'use strict'; + + return { + /** + * Hide weight switcher + */ + hideWeightSwitcher: function () { + $('[data-role=weight-switcher]').hide(); + } + }; +}); diff --git a/app/code/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/Downloadable.php b/app/code/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/Downloadable.php index 19cc68b641ac5..d622fa745dfee 100644 --- a/app/code/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/Downloadable.php +++ b/app/code/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/Downloadable.php @@ -7,6 +7,7 @@ use Closure; use Magento\Framework\App\RequestInterface; +use Magento\Catalog\Model\Product\Edit\WeightResolver; /** * Plugin for product type transition manager @@ -20,12 +21,19 @@ class Downloadable */ protected $request; + /** + * @var \Magento\Catalog\Model\Product\Edit\WeightResolver + */ + protected $weightResolver; + /** * @param RequestInterface $request + * @param WeightResolver $weightResolver */ - public function __construct(RequestInterface $request) + public function __construct(RequestInterface $request, WeightResolver $weightResolver) { $this->request = $request; + $this->weightResolver = $weightResolver; } /** @@ -62,7 +70,7 @@ public function aroundProcessProduct( } } } - if ($isTypeCompatible && $hasDownloadableData && $product->hasIsVirtual()) { + if ($isTypeCompatible && $hasDownloadableData && !$this->weightResolver->resolveProductHasWeight($product)) { $product->setTypeId(\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE); return; } diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php index 1ab99374fd6ad..fc7dcf4c525b7 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php @@ -35,10 +35,16 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); - $this->model = new \Magento\Downloadable\Model\Product\TypeTransitionManager\Plugin\Downloadable($this->requestMock); $this->productMock = $this->getMock( 'Magento\Catalog\Model\Product', - ['hasIsVirtual', 'getTypeId', 'setTypeId', '__wakeup'], + ['getTypeId', 'setTypeId', '__wakeup'], + [], + '', + false + ); + $this->weightResolver = $this->getMock( + 'Magento\Catalog\Model\Product\Edit\WeightResolver', + ['resolveProductHasWeight'], [], '', false @@ -46,6 +52,10 @@ protected function setUp() $this->subjectMock = $this->getMock('Magento\Catalog\Model\Product\TypeTransitionManager', [], [], '', false); $this->closureMock = function () { }; + $this->model = new \Magento\Downloadable\Model\Product\TypeTransitionManager\Plugin\Downloadable( + $this->requestMock, + $this->weightResolver + ); } /** @@ -58,7 +68,7 @@ public function testAroundProcessProductWithProductThatCanBeTransformedToDownloa ->method('getPost') ->with('downloadable') ->will($this->returnValue(['link' => [['is_delete' => '']]])); - $this->productMock->expects($this->any())->method('hasIsVirtual')->will($this->returnValue(true)); + $this->weightResolver->expects($this->any())->method('resolveProductHasWeight')->willReturn(false); $this->productMock->expects($this->once())->method('getTypeId')->will($this->returnValue($currentTypeId)); $this->productMock->expects($this->once()) ->method('setTypeId') @@ -80,13 +90,13 @@ public function compatibleTypeDataProvider() } /** - * @param bool $isVirtual + * @param bool $hasWeight * @param string $currentTypeId * @param string|null $downloadableData * @dataProvider productThatCannotBeTransformedToDownloadableDataProvider */ public function testAroundProcessProductWithProductThatCannotBeTransformedToDownloadable( - $isVirtual, + $hasWeight, $currentTypeId, $downloadableData ) { @@ -94,7 +104,7 @@ public function testAroundProcessProductWithProductThatCannotBeTransformedToDown ->method('getPost') ->with('downloadable') ->will($this->returnValue($downloadableData)); - $this->productMock->expects($this->any())->method('hasIsVirtual')->will($this->returnValue($isVirtual)); + $this->weightResolver->expects($this->any())->method('resolveProductHasWeight')->willReturn($hasWeight); $this->productMock->expects($this->once())->method('getTypeId')->will($this->returnValue($currentTypeId)); $this->productMock->expects($this->never())->method('setTypeId'); @@ -107,11 +117,11 @@ public function testAroundProcessProductWithProductThatCannotBeTransformedToDown public function productThatCannotBeTransformedToDownloadableDataProvider() { return [ - [true, 'custom_product_type', ['link' => [['is_delete' => '']]]], - [false, \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, null], + [false, 'custom_product_type', ['link' => [['is_delete' => '']]]], [true, \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, null], - [false, \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, ['link' => [['is_delete' => '']]]], - [true, \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE, ['link' => [['is_delete' => '1']]]] + [false, \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, null], + [true, \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, ['link' => [['is_delete' => '']]]], + [false, \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE, ['link' => [['is_delete' => '1']]]] ]; } } diff --git a/app/code/Magento/Downloadable/etc/di.xml b/app/code/Magento/Downloadable/etc/di.xml index acb63729a5781..3b4675368608a 100644 --- a/app/code/Magento/Downloadable/etc/di.xml +++ b/app/code/Magento/Downloadable/etc/di.xml @@ -11,11 +11,6 @@ Magento\MediaStorage\Helper\File\Storage\Database\Proxy - - - Virtual / Downloadable - - diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml index 7e94d4691cf15..d631a7b2efd05 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml @@ -27,9 +27,10 @@ select - + + [name="product[product_has_weight]"] checkbox - + #attribute-category_ids-container Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails\CategoryIds diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml index e295d379e33d2..0361bfb2b5caf 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml @@ -85,7 +85,7 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml index edcfc39f2c5b0..6845abe78e715 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml @@ -24,7 +24,7 @@ product - + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php index 56d819a6ed398..0d99fcd62d512 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php @@ -47,8 +47,8 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface 'Yes' => 1, 'No' => 0 ], - 'is_virtual' => [ - 'Yes' => 1 + 'product_has_weight' => [ + 'No' => 0 ], 'use_config_enable_qty_increments' => [ 'Yes' => 1, diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml index 831681a82f09b..883a48bc34d13 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml @@ -13,7 +13,7 @@ Simple Product %isolation% sku_simple_product_%isolation% - No + Yes 1 25 @@ -41,7 +41,7 @@ product_10_dollar %isolation% sku_product_10_dollar_%isolation% - No + Yes 1 1000 @@ -69,7 +69,7 @@ product_20_dollar %isolation% sku_product_20_dollar_%isolation% - No + Yes 1 1000 @@ -91,7 +91,7 @@ Simple Product %isolation% sku_simple_product_%isolation% - No + Yes 1 25 diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.xml index 818590b22319a..582501462c3c3 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.xml @@ -15,7 +15,7 @@ Main Website - Yes + No virtual-product%isolation% Catalog, Search @@ -39,7 +39,7 @@ virtual-product%isolation% Virtual product %isolation% sku_virtual_product_%isolation% - Yes + No 10 @@ -55,7 +55,7 @@ virtual-product%isolation% Virtual product %isolation% sku_virtual_product_%isolation% - Yes + No 10 @@ -78,7 +78,7 @@ Main Website - Yes + No virtual-product%isolation% Catalog, Search @@ -106,7 +106,7 @@ Main Website - Yes + No virtual-product%isolation% Catalog, Search @@ -136,7 +136,7 @@ Main Website - Yes + No virtual-product%isolation% Catalog, Search @@ -161,7 +161,7 @@ Main Website - Yes + No virtual-product%isolation% Virtual product %isolation% sku_virtual_product_%isolation% diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.xml index eebe1b345306a..0a5b9e30e08d5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.xml @@ -13,7 +13,7 @@ VirtualProduct %isolation% virtual_sku_%isolation% 10 - Yes + No @@ -25,7 +25,7 @@ 10 None 999 - Yes + No category_%isolation% MAGETWO-23002 Yes @@ -44,7 +44,7 @@ taxable_goods 999 In Stock - Yes + No MAGETWO-23030 Search @@ -57,7 +57,7 @@ VirtualProduct %isolation% virtual_sku_%isolation% 10 - Yes + No category_%isolation% not_logged_in_90 Catalog @@ -71,7 +71,7 @@ VirtualProduct %isolation% virtual_sku_%isolation% 9000 - Yes + No not_logged_in_90 options_suite catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option @@ -88,7 +88,7 @@ virtual_sku_%isolation% 10 999 - Yes + No MAGETWO-23030 No In Stock @@ -104,7 +104,7 @@ virtual_sku_%isolation% 9000 999 - Yes + No default Out of Stock @@ -118,7 +118,7 @@ VirtualProduct %isolation% virtual_sku_%isolation% 10 - Yes + No category_%isolation% test_type:acceptance_test diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml index f1b1517bda524..0539fdf7f6fa6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml @@ -13,7 +13,7 @@ 99.99 None 999 - Yes + No default_subcategory MAGETWO-23002 In Stock @@ -34,7 +34,7 @@ 120.00 taxable_goods 999 - Yes + No 45 In Stock Catalog, Search @@ -54,7 +54,7 @@ 185.00 None 999 - Yes + No default_subcategory MAGETWO-23002 Out of Stock @@ -74,7 +74,7 @@ virtual_sku_%isolation% 99.99 taxable_goods - Yes + No Out of Stock Search virtual-product-%isolation% @@ -90,7 +90,7 @@ virtual_sku_%isolation% 5.00 None - Yes + No Out of Stock Catalog virtual-product-%isolation% @@ -107,7 +107,7 @@ 145.00 taxable_goods 999 - Yes + No default_subcategory not_logged_in_90 MAGETWO-23002 @@ -128,7 +128,7 @@ virtual_sku_%isolation% 99.99 None - Yes + No default_subcategory 45 Out of Stock @@ -146,7 +146,7 @@ virtual_sku_%isolation% 5.00 taxable_goods - Yes + No not_logged_in_90 Out of Stock Search @@ -164,7 +164,7 @@ 120.00 None 999 - Yes + No default_subcategory In Stock options_suite @@ -183,7 +183,7 @@ virtual_sku_%isolation% 99.99 taxable_goods - Yes + No not_logged_in_90 Out of Stock Catalog, Search @@ -201,7 +201,7 @@ 99.99 None 999 - Yes + No default_subcategory not_logged_in_90 MAGETWO-23002 diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml index 96623e3492dae..7ee2aab1e7806 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml @@ -74,7 +74,7 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml index fbffeb8f07028..9951fff4a0df1 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml @@ -161,7 +161,7 @@ 120 - No + Yes 30 Product online Catalog, Search diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.xml index 3d250fc3f2f46..e2a27faaf79d3 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.xml @@ -86,7 +86,7 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProduct.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProduct.xml index 8d84025eee8b4..eee102fe568a8 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProduct.xml @@ -25,7 +25,7 @@ Product online Catalog, Search test-downloadable-product-%isolation% - Yes + No with_two_separately_links @@ -53,7 +53,7 @@ Product online Catalog, Search - Yes + No Main Website @@ -81,7 +81,7 @@ Product online Catalog, Search - Yes + No Main Website @@ -113,7 +113,7 @@ default_subcategory Catalog, Search - Yes + No Main Website @@ -147,7 +147,7 @@ default_subcategory Catalog, Search - Yes + No Main Website @@ -178,7 +178,7 @@ default_subcategory Catalog, Search - Yes + No Main Website @@ -197,7 +197,7 @@ Downloadable product %isolation% downloadable_product_%isolation% downloadable-product-%isolation% - Yes + No 1 diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.xml index 67da232884b05..ffb6f2c9d9aa6 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.xml @@ -29,7 +29,7 @@ taxable_goods 1 In Stock - Yes + No Default Category with_two_separately_links downloadableproduct-%isolation% @@ -48,7 +48,7 @@ taxable_goods 10 In Stock - Yes + No category %isolation% with_two_samples with_two_separately_links @@ -68,7 +68,7 @@ taxable_goods 10 In Stock - Yes + No category %isolation% with_two_separately_links default @@ -88,7 +88,7 @@ taxable_goods 10 In Stock - Yes + No with_three_samples with_three_links two_options @@ -111,7 +111,7 @@ taxable_goods 50 Out of Stock - Yes + No Default Category with_two_separately_links downloadableproduct-%isolation% @@ -126,7 +126,7 @@ DownloadableProduct_%isolation% 9999 taxable_goods - Yes + No Default Category Yes 123 @@ -147,7 +147,7 @@ None 5 In Stock - Yes + No Default Category This is description for downloadable product with_two_separately_links @@ -165,7 +165,7 @@ taxable_goods 10 In Stock - Yes + No category %isolation% This is short description for downloadable product with_two_samples @@ -189,7 +189,7 @@ taxable_goods 11 In Stock - Yes + No category %isolation% This is description for downloadable product This is short description for downloadable product @@ -213,7 +213,7 @@ taxable_goods 11 In Stock - Yes + No category %isolation% with_two_samples with_three_links @@ -232,7 +232,7 @@ DownloadableProduct_%isolation% 100 taxable_goods - Yes + No Default Category with_two_separately_links downloadableproduct-%isolation% @@ -249,7 +249,7 @@ taxable_goods 10 In Stock - Yes + No category %isolation% with_two_separately_links 5 @@ -268,7 +268,7 @@ taxable_goods 23 In Stock - Yes + No category %isolation% with_two_separately_links not_logged_in_20 @@ -287,7 +287,7 @@ taxable_goods 65 In Stock - Yes + No category %isolation% with_two_separately_links default diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml index e1a51bf8cc9d5..8a5230fce71e3 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml @@ -14,7 +14,7 @@ taxable_goods 10 In Stock - Yes + No with_three_samples with_three_links two_options @@ -36,7 +36,7 @@ taxable_goods 50 Out of Stock - Yes + No Default Category with_two_separately_links No @@ -52,7 +52,7 @@ 9999 taxable_goods 123 - Yes + No Default Category Yes No @@ -71,7 +71,7 @@ None 5 In Stock - Yes + No Default Category This is description for downloadable product with_two_separately_links @@ -89,7 +89,7 @@ taxable_goods 10 In Stock - Yes + No category %isolation% This is short description for downloadable product with_two_samples @@ -113,7 +113,7 @@ taxable_goods 10 In Stock - Yes + No 40 No downloadableproduct-%isolation% diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index 90f0fb5fa7649..0ba53d5570e57 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -2460,4 +2460,5 @@ 'Magento\ConfigurableProduct\Model\Product\VariationHandler::fillSimpleProductData' ], ['mergeBookmarkConfig', 'Magento\Ui\Model\Manager'], + ['getTypeSwitcherControlLabel', 'Magento\Catalog\Helper\Product'], ]; diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Radios.php b/lib/internal/Magento/Framework/Data/Form/Element/Radios.php index 2fde6e9fd916e..81ca435bd1ef3 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Radios.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Radios.php @@ -66,7 +66,7 @@ public function getElementHtml() */ protected function _optionToHtml($option, $selected) { - $html = 'serialize(['name', 'class', 'style']); + $html = 'getRadioButtonAttributes($option); if (is_array($option)) { $html .= 'value="' . $this->_escape( $option['value'] @@ -99,4 +99,28 @@ protected function _optionToHtml($option, $selected) $html .= $this->getSeparator() . "\n"; return $html; } + + /** + * @return array + */ + public function getHtmlAttributes() + { + return array_merge(parent::getHtmlAttributes(), ['name']); + } + + /** + * @param array $option + * @return string + */ + protected function getRadioButtonAttributes($option) + { + $html = ''; + foreach ($this->getHtmlAttributes() as $attribute) { + if ($value = $this->getDataUsingMethod($attribute, $option['value'])) { + $html .= ' ' . $attribute . '="' . $value . '" '; + } + } + return $html; + + } } From 28bf7a5605fc0108464a6186c21e09d07a2dd8b9 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Fri, 25 Sep 2015 13:21:01 +0300 Subject: [PATCH 15/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42347: Move Downloadable Tab to section - fix FAT bundle --- .../Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php | 2 +- app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php index 1f97b56488bcd..caddba648ebda 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php @@ -159,7 +159,7 @@ public function canShowTab() */ public function isHidden() { - return false; + return true; } /** diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php index dc2bc02f594af..f06413cb15dff 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php @@ -339,6 +339,7 @@ protected function _translateHtml($html) public function getAccordion($parentTab) { + /** @var Magento\Backend\Block\Widget\Accordion $accordion */ $accordion = $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Accordion') ->setId($this->accordionBlockId . $parentTab->getId()); foreach ($this->_tabs as $childTab) { @@ -348,7 +349,7 @@ public function getAccordion($parentTab) [ 'title' => $childTab->getTabTitle(), 'content' => $this->getTabContent($childTab), - 'open' => false + 'open' => $childTab->isHidden() ] ); } From 33046dbf523d56bf2a587ee4bf52baef63ce82d2 Mon Sep 17 00:00:00 2001 From: Michail Slabko Date: Fri, 25 Sep 2015 13:31:54 +0300 Subject: [PATCH 16/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42348: Adapt FAT --- .../Model/Product/Edit/WeightResolver.php | 5 --- .../Bundle/Test/Repository/BundleProduct.xml | 4 +++ .../Handler/CatalogProductSimple/Curl.php | 7 ++-- .../Test/Repository/CatalogProductSimple.xml | 35 +++++++++++++++++++ .../Test/Repository/ConfigurableProduct.xml | 13 ++++++- 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Edit/WeightResolver.php b/app/code/Magento/Catalog/Model/Product/Edit/WeightResolver.php index 5ae02476396aa..074ee3a7503e1 100644 --- a/app/code/Magento/Catalog/Model/Product/Edit/WeightResolver.php +++ b/app/code/Magento/Catalog/Model/Product/Edit/WeightResolver.php @@ -24,11 +24,6 @@ class WeightResolver */ public function resolveProductHasWeight(\Magento\Catalog\Model\Product $product) { - if (!$product->hasData('product_has_weight')) { - throw new \LogicException( - __('Product don\'t have "%1" key. It must be fulfilled during product edit', 'product_has_weight') - ); - } return (bool) ($product->getData('product_has_weight') == self::HAS_WEIGHT); } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.xml index 2e920885fa488..6a9b0ac7f9b85 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.xml @@ -109,6 +109,7 @@ 1 Fixed + Yes Product online Together @@ -145,6 +146,7 @@ 1 Fixed + Yes Main Website @@ -190,6 +192,7 @@ 1 Fixed + Yes Main Website @@ -220,6 +223,7 @@ 1 Fixed + Yes Product online Together diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php index 0d99fcd62d512..ae794eaca4fe6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php @@ -48,7 +48,8 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface 'No' => 0 ], 'product_has_weight' => [ - 'No' => 0 + 'Yes' => 1, + 'No' => 0, ], 'use_config_enable_qty_increments' => [ 'Yes' => 1, @@ -249,10 +250,6 @@ protected function prepareData(FixtureInterface $fixture, $prefix = null) $fields['affect_product_custom_options'] = 1; } - if (isset($fields['product']['weight'])) { - unset($fields['product']['is_virtual']); - } - return $fields; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml index 883a48bc34d13..2f2e913126d15 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml @@ -116,6 +116,7 @@ Simple Product %isolation% sku_simple_product_%isolation% + Yes 1 1000 @@ -143,6 +144,7 @@ Simple Product %isolation% sku_simple_product_%isolation% + Yes 1 25 @@ -171,6 +173,7 @@ 666.0000 In Stock + Yes 1 default @@ -195,6 +198,7 @@ 666 In Stock + Yes 1 default @@ -219,6 +223,7 @@ 666 In Stock + Yes 1 100 @@ -241,6 +246,7 @@ 666 In Stock + Yes 1 default @@ -263,6 +269,7 @@ Simple product without category %isolation% simple-product-%isolation% simple_product_without_category_%isolation% + Yes 1 default @@ -290,6 +297,7 @@ 100 + Yes 100 Main Website @@ -316,6 +324,7 @@ 111 In Stock + Yes 1 Product online @@ -340,6 +349,7 @@ 50 + Yes 50 Main Website @@ -403,6 +413,7 @@ 666 In Stock + Yes 1 <p>dfj_full</p> Product online @@ -426,6 +437,7 @@ 666 In Stock + Yes 0.1 <p>Simple with Weight 0.1</p> Product online @@ -449,6 +461,7 @@ 666 In Stock + Yes 150.1 <p>Simple with Weight 150.1</p> Product online @@ -472,6 +485,7 @@ 666 In Stock + Yes 1 <p>adc_Full</p> Product online @@ -493,6 +507,7 @@ 25 In Stock + Yes 1 100 @@ -512,6 +527,7 @@ 100 + Yes 1 simple-product-%isolation% 9 @@ -526,6 +542,7 @@ 100 + Yes 1 not_logged_in_20 @@ -542,6 +559,7 @@ 100 + Yes 1 general_90_99 @@ -564,6 +582,7 @@ 300 + Yes 1 default @@ -580,6 +599,7 @@ 300 + Yes 1 default @@ -602,6 +622,7 @@ 300 + Yes 1 Main Website @@ -624,6 +645,7 @@ 300 + Yes 1 drop_down_with_one_option_percent_price @@ -649,6 +671,7 @@ 300 + Yes 1 simple-product-%isolation% @@ -667,6 +690,7 @@ No 2 + Yes 1 default @@ -686,6 +710,7 @@ Simple Product out of stock %isolation% sku_simple_product_out_of_stock%isolation% + Yes 1 25 @@ -713,6 +738,7 @@ Simple Product offline %isolation% sku_simple_product_offline_%isolation% + Yes 1 25 @@ -741,6 +767,7 @@ Simple Product not visible %isolation% sku_simple_product_not_visible_%isolation% + Yes 1 25 @@ -768,6 +795,7 @@ Simple Product with cart limit %isolation% sku_simple_product_with_cart_limit_%isolation% + Yes 1 25 @@ -802,6 +830,7 @@ 300 + Yes 1 drop_down_with_one_option_percent_price @@ -821,6 +850,7 @@ Simple Product with qty increments %isolation% sku_simple_product_with_qty_increments_%isolation% + Yes 1 25 @@ -855,6 +885,7 @@ 300 + Yes 1 25 @@ -876,6 +907,7 @@ 666 In Stock + Yes 1 default @@ -912,6 +944,7 @@ 70 + Yes 1 drop_down_with_one_option_fixed_price @@ -944,6 +977,7 @@ 110 100 + Yes 1 simple-product-%isolation% @@ -958,6 +992,7 @@ Simple Product %isolation% sku_simple_product_%isolation% simple-product-%isolation% + Yes 1 1000 diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml index 9951fff4a0df1..2fd3b20f3769c 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml @@ -14,6 +14,7 @@ 120 30 + Yes Product online Catalog, Search @@ -45,6 +46,7 @@ 9 5 + Yes Product online Catalog, Search @@ -75,6 +77,7 @@ 120 30 + Yes Product online Catalog, Search @@ -105,6 +108,7 @@ 120 30 + Yes Product online Catalog, Search @@ -135,6 +139,7 @@ 120 30 + Yes Product online Catalog, Search @@ -161,8 +166,8 @@ 120 - Yes 30 + Yes Product online Catalog, Search @@ -193,6 +198,7 @@ 10 30 + Yes Product online Catalog, Search @@ -223,6 +229,7 @@ 120 30 + Yes Product online Catalog, Search @@ -254,6 +261,7 @@ taxable_goods 1 + Yes 1 In Stock @@ -286,6 +294,7 @@ taxable_goods 1 + Yes Main Website @@ -307,6 +316,7 @@ 10 1 + Yes Product online Catalog, Search @@ -339,6 +349,7 @@ taxable_goods 1 + Yes 1 In Stock From faac289b209fc36e4da44a2d93ce847cbf4ab10a Mon Sep 17 00:00:00 2001 From: Michail Slabko Date: Fri, 25 Sep 2015 14:06:41 +0300 Subject: [PATCH 17/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42349: Change behavior for weight field -- fix integration tests --- .../Product/Helper/Form/WeightTest.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/WeightTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/WeightTest.php index a1518b1efc28e..7cf5a33130909 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/WeightTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/WeightTest.php @@ -27,7 +27,7 @@ protected function setUp() * @param string $type * @dataProvider virtualTypesDataProvider */ - public function testIsVirtualChecked($type) + public function testProductWithoutWeight($type) { /** @var $currentProduct \Magento\Catalog\Model\Product */ $currentProduct = $this->_objectManager->create('Magento\Catalog\Model\Product'); @@ -38,10 +38,10 @@ public function testIsVirtualChecked($type) $form->setDataObject($currentProduct); $block->setForm($form); - $this->assertContains( - 'checked="checked"', + $this->assertRegExp( + '/value="0".*checked="checked"/', $block->getElementHtml(), - 'Is Virtual checkbox is not selected for virtual products' + '"Does this have a weight" is set to "Yes" for virtual products' ); } @@ -60,7 +60,7 @@ public static function virtualTypesDataProvider() * @param string $type * @dataProvider physicalTypesDataProvider */ - public function testIsVirtualUnchecked($type) + public function testProductHasWeight($type) { /** @var $currentProduct \Magento\Catalog\Model\Product */ $currentProduct = $this->_objectManager->create('Magento\Catalog\Model\Product'); @@ -71,11 +71,10 @@ public function testIsVirtualUnchecked($type) $form = $this->_formFactory->create(); $form->setDataObject($currentProduct); $block->setForm($form); - - $this->assertNotContains( - 'checked="checked"', + $this->assertNotRegExp( + '/value="0".*checked="checked"/', $block->getElementHtml(), - 'Is Virtual checkbox is selected for physical products' + '"Does this have a weight" is set to "No" for physical products' ); } From e6173da0455d0d40288e9a4c584b0fd00f11273a Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Fri, 25 Sep 2015 14:41:32 +0300 Subject: [PATCH 18/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42347: Move Downloadable Tab to section --- .../Block/Product/Grouped/AssociatedProducts.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts.php b/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts.php index 2f1dbf803cce8..7d4acbbb5207c 100644 --- a/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts.php +++ b/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts.php @@ -35,4 +35,14 @@ public function getParentTab() { return 'product-details'; } + + /** + * Tab is hidden + * + * @return boolean + */ + public function isHidden() + { + return true; + } } From bb532a88f3c7642c53f6d062ee89fb062fd5eb5b Mon Sep 17 00:00:00 2001 From: Olga Matviienko Date: Fri, 25 Sep 2015 17:59:47 +0300 Subject: [PATCH 19/52] MAGETWO-36371: [UI] Assistance with Downloadable Products --- .../Product/Edit/Tab/Downloadable/Links.php | 4 +- .../Product/Edit/Tab/Downloadable/Samples.php | 4 +- .../product/edit/downloadable/links.phtml | 158 ++++++++++-------- .../product/edit/downloadable/samples.phtml | 96 ++++++----- .../module/steps/_attribute-values.less | 21 +-- .../web/css/source/_module.less | 125 ++++++++++---- .../backend/web/css/source/_classes.less | 12 ++ .../backend/web/css/source/_extends.less | 20 +++ .../Magento/backend/web/css/styles-old.less | 8 - 9 files changed, 268 insertions(+), 180 deletions(-) diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php index 224233a90353d..4b3c95f89150c 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php @@ -191,9 +191,9 @@ public function getAddButtonHtml() 'Magento\Backend\Block\Widget\Button' )->setData( [ - 'label' => __('Add New Row'), + 'label' => __('Add New Link'), 'id' => 'add_link_item', - 'class' => 'add', + 'class' => 'action-add', 'data_attribute' => ['action' => 'add-link'], ] ); diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php index ce2e80e7d335a..f4b5875ffe29e 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php @@ -121,9 +121,9 @@ public function getAddButtonHtml() 'Magento\Backend\Block\Widget\Button' )->setData( [ - 'label' => __('Add New Row'), + 'label' => __('Add New Link'), 'id' => 'add_sample_item', - 'class' => 'add', + 'class' => 'action-add', 'data_attribute' => ['action' => 'add-sample'], ] ); diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml index 48ff83f1e3816..f9d503e9c7255 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/links.phtml @@ -47,10 +47,10 @@ getCanReadPrice() !== false) : ?> - - + - + +   @@ -84,90 +84,108 @@ require([ 'name="downloadable[link][<%- ' + 'data.id' + ' %>][sort_order]" ' + - 'value="<%- data.sort_order %>" class="input-text admin__control-text sort" />#'+ + 'value="<%- data.sort_order %>" class="input-text admin__control-text sort" />' + + '' + + ''+ ''+ ''+ ''+ ''+ - 'getStoreId() ? '' : '' ?>'+ + getStoreId()): ?> + '
'+ + ''+ + ''+ + '
' + + + getCanReadPrice() == false) : ?> + '' + + getStoreId() && $block->getIsPriceWebsiteScope()) : ?> + '' + + + ''+ getCanReadPrice() !== false) : ?> - ''+ - 'getCanEditPrice() === false) : ?> disabled="disabled" /> ' + - '' + - getStoreId() && $block->getIsPriceWebsiteScope()) : ?> - '
getCanEditPrice() === false) : ?> disabled="disabled" /> ' + - - '' + - - '' + - getStoreId() && $block->getIsPriceWebsiteScope()) : ?> - '' + + ''+ + 'getCanEditPrice() === false) : ?> disabled="disabled" /> ' + + '
[getBaseCurrencyCode($_product->getStoreId()) ?>]
' + + getStoreId() && $block->getIsPriceWebsiteScope()) : ?> + '
'+ + 'getCanEditPrice() === false) : ?> disabled="disabled" class="admin__control-checkbox" />'+ + '' + + '
' + + + '' + - - ''+ - '

/>

'+ - ''+ - ''+ - ''+ ''+ - '
'+ - '
'+ - ''+ - ''+ - ''+ ''+ ''+ - ''+ + ''+ ''+ ''; sampleItems = { From e848d5a84caa662aa5baa860ffe8741e44df593c Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Mon, 28 Sep 2015 18:49:44 +0300 Subject: [PATCH 29/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42347: Move Downloadable Tab to section --- .../templates/catalog/product/edit.phtml | 4 +- .../adminhtml/web/catalog/type-switcher.js | 63 ++++++++++--------- .../templates/product/edit/downloadable.phtml | 6 +- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit.phtml index bfafbcb02d220..dca336e618d3f 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit.phtml @@ -61,12 +61,12 @@ From 32b5975a6d4736a2a3ec6772b4a7f78c247a5a07 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Tue, 29 Sep 2015 17:24:51 +0300 Subject: [PATCH 39/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42347: Move Downloadable Tab to section --- .../Catalog/Product/Edit/Tab/Bundle.php | 2 +- .../Block/Adminhtml/Product/Edit/Tabs.php | 2 -- .../Product/Grouped/AssociatedProducts.php | 2 +- .../layout/catalog_product_grouped.xml | 4 +-- .../templates/product/grouped/container.phtml | 28 ------------------- 5 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php index 796fd242c39af..8ab078f1b3ec0 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php @@ -160,7 +160,7 @@ public function canShowTab() */ public function isHidden() { - return true; + return false; } /** diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php index ec3629577c434..dc83f7ebe16eb 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php @@ -73,8 +73,6 @@ class Tabs extends WigetTabs */ protected $_translateInline; - private $accordionBlockId = 'tabs-accordion-info'; - /** * @param Context $context * @param EncoderInterface $jsonEncoder diff --git a/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts.php b/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts.php index 4c0b426eab924..2c10789d60cad 100644 --- a/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts.php +++ b/app/code/Magento/GroupedProduct/Block/Product/Grouped/AssociatedProducts.php @@ -43,7 +43,7 @@ public function getParentTab() */ public function isHidden() { - return true; + return false; } /** diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml index 78ddbe16ddd30..220f40e999966 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml @@ -12,13 +12,13 @@ - + grouped - catalog.product.edit.tab.super.container + catalog.product.edit.tab.grouped.container diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml b/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml deleted file mode 100644 index eb538c21eb220..0000000000000 --- a/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml +++ /dev/null @@ -1,28 +0,0 @@ - - - -
-
-
- - getTabLabel() ?> - -
-
-
- getChildHtml()?> -
-
-
-
From 47d97be872d81ef898ee7da5af1860d440934787 Mon Sep 17 00:00:00 2001 From: Olga Matviienko Date: Tue, 29 Sep 2015 18:40:05 +0300 Subject: [PATCH 40/52] MAGETWO-36371: [UI] Assistance with Downloadable Products --- .../configurable/affected-attribute-set-selector/js.phtml | 2 +- .../module/components/_attributes_template_popup.less | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml index 7f5d2c7d899b7..111ab842f22a9 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml @@ -48,7 +48,7 @@ }, buttons: [{ text: '', - 'class': 'action-primary', + 'class': 'action-secondary', click: function() { var affectedAttributeSetId = $form.find('input[name=affected-attribute-set]:checked').val(); if (affectedAttributeSetId == 'current') { diff --git a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_attributes_template_popup.less b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_attributes_template_popup.less index 0418de00c1f4f..75fd108b57db8 100644 --- a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_attributes_template_popup.less +++ b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_attributes_template_popup.less @@ -10,4 +10,11 @@ &:extend(.abs-field-rows all); } } + .admin__field-option { + .addafter { + &:before { + margin-right: @indent__s; + } + } + } } From a514a0cd4203a949ba24718d1fa42d742ea1f0b1 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi Date: Wed, 30 Sep 2015 11:51:34 +0300 Subject: [PATCH 41/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42347: Move Downloadable Tab to section - change configurable block after check downloadble product --- .../catalog/product/edit/super/config.phtml | 2 +- .../templates/product/edit/downloadable.phtml | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml index d08fe6345b0ec..94b0f4c72926b 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml @@ -11,7 +11,7 @@
-
+
diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml index 2a0dc07ab3344..f8fb07a70966b 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml @@ -48,18 +48,38 @@ var uploaderTemplate = '
' + downloadableCheckbox = jQuery('[data-action=change-type-product]'), toggleTab = function (showTab) { showTab = showTab === undefined ? isDownloadable() ? 'true' : 'false' ?> : showTab; - if (jQuery('[data-tab=getTabId()?>]').data('collapsible')) { - jQuery('[data-tab=getTabId()?>]').collapsible(showTab ? 'activate' : 'deactivate'); + var tab = jQuery('[data-tab=getTabId()?>]'); + if (tab.data('collapsible')) { + tab.collapsible(showTab ? 'activate' : 'deactivate'); } else { - jQuery('[data-tab=getTabId()?>]').on('collapsiblecreated', function() { + tab.on('collapsiblecreated', function() { jQuery(this).collapsible(showTab ? 'activate' : 'deactivate'); }); } }; + var configurableBlock = (new function(attributeTitle, attributeTab) { + this.ref = jQuery(attributeTitle); + this.new = ''; + this.old = this.ref.text(); + this.change = function (change) { + if (change) { + this.ref.text(this.new); + jQuery(attributeTab).collapsible('deactivate'); + } else { + this.ref.text(this.old); + } + } + }('[data-role="product-create-configuration-info"]', '[data-tab="super_config"]')); + + downloadableCheckbox.on('change', function () { if (jQuery(this).is(':checked')) { toggleTab(true); + configurableBlock.change(true); + } else { + configurableBlock.change(false); } jQuery(document).trigger('typeSwitcherOut'); }); From c7f9cae6dc3e9848a58b6991cf07ad9482f632c4 Mon Sep 17 00:00:00 2001 From: Michail Slabko Date: Wed, 30 Sep 2015 12:58:16 +0300 Subject: [PATCH 42/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42348: Adapt FAT --- .../Test/Block/Adminhtml/Product/AffectedAttributeSet.php | 6 +++--- .../Test/Block/Adminhtml/Product/FormPageActions.php | 8 +++++--- .../Test/Constraint/AssertChildProductsInGrid.php | 2 +- .../GiftMessage/Test/Block/Cart/Item/GiftOptions.php | 2 +- .../Constraint/AssertGiftMessageInFrontendOrderItems.php | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php index c838565a3d1ad..eac63680dc2de 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php @@ -23,14 +23,14 @@ class AffectedAttributeSet extends ParentForm * * @var string */ - protected $confirmButton = '//button[contains(@id,"confirm-button")]'; + protected $confirmButton = '[data-role=action]'; /** * Locator buttons new name attribute set * * @var string */ - protected $affectedAttributeSetNew = '#affected-attribute-set-new'; + protected $affectedAttributeSetNew = '#new-affected-attribute-set'; /** * Fill popup form @@ -61,6 +61,6 @@ public function fill(FixtureInterface $product, SimpleElement $element = null) */ public function confirm() { - $this->_rootElement->find($this->confirmButton, Locator::SELECTOR_XPATH)->click(); + $this->_rootElement->find($this->confirmButton, Locator::SELECTOR_CSS)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php index 8ab7d90735adb..d52cbe77d49fd 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php @@ -15,12 +15,14 @@ */ class FormPageActions extends \Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions { + // @codingStandardsIgnoreStart /** - * Selector for "Affected Attribute Set" popup form + * Selector for "Affected Attribute Set" modal window * * @var string */ - protected $affectedAttributeSetForm = '[data-role=affected-attribute-set-selector]'; + protected $affectedAttributeSetForm = '//div[@data-role="affected-attribute-set-selector"]/ancestor::*[@data-role="modal"]'; + // @codingStandardsIgnoreEnd /** * Click on "Save" button @@ -46,7 +48,7 @@ protected function getAffectedAttributeSetForm() { return $this->blockFactory->create( '\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AffectedAttributeSet', - ['element' => $this->_rootElement->find($this->affectedAttributeSetForm, Locator::SELECTOR_CSS)] + ['element' => $this->browser->find($this->affectedAttributeSetForm, Locator::SELECTOR_XPATH)] ); } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.php index 557e1c09882fe..923e439e03940 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.php @@ -31,7 +31,7 @@ class AssertChildProductsInGrid extends AbstractConstraint public function processAssert(CatalogProductIndex $productGrid, ConfigurableProduct $product) { $configurableAttributesData = $product->getConfigurableAttributesData(); - $productType = $product->getIsVirtual() === "Yes" ? 'Virtual Product' : 'Simple Product'; + $productType = $product->getProductHasWeight() === "Yes" ? 'Simple Product' : 'Virtual Product'; $errors = []; $productGrid->open(); diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php index 78ce8fe619261..5443274248669 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php @@ -55,7 +55,7 @@ public function fillGiftMessageItem(GiftMessage $giftMessage, $products = []) /** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */ if ($giftMessage->getAllowGiftOptionsForItems() === 'Yes') { foreach ($products as $product) { - if ($product->getIsVirtual() !== 'Yes') { + if ($product->getProductHasWeight() == 'Yes') { $this->_rootElement->find( sprintf($this->allowGiftOptions, $product->getName()), Locator::SELECTOR_XPATH diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php index bb193414ea93a..9adbac82bef1a 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Constraint/AssertGiftMessageInFrontendOrderItems.php @@ -62,7 +62,7 @@ public function processAssert( 'message' => $itemGiftMessage->getMessage(), ]; } - if ($product->getIsVirtual() == 'Yes') { + if ($product->getProductHasWeight() !== 'Yes') { $expectedData = []; } From eb3200d43131f02cc0adad12ca33a542437027ac Mon Sep 17 00:00:00 2001 From: Michail Slabko Date: Wed, 30 Sep 2015 13:57:35 +0300 Subject: [PATCH 43/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42353: Delivery to mainline -- fix static tests --- app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php | 1 + .../Catalog/Block/Adminhtml/Product/Edit/Tab/ChildTab.php | 3 +++ .../Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php | 2 +- .../Block/Adminhtml/Product/Helper/Form/WeightTest.php | 2 +- .../Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php | 8 +++----- app/code/Magento/ConfigurableProduct/composer.json | 1 - .../templates/catalog/product/edit/super/config.phtml | 2 +- .../Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php | 2 ++ 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php index 8cd6cc4fffa45..fac304750b366 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php @@ -8,6 +8,7 @@ * Customer edit block * * @author Magento Core Team + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ namespace Magento\Catalog\Block\Adminhtml\Product; diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/ChildTab.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/ChildTab.php index e187219d34c22..e9b2f68bfb205 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/ChildTab.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/ChildTab.php @@ -42,6 +42,9 @@ public function getContent() return $this->tab->toHtml(); } + /** + * @return string + */ public function getTabId() { return $this->tab->getTabId(); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php index dc83f7ebe16eb..9828bd095fa6a 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php @@ -336,7 +336,7 @@ protected function _translateHtml($html) } /** - * @param $parentTab + * @param string $parentTab * @return string */ public function getAccordion($parentTab) diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php index 359a78ec38ede..c5cb5700c445e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/WeightTest.php @@ -97,7 +97,7 @@ public function testSetForm() $this->returnSelf() ); - $this->_model->setForm($form); + $this->_model->setForm($form); } public function testGetEscapedValue() diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php index 189fccb97ead7..0d91e23db469c 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php @@ -23,7 +23,7 @@ class Matrix extends \Magento\Backend\Block\Template * * @var \Magento\Framework\Registry */ - protected $_coreRegistry = null; + protected $_coreRegistry; /** * @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable @@ -58,7 +58,6 @@ class Matrix extends \Magento\Backend\Block\Template * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configurableType * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry * @param \Magento\ConfigurableProduct\Model\Product\Type\VariationMatrix $variationMatrix * @param ProductRepositoryInterface $productRepository @@ -69,7 +68,6 @@ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configurableType, \Magento\Framework\Registry $coreRegistry, - \Magento\Framework\Locale\CurrencyInterface $localeCurrency, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, \Magento\ConfigurableProduct\Model\Product\Type\VariationMatrix $variationMatrix, ProductRepositoryInterface $productRepository, @@ -80,7 +78,6 @@ public function __construct( $this->_configurableType = $configurableType; $this->_coreRegistry = $coreRegistry; $this->stockRegistry = $stockRegistry; - parent::__construct($context, $data); $this->variationMatrix = $variationMatrix; $this->productRepository = $productRepository; $this->image = $image; @@ -266,6 +263,7 @@ public function getProductAttributes() /** * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @return void * TODO: move to class */ protected function prepareVariations() @@ -284,7 +282,7 @@ protected function prepareVariations() $key = implode('-', $attributeValues); if (isset($productByUsedAttributes[$key])) { $product = $productByUsedAttributes[$key]; - $price = $originPrice = $product->getPrice(); + $price = $product->getPrice(); $variationOptions = []; foreach ($usedProductAttributes as $attribute) { if (!isset($attributes[$attribute->getAttributeId()])) { diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index a90d56be9beb6..3ed8b8b4eaf5f 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -11,7 +11,6 @@ "magento/module-backend": "1.0.0-beta", "magento/module-eav": "1.0.0-beta", "magento/module-customer": "1.0.0-beta", - "magento/module-directory": "1.0.0-beta", "magento/framework": "1.0.0-beta", "magento/module-media-storage": "1.0.0-beta", "magento/module-quote": "1.0.0-beta", diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml index 94b0f4c72926b..f5951e3cd280d 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml @@ -86,7 +86,7 @@ require([ $('[data-form=edit-product]').trigger("change_configurable_type", isConfigurable); }; - $('[data-tab=getTabId()?>]') + $('[data-tab=getTabId()?>]') .on('dimensionsChanged', function (event, data) { var suggestContainer = $('#product-template-suggest-container .action-dropdown > .action-toggle'); if (data.opened) { diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php index f7a3bd8cb41bb..70c1441e75a91 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable.php @@ -54,6 +54,7 @@ public function getDownloadableBlock($type, SimpleElement $element = null) * * @param array|null $fields * @param SimpleElement|null $element + * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @return array */ public function getDataFormTab($fields = null, SimpleElement $element = null) @@ -78,6 +79,7 @@ public function getDataFormTab($fields = null, SimpleElement $element = null) * * @param array $fields * @param SimpleElement|null $element + * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @return $this */ public function fillFormTab(array $fields, SimpleElement $element = null) From b72df40fa4b6470cb58165f0c84ef7ec9073cc86 Mon Sep 17 00:00:00 2001 From: Michail Slabko Date: Wed, 30 Sep 2015 15:13:44 +0300 Subject: [PATCH 44/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42353: Delivery to mainline -- fix tests --- .../AssertConfigurableProductForm.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php index eb733915bc22e..dbe514e6e8545 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php @@ -90,7 +90,7 @@ protected function prepareFixtureData(array $data, array $sortFields = []) protected function prepareFormData(array $data, array $sortFields = []) { // filter values and reset keys in variation matrix - $variationsMatrix = $data['configurable_attributes_data']['matrix']; + $variationsMatrix = $this->trimCurrencyForPriceInMatrix($data['configurable_attributes_data']['matrix']); foreach ($variationsMatrix as $key => $variationMatrix) { $variationsMatrix[$key] = array_diff_key($variationMatrix, array_flip($this->skippedVariationMatrixFields)); } @@ -101,4 +101,21 @@ protected function prepareFormData(array $data, array $sortFields = []) } return $data; } + + /** + * Escape currency for price in matrix + * + * @param array $variationsMatrix + * @param string $currency + * @return array + */ + protected function trimCurrencyForPriceInMatrix($variationsMatrix, $currency = '$') + { + foreach ($variationsMatrix as &$variation) { + if (isset($variation['price'])) { + $variation['price'] = str_replace($currency, '', $variation['price']); + } + } + return $variationsMatrix; + } } From 949cdbab963d3dd7c0a524a91cc8b48b41a78659 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov Date: Wed, 30 Sep 2015 15:29:54 +0300 Subject: [PATCH 45/52] MAGETWO-35324: Success message for contact us form does not disappear even after closing browser --- .../Test/Unit/Controller/Index/IndexTest.php | 22 ------------------- app/code/Magento/Contact/composer.json | 1 + 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php index ccaec64fabb98..a914cf698e33b 100644 --- a/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php @@ -93,31 +93,9 @@ public function setUp() public function testExecute() { - $layout = $this->getMock( - '\Magento\Framework\View\Layout', - ['getBlock', 'initMessages'], - [], - '', - false - ); - $block = $this->getMockForAbstractClass( - '\Magento\Framework\View\Element\AbstractBlock', - ['setFormAction'], - '', - false - ); - $layout->expects($this->once()) - ->method('getBlock') - ->with('contactForm') - ->will($this->returnValue($block)); - $this->_view->expects($this->once()) ->method('loadLayout'); - $this->_view->expects($this->exactly(1)) - ->method('getLayout') - ->will($this->returnValue($layout)); - $this->_view->expects($this->once()) ->method('renderLayout'); diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index 0b7d865823385..27185c09c5557 100644 --- a/app/code/Magento/Contact/composer.json +++ b/app/code/Magento/Contact/composer.json @@ -5,6 +5,7 @@ "php": "~5.5.0|~5.6.0|~7.0.0", "magento/module-config": "1.0.0-beta", "magento/module-store": "1.0.0-beta", + "magento/module-backend": "1.0.0-beta", "magento/module-customer": "1.0.0-beta", "magento/module-cms": "1.0.0-beta", "magento/framework": "1.0.0-beta", From 0b00395becdf2b657c71625fd5103f3f656ca9dd Mon Sep 17 00:00:00 2001 From: Michail Slabko Date: Wed, 30 Sep 2015 15:39:42 +0300 Subject: [PATCH 46/52] MAGETWO-36655: Downloadable UI and Flow Update - MAGETWO-42353: Delivery to mainline -- fix static --- .../templates/product/edit/tabs.phtml | 2 +- .../product/edit/tabs/child_tab.phtml | 12 +++++----- .../catalog/product/edit/super/matrix.phtml | 2 +- .../templates/product/edit/downloadable.phtml | 8 +++---- .../product/edit/downloadable/samples.phtml | 24 +++++++++---------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs.phtml index b51fc1b7cbb0a..4285cba52e575 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs.phtml @@ -98,7 +98,7 @@ getUiId('tab', 'content', $_tab->getId()) ?> > getTabContent($_tab); ?> - getAccordion($_tab); ?> + getAccordion($_tab); ?>
diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs/child_tab.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs/child_tab.phtml index 97abc7a027808..1d5e98a29e10b 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs/child_tab.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/product/edit/tabs/child_tab.phtml @@ -8,9 +8,9 @@ /** @var $block \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\ChildTab */ ?> -
, +
, "openedState": "_show", "closedState": "_hide", "animate": 200, @@ -19,10 +19,10 @@ >
- getTitle()?> + getTitle()?>
-
- getContent()?> +
+ getContent()?>
diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml index dcf63fe2a2b5b..e962963ccac6c 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml @@ -144,7 +144,7 @@ $currencySymbol = $block->getCurrencySymbol(); - +
diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml index f8fb07a70966b..df5d55fcf076e 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable.phtml @@ -47,8 +47,8 @@ var uploaderTemplate = '
' + '', downloadableCheckbox = jQuery('[data-action=change-type-product]'), toggleTab = function (showTab) { - showTab = showTab === undefined ? isDownloadable() ? 'true' : 'false' ?> : showTab; - var tab = jQuery('[data-tab=getTabId()?>]'); + showTab = showTab === undefined ? isDownloadable() ? 'true' : 'false' ?> : showTab; + var tab = jQuery('[data-tab=getTabId()?>]'); if (tab.data('collapsible')) { tab.collapsible(showTab ? 'activate' : 'deactivate'); } else { @@ -60,7 +60,7 @@ var uploaderTemplate = '
' + var configurableBlock = (new function(attributeTitle, attributeTab) { this.ref = jQuery(attributeTitle); - this.new = ''; this.old = this.ref.text(); this.change = function (change) { @@ -261,7 +261,7 @@ var uploaderTemplate = '
' + isDownloadable() ? 'checked="checked"' : ''?> />
diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml index 78c22f8cac1a5..c5fe83f3f92fb 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml @@ -17,12 +17,12 @@ $block->getConfigJson(); ?>
isSingleStoreMode() ? ' data-config-scope="' . __('[STORE VIEW]') . '"' : ''; ?>> - +
- getStoreId() && $block->getUsedDefault()) ? 'disabled="disabled"' : '' ?>> + getStoreId() && $block->getUsedDefault()) ? 'disabled="disabled"' : '' ?>> getStoreId()): ?>
- getUsedDefault() ? 'checked="checked"' : '' ?> /> + getUsedDefault() ? 'checked="checked"' : '' ?> />
@@ -34,9 +34,9 @@ $block->getConfigJson(); - - - + + + @@ -50,7 +50,7 @@ $block->getConfigJson();
 
- +
@@ -89,8 +89,8 @@ require([ '
'+ '
'+ '
'+ - '' + - '' + + '' + + '' + '