From 29955ad7e7cfd1ea5915eedfbb174644a6f75829 Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Tue, 9 Feb 2016 21:06:20 +0200 Subject: [PATCH 001/278] MAGETWO-47246: Add Attribute and Attributes Panel --- .../Catalog/Model/Attribute/DataProvider.php | 176 +++++++ .../Product/Form/Modifier/Attributes.php | 21 + .../product_attribute_add_form.xml | 440 ++++++++++++++++++ 3 files changed, 637 insertions(+) create mode 100644 app/code/Magento/Catalog/Model/Attribute/DataProvider.php create mode 100644 app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml diff --git a/app/code/Magento/Catalog/Model/Attribute/DataProvider.php b/app/code/Magento/Catalog/Model/Attribute/DataProvider.php new file mode 100644 index 0000000000000..e908f6debbe07 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Attribute/DataProvider.php @@ -0,0 +1,176 @@ +collection = $collectionFactory->create(); + } + + /** + * Get data + * + * @return array + */ + public function getData() + { + return []; + } + + /** + * @return array + */ + public function getMeta() + { + $meta = parent::getMeta(); + + $scopes = [ + [ + 'value' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, + 'label' => __('Store View') + ], + [ + 'value' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, + 'label' => __('Website') + ], + [ + 'value' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, + 'label' => __('Global') + ] + ]; + + $meta['advanced_fieldset']['children'] = [ + 'is_global' => ['options' => $scopes], + 'attribute_code' => [ + 'notice' => __( + "This is used internally. Make sure you don't use spaces or more than %1 symbols.", + EavAttribute::ATTRIBUTE_CODE_MAX_LENGTH + ), + 'validation' => [ + 'validate-length' => true, + 'maximum-length-' . EavAttribute::ATTRIBUTE_CODE_MAX_LENGTH => true + ] + ] + ]; + + $meta['base_fieldset']['children']['attribute_options'] = [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'componentType' => 'dynamicRows', + 'dataScope' => 'attribute_options', + 'addButtonLabel' => __('Add Value') + ] + ] + ], + 'children' => [ + 'record' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'componentType' => 'container', + 'isTemplate' => true, + 'is_collection' => true, + 'component' => 'Magento_Ui/js/dynamic-rows/record', +// 'positionProvider' => 'attribute_options_container.position' + ], + ], + ], + 'children' => [ + 'attribute_options_container' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'componentType' => 'fieldset', + 'label' => null, + 'sortOrder' => 10, + 'opened' => true, + ], + ], + ], + 'children' => [ + 'is_default' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'componentType' => 'field', + 'dataType' => Form\Element\DataType\Boolean::NAME, + 'formElement' => Form\Element\Checkbox::NAME, + 'label' => __('Is Default'), + 'dataScope' => 'is_default', + 'prefer' => 'radio', + 'value' => '1', + 'sortOrder' => 10, + ], + ], + ], + ], + 'options[0]' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'componentType' => Form\Field::NAME, + 'dataType' => Form\Element\DataType\Text::NAME, + 'dataScope' => 'option[0]', + 'formElement' => Form\Element\Input::NAME, + 'label' => __('Default Store View'), + 'sortOrder' => 20, + ] + ] + ] + ], + 'options[1]' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'componentType' => Form\Field::NAME, + 'dataType' => Form\Element\DataType\Text::NAME, + 'dataScope' => 'options[1]', + 'formElement' => Form\Element\Input::NAME, + 'label' => __('Admin'), + 'sortOrder' => 30, + ] + ] + ] + ] + ] + ] + ] + ] + ] + ]; + + return $meta; + } +} diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php index 5ac7a7c8b386f..5013df4135917 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php @@ -132,9 +132,30 @@ public function modifyMeta(array $meta) ] ] ], + [ + 'text' => __('Create New Attribute'), + 'class' => 'action-secondary', + 'actions' => [ + [ + 'targetName' => '', + 'actionName' => 'create' + ] + ] + ] ], ], ]; + + $meta['new_attribute_modal']['arguments']['data']['config'] = [ + 'isTemplate' => false, + 'componentType' => Component\Modal::NAME, + 'dataScope' => '', + 'provider' => 'product_form.product_form_data_source', + 'options' => [ + 'title' => __('New Attribute') + ], + ]; + $meta['add_attribute_modal']['children'] = [ 'product_attributes_grid' => [ 'arguments' => [ diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml new file mode 100644 index 0000000000000..91b6c271d695d --- /dev/null +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml @@ -0,0 +1,440 @@ + + +
+ + + product_attribute_add_form.product_attribute_add_form_data_source + product_attribute_add_form.product_attribute_add_form_data_source + + New Attribute + templates/form/collapsible + + + + + data + product_attribute_add_form + + true + + + + Magento\Catalog\Model\Product\Attribute\DataProvider + product_attribute_add_form_data_source + attribute_id + id + + + + + + + + + Magento_Ui/js/form/provider + + + + +
+ + + Attribute Properties + false + 10 + + + + + + string + hidden + attribute_id + + + + + + + 10 + string + input + Attribute Label + true + + true + + frontend_label + + + + + + Magento\Catalog\Model\Product\Attribute\Source\Inputtype + + 20 + string + select + Catalog Input Type for Store Owner + frontend_input + + + + + + Magento\Config\Model\Config\Source\Yesno + + 30 + boolean + checkbox + toggle + Required + + + + + 0 + is_required + + + +
+ +
+ + + Advanced Attribute Properties + true + 20 + + + + + + 10 + string + input + Attribute Code + attribute_code + true + + true + true + + + + + + + + 20 + string + select + Scope + Declare attribute value saving scope. + is_global + + + + + + + 30 + string + input + Default Value + default_value_text + + + + + + + 30 + text + textarea + Default Value + default_value_textarea + + + + + + + 30 + boolean + checkbox + toggle + Default Value + + 1 + 0 + + 0 + default_value_yesno + + + + + + + 30 + text + date + Default Value + default_value_date + + + + + + + 40 + boolean + checkbox + toggle + Unique Value + + 1 + 0 + + Not shared with other products. + 0 + is_unique + + + + + + + + + + 60 + boolean + checkbox + toggle + Add to Column Options + + 1 + 0 + + Add this attribute to the list of column options in the product grid. + 0 + is_used_in_grid + + + + + + + string + hidden + is_visible_in_grid + + + + + + + 70 + boolean + checkbox + toggle + Use in Filter Options + + 1 + 0 + + Add this attribute to the list of filter options in the product grid. + 0 + is_filterable_in_grid + + + +
+ +
+ + + Storefront Properties + true + 30 + + + + + + 10 + boolean + checkbox + toggle + Use in Search + + 1 + 0 + + 0 + is_searchable + + + + + + + 20 + boolean + checkbox + toggle + Visible in Advanced Search + + 1 + 0 + + + + ${ $.provider }:data.is_searchable + + 0 + is_visible_in_advanced_search + + + + + + + 30 + boolean + checkbox + toggle + Comparable on Storefront + + 1 + 0 + + 0 + is_comparable + + + + + + + + + + 70 + boolean + checkbox + toggle + Use for Promo Rule Conditions + + 1 + 0 + + 0 + is_used_for_promo_rules + + + + + + + 80 + boolean + checkbox + toggle + Allow HTML Tags on Storefront + + 1 + 0 + + 0 + + + + + is_html_allowed_on_front + + + + + + + + + 90 + boolean + checkbox + toggle + Enable WYSIWYG + + 1 + 0 + + 0 + is_wysiwyg_enabled + + + + + + + 100 + boolean + checkbox + toggle + Visible on Catalog Pages on Storefront + + 1 + 0 + + 0 + is_visible_on_front + + + + + + + 110 + boolean + checkbox + toggle + Used in Product Listing + + 1 + 0 + + Depends on design theme. + 0 + used_in_product_listing + + + + + + + 120 + boolean + checkbox + toggle + Used for Sorting in Product Listing + Depends on design theme. + + 1 + 0 + + 0 + used_for_sort_by + + + +
+
From 95ee632427481b5ad33a43aef826792983aca078 Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Wed, 10 Feb 2016 19:21:25 +0200 Subject: [PATCH 002/278] MAGETWO-47246: Add Attribute and Attributes Panel --- .../{ => Product}/Attribute/DataProvider.php | 0 .../Product/Form/Modifier/Attributes.php | 104 ++++++++++++++---- .../catalog_product_attribute_edit_form.xml | 15 +++ 3 files changed, 98 insertions(+), 21 deletions(-) rename app/code/Magento/Catalog/Model/{ => Product}/Attribute/DataProvider.php (100%) create mode 100644 app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_attribute_edit_form.xml diff --git a/app/code/Magento/Catalog/Model/Attribute/DataProvider.php b/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php similarity index 100% rename from app/code/Magento/Catalog/Model/Attribute/DataProvider.php rename to app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php index 5013df4135917..38cc26f0a1a66 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php @@ -9,7 +9,7 @@ use Magento\Framework\Registry; use Magento\Framework\AuthorizationInterface; use Magento\Ui\Component; -use Magento\Catalog\Model\Locator\LocatorInterface; +use Magento\Catalog\Model\Locator\LocatorInterface;use Magento\Ui\Component\Container; class Attributes extends AbstractModifier { @@ -131,32 +131,94 @@ public function modifyMeta(array $meta) 'closeModal' ] ] - ], - [ - 'text' => __('Create New Attribute'), - 'class' => 'action-secondary', - 'actions' => [ - [ - 'targetName' => '', - 'actionName' => 'create' - ] - ] ] ], ], ]; - $meta['new_attribute_modal']['arguments']['data']['config'] = [ - 'isTemplate' => false, - 'componentType' => Component\Modal::NAME, - 'dataScope' => '', - 'provider' => 'product_form.product_form_data_source', - 'options' => [ - 'title' => __('New Attribute') - ], - ]; - $meta['add_attribute_modal']['children'] = [ + 'add_new_attribute_button' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'formElement' => Container::NAME, + 'componentType' => Container::NAME, + 'component' => 'Magento_Ui/js/form/components/button', + 'additionalClasses' => 'admin_field-complex', + 'template' => 'ui/form/components/button/container', + 'actions' => [ + [ + 'targetName' => 'product_form.product_form.add_attribute_modal.create_new_attribute_modal', + 'actionName' => 'toggleModal', + ], + [ + 'targetName' + => 'product_form.product_form.add_attribute_modal.create_new_attribute_modal.product_attribute_add_form', + 'actionName' => 'render' + ] + ], + 'title' => __('Create New Attribute'), + 'additionalForGroup' => true, + 'provider' => false, + 'source' => 'add_attribute_modal', + 'displayArea' => 'insideGroup', + ] + ] + ] + ], + 'create_new_attribute_modal' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'isTemplate' => false, + 'componentType' => Component\Modal::NAME, + 'dataScope' => '', + 'provider' => 'product_form.product_form_data_source', + 'options' => [ + 'title' => __('New Attribute'), + 'buttons' => [ + [ + 'text' => 'Cancel', + 'class' => 'action-secondary', + 'actions' => [ + [ + 'targetName' => '${ $.name }', + 'actionName' => 'actionCancel' + ] + ] + ], + ] + ], + ] + ] + ], + 'children' => [ + 'product_attribute_add_form' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'label' => __('New Attribute'), + 'componentType' => Component\Container::NAME, + 'component' => 'Magento_Ui/js/form/components/insert-form', + 'dataScope' => '', + 'update_url' => $this->urlBuilder->getUrl('mui/index/render'), + 'render_url' => $this->urlBuilder->getUrl( + 'mui/index/render_handle', + [ + 'handle' => 'catalog_product_attribute_edit_form' + ] + ), + 'autoRender' => false, + 'ns' => 'product_attribute_add_form', + 'externalProvider' => 'product_attribute_add_form.product_attribute_add_form_data_source', + 'toolbarContainer' => '${ $.parentName }', + 'formSubmitType' => 'ajax', + ] + ] + ] + ] + ] + ], 'product_attributes_grid' => [ 'arguments' => [ 'data' => [ diff --git a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_attribute_edit_form.xml b/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_attribute_edit_form.xml new file mode 100644 index 0000000000000..9123ebe8fdcb9 --- /dev/null +++ b/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_attribute_edit_form.xml @@ -0,0 +1,15 @@ + + + + + + + + + + From 706a5244faf84e5fbd8672bcf3187748ea916b15 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Thu, 11 Feb 2016 10:42:16 +0200 Subject: [PATCH 003/278] MAGETWO-47227: Configurable panel implementation --- .../Product/Form/Modifier/Configurable.php | 147 ++++++++++++++++++ .../ConfigurableProduct/etc/adminhtml/di.xml | 10 ++ 2 files changed, 157 insertions(+) create mode 100644 app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php new file mode 100644 index 0000000000000..b0f64f2e6d28b --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -0,0 +1,147 @@ +locator = $locator; + } + + /** + * {@inheritdoc} + */ + public function modifyData(array $data) + { + return $data; + } + + /** + * {@inheritdoc} + */ + public function modifyMeta(array $meta) + { + if (in_array($this->locator->getProduct()->getTypeId(), self::$availableProductTypes)) { + $meta = array_replace_recursive( + $meta, + [ + static::GROUP_CONFIGURABLE => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'label' => __('Configurations'), + 'collapsible' => true, + 'opened' => true, + 'componentType' => Form\Fieldset::NAME, + 'sortOrder' => $this->getNextGroupSortOrder( + $meta, + self::$groupContent, + self::$sortOrder + ), + ], + ], + ], + 'children' => $this->getPanelChildren(), + ], + ] + ); + } + return $meta; + } + + /** + * Prepares panel children configuration + * + * @return array + */ + protected function getPanelChildren() { + return [ + 'configurable_products_button_set' => $this->getButtonSet(), + ]; + } + + /** + * Returns Buttons Set configuration + * + * @return array + */ + protected function getButtonSet() + { + return [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'formElement' => 'container', + 'componentType' => 'container', + 'label' => false, + 'content' => __( + 'Configurable products allow customers to choose options ' + . '(Ex: shirt color). You need to create a simple product for each ' + . 'configuration (Ex: a product for each color).' + ), + 'template' => 'ui/form/components/complex', + ], + ], + ], + 'children' => [ + 'create_configurable_products_button' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'formElement' => 'container', + 'componentType' => 'container', + 'component' => 'Magento_Ui/js/form/components/button', + 'actions' => [], + 'title' => __('Create Configurations'), + 'provider' => null, + ], + ], + ], + ], + ], + ]; + } +} \ No newline at end of file diff --git a/app/code/Magento/ConfigurableProduct/etc/adminhtml/di.xml b/app/code/Magento/ConfigurableProduct/etc/adminhtml/di.xml index b624fa0201578..d99cbe0701521 100644 --- a/app/code/Magento/ConfigurableProduct/etc/adminhtml/di.xml +++ b/app/code/Magento/ConfigurableProduct/etc/adminhtml/di.xml @@ -35,4 +35,14 @@ + + + + + Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier\Configurable + 140 + + + + From 024f504e7dcf0972ee9ea7336e9922a8415567f3 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Mon, 15 Feb 2016 09:20:44 +0200 Subject: [PATCH 004/278] MAGETWO-47227: Configurable panel implementation --- .../Product/Form/Modifier/Configurable.php | 13 ++++-- .../catalog_product_superconfig_config.xml | 45 ++++++++++++++++++- .../catalog/product/edit/super/wizard.phtml | 39 ++++++++++++++++ 3 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php index b0f64f2e6d28b..51a50ef526a7b 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -10,6 +10,7 @@ use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType; use Magento\Catalog\Model\Product\Type; use Magento\Ui\Component\Form; +use Magento\Ui\Component\Modal; /** * Data provider for Configurable products @@ -65,7 +66,7 @@ public function modifyData(array $data) public function modifyMeta(array $meta) { if (in_array($this->locator->getProduct()->getTypeId(), self::$availableProductTypes)) { - $meta = array_replace_recursive( + $meta = array_merge_recursive( $meta, [ static::GROUP_CONFIGURABLE => [ @@ -89,6 +90,7 @@ public function modifyMeta(array $meta) ] ); } + return $meta; } @@ -134,9 +136,14 @@ protected function getButtonSet() 'formElement' => 'container', 'componentType' => 'container', 'component' => 'Magento_Ui/js/form/components/button', - 'actions' => [], + 'actions' => [ + [ + 'targetName' => + 'product_form.product_form.step-wizard-dialog', + 'actionName' => 'openModal', + ], + ], 'title' => __('Create Configurations'), - 'provider' => null, ], ], ], diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_superconfig_config.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_superconfig_config.xml index 23bfe498712c8..fc21e6ccab2c8 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_superconfig_config.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_superconfig_config.xml @@ -25,6 +25,49 @@ admin.product.edit.tab.super.config.grid.container - + + + + + + false + + 3333 + true + fieldset + + + + + + + + + + + + diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml new file mode 100644 index 0000000000000..377025e9c8140 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -0,0 +1,39 @@ + +getProductMatrix(); +$attributes = $block->getProductAttributes(); +$currencySymbol = $block->getCurrencySymbol(); +?> + +
", + "buttons":[], "modalClass": "product_form_product_form_somelongstring_modal"}}' + class="no-display"> +
+ \ No newline at end of file From 7244f1438cdbd2eaea2bc213afcafd8e9cb14a39 Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Mon, 15 Feb 2016 20:15:58 +0200 Subject: [PATCH 005/278] MAGETWO-47246: Add Attribute and Attributes Panel --- .../Model/Product/Attribute/DataProvider.php | 70 ++++++++++++++----- .../product_attribute_add_form.xml | 4 -- .../web/js/components/visible-on-option.js | 39 +++++++++++ 3 files changed, 91 insertions(+), 22 deletions(-) create mode 100644 app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php b/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php index e908f6debbe07..00220fdf55188 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php @@ -84,38 +84,46 @@ public function getMeta() ] ]; - $meta['base_fieldset']['children']['attribute_options'] = [ + $meta['base_fieldset']['children']['attribute_options_container'] = [ 'arguments' => [ 'data' => [ 'config' => [ - 'componentType' => 'dynamicRows', - 'dataScope' => 'attribute_options', - 'addButtonLabel' => __('Add Value') + 'formElement' => 'container', + 'componentType' => 'container', + 'component' => 'Magento_Catalog/js/components/visible-on-option', + 'valuesForOptions' => [ + 'select', + 'multiselect' + ], + 'dataScope' => 'attribute_options_container' ] ] ], 'children' => [ - 'record' => [ + 'attribute_options' => [ 'arguments' => [ 'data' => [ 'config' => [ - 'componentType' => 'container', - 'isTemplate' => true, - 'is_collection' => true, - 'component' => 'Magento_Ui/js/dynamic-rows/record', -// 'positionProvider' => 'attribute_options_container.position' - ], - ], + 'componentType' => 'dynamicRows', + 'dataScope' => 'attribute_options', + 'addButtonLabel' => __('Add Value'), +// 'visible' => false, + 'imports' => [ +// 'visible' => 'product_attribute_add_form.frontend_input:select' + ], + ] + ] ], 'children' => [ - 'attribute_options_container' => [ + 'record' => [ 'arguments' => [ 'data' => [ 'config' => [ - 'componentType' => 'fieldset', - 'label' => null, - 'sortOrder' => 10, - 'opened' => true, + 'componentType' => 'container', + 'isTemplate' => true, + 'is_collection' => true, + 'component' => 'Magento_Ui/js/dynamic-rows/record', + 'positionProvider' => 'attribute_options.position' ], ], ], @@ -163,7 +171,33 @@ public function getMeta() ] ] ] - ] + ], + 'position' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'componentType' => Form\Field::NAME, + 'dataType' => Form\Element\DataType\Text::NAME, + 'formElement' => Form\Element\Input::NAME, + 'dataScope' => 'position', + 'visible' => false, + 'additionalClasses' => ['_hidden' => true] + ], + ], + ], + ], + 'action_delete' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'componentType' => 'actionDelete', + 'dataType' => Form\Element\DataType\Text::NAME, + 'label' => '', + 'fit' => true, + ], + ], + ], + ], ] ] ] diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml index 91b6c271d695d..0f31f7a28ac4a 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml @@ -95,10 +95,6 @@ checkbox toggle Required - - - - 0 is_required diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js b/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js new file mode 100644 index 0000000000000..575481c9c5025 --- /dev/null +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js @@ -0,0 +1,39 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'uiCollection' +], function (Group) { + 'use strict'; + + return Group.extend({ + defaults: { + valuesForOptions: [], // ['select', 'multiselect'], + visibilityState: true, + imports: { + toggleVisibility: '${ $.parentName }.frontend_input:value' + } + + }, + + initElement: function (item) { + this._super(); + + item.set('visible', this.visibilityState); + + return this; + }, + + toggleVisibility: function (selected) { + //this.visible(this.valuesForOptions.indexOf(selected) != -1); + //console.log(selected); + //console.log(this.valuesForOptions); + var isShown = this.visibilityState = this.valuesForOptions.indexOf(selected) !== -1; + + this.elems.each(function (child) { + child.set('visible', isShown); + }); + } + }); +}); From 3cbcef3675db8447b6fd64ee2c7d37c66cfb5f81 Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Wed, 17 Feb 2016 18:54:00 +0200 Subject: [PATCH 006/278] MAGETWO-47246: Add Attribute and Attributes Panel --- .../Model/Product/Attribute/DataProvider.php | 235 +++++++++--------- .../product_attribute_add_form.xml | 88 +++++++ .../web/js/components/visible-on-option.js | 10 +- 3 files changed, 205 insertions(+), 128 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php b/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php index 00220fdf55188..8fba13dc1b6c8 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php @@ -84,126 +84,121 @@ public function getMeta() ] ]; - $meta['base_fieldset']['children']['attribute_options_container'] = [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'formElement' => 'container', - 'componentType' => 'container', - 'component' => 'Magento_Catalog/js/components/visible-on-option', - 'valuesForOptions' => [ - 'select', - 'multiselect' - ], - 'dataScope' => 'attribute_options_container' - ] - ] - ], - 'children' => [ - 'attribute_options' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'componentType' => 'dynamicRows', - 'dataScope' => 'attribute_options', - 'addButtonLabel' => __('Add Value'), -// 'visible' => false, - 'imports' => [ -// 'visible' => 'product_attribute_add_form.frontend_input:select' - ], - ] - ] - ], - 'children' => [ - 'record' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'componentType' => 'container', - 'isTemplate' => true, - 'is_collection' => true, - 'component' => 'Magento_Ui/js/dynamic-rows/record', - 'positionProvider' => 'attribute_options.position' - ], - ], - ], - 'children' => [ - 'is_default' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'componentType' => 'field', - 'dataType' => Form\Element\DataType\Boolean::NAME, - 'formElement' => Form\Element\Checkbox::NAME, - 'label' => __('Is Default'), - 'dataScope' => 'is_default', - 'prefer' => 'radio', - 'value' => '1', - 'sortOrder' => 10, - ], - ], - ], - ], - 'options[0]' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'componentType' => Form\Field::NAME, - 'dataType' => Form\Element\DataType\Text::NAME, - 'dataScope' => 'option[0]', - 'formElement' => Form\Element\Input::NAME, - 'label' => __('Default Store View'), - 'sortOrder' => 20, - ] - ] - ] - ], - 'options[1]' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'componentType' => Form\Field::NAME, - 'dataType' => Form\Element\DataType\Text::NAME, - 'dataScope' => 'options[1]', - 'formElement' => Form\Element\Input::NAME, - 'label' => __('Admin'), - 'sortOrder' => 30, - ] - ] - ] - ], - 'position' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'componentType' => Form\Field::NAME, - 'dataType' => Form\Element\DataType\Text::NAME, - 'formElement' => Form\Element\Input::NAME, - 'dataScope' => 'position', - 'visible' => false, - 'additionalClasses' => ['_hidden' => true] - ], - ], - ], - ], - 'action_delete' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'componentType' => 'actionDelete', - 'dataType' => Form\Element\DataType\Text::NAME, - 'label' => '', - 'fit' => true, - ], - ], - ], - ], - ] - ] - ] - ] - ] - ]; +// $meta['base_fieldset']['children']['attribute_options_container'] = [ +// 'arguments' => [ +// 'data' => [ +// 'config' => [ +// 'formElement' => 'container', +// 'componentType' => 'container', +// 'component' => 'Magento_Catalog/js/components/visible-on-option', +// 'valuesForOptions' => [ +// 'select', +// 'multiselect' +// ] +// ] +// ] +// ], +// 'children' => [ +// 'attribute_options' => [ +// 'arguments' => [ +// 'data' => [ +// 'config' => [ +// 'componentType' => 'dynamicRows', +// 'dataScope' => 'attribute_options', +// 'addButtonLabel' => __('Add Value') +// ] +// ] +// ], +// 'children' => [ +// 'record' => [ +// 'arguments' => [ +// 'data' => [ +// 'config' => [ +// 'componentType' => 'container', +// 'isTemplate' => true, +// 'is_collection' => true, +// 'component' => 'Magento_Ui/js/dynamic-rows/record', +// 'positionProvider' => 'attribute_options.position' +// ], +// ], +// ], +// 'children' => [ +// 'is_default' => [ +// 'arguments' => [ +// 'data' => [ +// 'config' => [ +// 'componentType' => 'field', +// 'dataType' => Form\Element\DataType\Boolean::NAME, +// 'formElement' => Form\Element\Checkbox::NAME, +// 'label' => __('Is Default'), +// 'dataScope' => 'is_default', +// 'prefer' => 'radio', +// 'value' => '1', +// 'sortOrder' => 10, +// ], +// ], +// ], +// ], +// 'options[0]' => [ +// 'arguments' => [ +// 'data' => [ +// 'config' => [ +// 'componentType' => Form\Field::NAME, +// 'dataType' => Form\Element\DataType\Text::NAME, +// 'dataScope' => 'option[0]', +// 'formElement' => Form\Element\Input::NAME, +// 'label' => __('Default Store View'), +// 'sortOrder' => 20, +// ] +// ] +// ] +// ], +// 'options[1]' => [ +// 'arguments' => [ +// 'data' => [ +// 'config' => [ +// 'componentType' => Form\Field::NAME, +// 'dataType' => Form\Element\DataType\Text::NAME, +// 'dataScope' => 'options[1]', +// 'formElement' => Form\Element\Input::NAME, +// 'label' => __('Admin'), +// 'sortOrder' => 30, +// ] +// ] +// ] +// ], +// 'position' => [ +// 'arguments' => [ +// 'data' => [ +// 'config' => [ +// 'componentType' => Form\Field::NAME, +// 'dataType' => Form\Element\DataType\Text::NAME, +// 'formElement' => Form\Element\Input::NAME, +// 'dataScope' => 'position', +// 'visible' => false, +// 'additionalClasses' => ['_hidden' => true] +// ], +// ], +// ], +// ], +// 'action_delete' => [ +// 'arguments' => [ +// 'data' => [ +// 'config' => [ +// 'componentType' => 'actionDelete', +// 'dataType' => Form\Element\DataType\Text::NAME, +// 'label' => '', +// 'fit' => true, +// ], +// ], +// ], +// ], +// ] +// ] +// ] +// ] +// ] +// ]; return $meta; } diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml index 0f31f7a28ac4a..b5a7d15102387 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml @@ -100,6 +100,94 @@ + + + + container + container + Magento_Catalog/js/components/visible-on-option + + select + multiselect + + + + + + + dynamicRows + attribute_options + Add Value + + + + + + true + true + Magento_Ui/js/dynamic-rows/record + container + attribute_options.position + false + + + + + + boolean + checkbox + Is Default + is_default + radio + 1 + + + + + + + text + input + Default Store View + option[0] + + + + + + + text + input + Admin + option[1] + + + + + + + text + input + Admin + position + false + + true + + + + + + + actionDelete + text + + true + + + + +
diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js b/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js index 575481c9c5025..3c76eca54d302 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js @@ -9,27 +9,21 @@ define([ return Group.extend({ defaults: { - valuesForOptions: [], // ['select', 'multiselect'], + valuesForOptions: [], visibilityState: true, imports: { toggleVisibility: '${ $.parentName }.frontend_input:value' } - }, initElement: function (item) { this._super(); - item.set('visible', this.visibilityState); - return this; }, toggleVisibility: function (selected) { - //this.visible(this.valuesForOptions.indexOf(selected) != -1); - //console.log(selected); - //console.log(this.valuesForOptions); - var isShown = this.visibilityState = this.valuesForOptions.indexOf(selected) !== -1; + var isShown = this.visibilityState = selected in this.valuesForOptions; //this.valuesForOptions.indexOf(selected) !== -1; this.elems.each(function (child) { child.set('visible', isShown); From 09a9941a67892be65323ec0d803c6d6ed8560e65 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Thu, 18 Feb 2016 10:29:14 +0200 Subject: [PATCH 007/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../Product/Form/Modifier/Configurable.php | 4 ++- .../catalog_product_superconfig_config.xml | 2 +- .../catalog/product/edit/super/matrix.phtml | 6 ++++ .../catalog/product/edit/super/wizard.phtml | 36 ++++++++++++------- .../web/js/advanced-pricing-handler.js | 3 +- .../web/js/configurable-type-handler.js | 17 +++++---- .../web/js/options/price-type-handler.js | 3 +- 7 files changed, 49 insertions(+), 22 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php index 51a50ef526a7b..0abc7c7c9734a 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -65,6 +65,8 @@ public function modifyData(array $data) */ public function modifyMeta(array $meta) { + //return $meta; + if (in_array($this->locator->getProduct()->getTypeId(), self::$availableProductTypes)) { $meta = array_merge_recursive( $meta, @@ -139,7 +141,7 @@ protected function getButtonSet() 'actions' => [ [ 'targetName' => - 'product_form.product_form.step-wizard-dialog', + 'configurableVariations', 'actionName' => 'openModal', ], ], diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_superconfig_config.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_superconfig_config.xml index fc21e6ccab2c8..01ed274cbc994 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_superconfig_config.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_superconfig_config.xml @@ -25,7 +25,7 @@ admin.product.edit.tab.super.config.grid.container - + \ No newline at end of file diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/advanced-pricing-handler.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/advanced-pricing-handler.js index 1f04719da9954..43df5e39be2e3 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/advanced-pricing-handler.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/advanced-pricing-handler.js @@ -2,7 +2,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - +/* define([ 'jquery', 'Magento_Catalog/catalog/type-events' @@ -43,3 +43,4 @@ define([ } }; }); +*/ \ No newline at end of file diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/configurable-type-handler.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/configurable-type-handler.js index 3a77ac24ba6f9..b87de17b725ba 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/configurable-type-handler.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/configurable-type-handler.js @@ -86,6 +86,7 @@ define([ _initType: function () { var suggestContainer = $('#product-template-suggest-container .action-dropdown > .action-toggle'); + /* if (productType.type.current === 'configurable') { this._setElementDisabled(suggestContainer.addClass('disabled'), true); this._setElementDisabled($('#inventory_qty'), true); @@ -98,12 +99,15 @@ define([ this._setElementDisabled($('#inventory_stock_availability'), true); this._setElementDisabled($('#qty'), false, true); } + */ - if (['simple', 'virtual', 'configurable'].indexOf(productType.type.current) < 0) { + /*if (['simple', 'virtual', 'configurable'].indexOf(productType.type.current) < 0) { this.hide(); } else { this.show(); - } + }*/ + + this.show(); }, /** @@ -114,12 +118,13 @@ define([ this.$block = $(data.blockId + ' input[name="attributes[]"]'); this.hasVariations = data.hasVariations; - advancedPricingHandler.init(); - priceTypeHandler.init(); + //advancedPricingHandler.init(); + //priceTypeHandler.init(); - if (productType.type.init === 'configurable' && !this.hasVariations) { + /*if (productType.type.init === 'configurable' && !this.hasVariations) { $(document).trigger('setTypeProduct', 'simple'); - } + }*/ + $(document).trigger('setTypeProduct', 'simple'); this.bindAll(); this._initType(); diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/options/price-type-handler.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/options/price-type-handler.js index d0d0314443b5d..d486723fc46d0 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/options/price-type-handler.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/options/price-type-handler.js @@ -2,7 +2,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - +/* define([ 'jquery', 'Magento_Catalog/catalog/type-events', @@ -80,3 +80,4 @@ define([ } }; }); +*/ \ No newline at end of file From 1417d770b93f018b3a3fd02ac052bb1fd6dc4757 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Thu, 18 Feb 2016 12:14:23 +0200 Subject: [PATCH 008/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../Product/Form/Modifier/Configurable.php | 2 +- .../catalog/product/edit/super/wizard.phtml | 39 ++++++++++--------- .../Ui/view/base/web/js/lib/step-wizard.js | 7 ---- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php index 0abc7c7c9734a..0227181c211fd 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -141,7 +141,7 @@ protected function getButtonSet() 'actions' => [ [ 'targetName' => - 'configurableVariations', + 'product_form.product_form.configurableModal', 'actionName' => 'openModal', ], ], diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index e19789219d3eb..fc166100e1516 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -13,27 +13,32 @@ $productMatrix = $block->getProductMatrix(); $attributes = $block->getProductAttributes(); $currencySymbol = $block->getCurrencySymbol(); ?> -
- +
+ + getVariationWizard([ + 'attributes' => $attributes, + 'configurations' => $productMatrix + ]); + ?> +
\ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js b/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js index 925db56dd1755..1d0b583ea40c8 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js @@ -184,13 +184,6 @@ define([ this.selectedStep(this.wizard.prev()); }, open: function () { - /* - var $form = $('[data-form=edit-product]'); - - if (!$form.valid()) { - $form.data('validator').focusInvalid(); - } else { - */ require('uiRegistry').get('product_form.product_form').validate(); if (!require('uiRegistry').get('product_form.product_form').source.get('params.invalid')) { this.selectedStep(this.stepsNames.first()); From 3fab9a37abd96d55f7fecfc2ff15303accfd0923 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Fri, 19 Feb 2016 12:18:30 +0200 Subject: [PATCH 009/278] MAGETWO-49382: Refactor service layer --- .../Product/AddAttributeToTemplate.php | 204 +++++++++++++----- .../Eav/Api/Data/AttributeGroupInterface.php | 67 +++++- .../Eav/Model/Attribute/GroupRepository.php | 23 ++ .../Magento/Eav/Model/AttributeRepository.php | 2 +- .../Eav/Model/Entity/Attribute/Group.php | 72 ++++++- .../Db/Collection/AbstractCollection.php | 27 +++ 6 files changed, 336 insertions(+), 59 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php index 3832adef2c4a7..804951258959e 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php @@ -6,8 +6,21 @@ */ namespace Magento\Catalog\Controller\Adminhtml\Product; -use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory; +use Magento\Catalog\Api\AttributeSetRepositoryInterface; +use Magento\Catalog\Api\Data\ProductAttributeInterface; +use Magento\Eav\Api\AttributeGroupRepositoryInterface; +use Magento\Eav\Api\AttributeManagementInterface; +use Magento\Eav\Api\AttributeRepositoryInterface; +use Magento\Eav\Api\Data\AttributeGroupInterface; +use Magento\Eav\Api\Data\AttributeGroupInterfaceFactory; +use Magento\Eav\Api\Data\AttributeInterface; +use Magento\Eav\Api\Data\AttributeSetInterface; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Api\SortOrderBuilder; +/** + * Class AddAttributeToTemplate + */ class AddAttributeToTemplate extends \Magento\Catalog\Controller\Adminhtml\Product { /** @@ -16,25 +29,78 @@ class AddAttributeToTemplate extends \Magento\Catalog\Controller\Adminhtml\Produ protected $resultJsonFactory; /** - * @var CollectionFactory + * @var AttributeRepositoryInterface + */ + protected $attributeRepository; + + /** + * @var AttributeSetRepositoryInterface + */ + protected $attributeSetRepository; + + /** + * @var AttributeGroupRepositoryInterface + */ + protected $attributeGroupRepository; + + /** + * @var SearchCriteriaBuilder + */ + protected $searchCriteriaBuilder; + + /** + * @var SortOrderBuilder + */ + protected $sortOrderBuilder; + + /** + * @var AttributeGroupInterfaceFactory + */ + protected $attributeGroupFactory; + + /** + * @var CatalogEavResource + */ + protected $catalogEavResourceFactory; + + /** + * @var AttributeManagementInterfaces */ - protected $attributeCollectionFactory; + protected $attributeManagement; /** * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder + * @param Builder $productBuilder * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory - * @param CollectionFactory $attributeCollectionFactory + * @param AttributeRepositoryInterface $attributeRepository + * @param AttributeSetRepositoryInterface $attributeSetRepository + * @param AttributeGroupRepositoryInterface $attributeGroupRepository + * @param AttributeGroupInterfaceFactory $attributeGroupFactory + * @param SearchCriteriaBuilder $searchCriteriaBuilder + * @param SortOrderBuilder $sortOrderBuilder + * @param AttributeManagementInterface $attributeManagement */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, - CollectionFactory $attributeCollectionFactory + AttributeRepositoryInterface $attributeRepository, + AttributeSetRepositoryInterface $attributeSetRepository, + AttributeGroupRepositoryInterface $attributeGroupRepository, + AttributeGroupInterfaceFactory $attributeGroupFactory, + SearchCriteriaBuilder $searchCriteriaBuilder, + SortOrderBuilder $sortOrderBuilder, + AttributeManagementInterface $attributeManagement ) { parent::__construct($context, $productBuilder); $this->resultJsonFactory = $resultJsonFactory; - $this->attributeCollectionFactory = $attributeCollectionFactory; + $this->attributeRepository = $attributeRepository; + $this->attributeSetRepository = $attributeSetRepository; + $this->attributeGroupRepository = $attributeGroupRepository; + $this->attributeGroupFactory = $attributeGroupFactory; + $this->searchCriteriaBuilder = $searchCriteriaBuilder; + $this->sortOrderBuilder = $sortOrderBuilder; + $this->attributeManagement = $attributeManagement; } /** @@ -48,57 +114,99 @@ public function execute() $response = new \Magento\Framework\DataObject(); $response->setError(false); - try { - $attributeSet = $this->_objectManager->create('Magento\Eav\Model\Entity\Attribute\Set') - ->load($request->getParam('templateId')); - - /** @var \Magento\Eav\Model\ResourceModel\Attribute\Collection $collection */ - $attributesCollection = $this->attributeCollectionFactory->create(); - - $attributesIds = $request->getParam('attributesIds'); - if ($attributesIds['excludeMode'] === 'false' && !empty($attributesIds['selected'])) { - $attributesCollection - ->addFieldToFilter('main_table.attribute_id', ['in' => $attributesIds['selected']]); - } elseif ($attributesIds['excludeMode'] === 'true') { - $attributesCollection->setExcludeSetFilter($attributeSet->getId()); - } else { - throw new \Magento\Framework\Exception\LocalizedException(__('Please, specify attributes')); - } + $attributeSearchCriteriaBuilder = clone $this->searchCriteriaBuilder; + $groupSearchCriteriaBuilder = clone $this->searchCriteriaBuilder; + try { + /** @var AttributeSetInterface $attributeSet */ + $attributeSet = $this->attributeSetRepository->get($request->getParam('templateId')); $groupCode = $request->getParam('groupCode'); + $groupName = $request->getParam('groupName'); + $groupSortOrder = $request->getParam('groupSortOrder'); - /** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection $attributeGroupCollection */ - $attributeGroupCollection = $this->_objectManager->get( - 'Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection' + $attributeSearchCriteriaBuilder = $this->addBasicAttributeSearchFilters( + $attributeSearchCriteriaBuilder, + $attributeSet ); - $attributeGroupCollection->setAttributeSetFilter($attributeSet->getId()); - $attributeGroupCollection->addFilter('attribute_group_code', $groupCode); - $attributeGroupCollection->setPageSize(1); - - $attributeGroup = $attributeGroupCollection->getFirstItem(); - - if (!$attributeGroup->getId()) { - $attributeGroup->addData( - [ - 'attribute_group_code' => $groupCode, - 'attribute_set_id' => $attributeSet->getId(), - 'attribute_group_name' => $request->getParam('groupName'), - 'sort_order' => $request->getParam('groupSortOrder') - ] - ); - $attributeGroup->save(); - } - foreach ($attributesCollection as $attribute) { - $attribute->setAttributeSetId($attributeSet->getId())->loadEntityAttributeIdBySet(); - $attribute->setAttributeGroupId($attributeGroup->getId()) - ->setSortOrder('0') - ->save(); + $attributeSearchCriteria = $attributeSearchCriteriaBuilder->create(); + $attributeGroupSearchCriteria = $groupSearchCriteriaBuilder + ->addFilter('attribute_set_id', $attributeSet->getAttributeSetId()) + ->addFilter('attribute_group_code', $groupCode) + ->addSortOrder($this->sortOrderBuilder->setAscendingDirection()->create()) + ->setPageSize(1) + ->create(); + + try { + /** @var AttributeGroupInterface[] $attributeGroupItems */ + $attributeGroupItems = $this->attributeGroupRepository->getList($attributeGroupSearchCriteria) + ->getItems(); + + if (!$attributeGroupItems) { + throw new \Magento\Framework\Exception\NoSuchEntityException; + } + + /** @var AttributeGroupInterface $attributeGroup */ + $attributeGroup = reset($attributeGroupItems); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + /** @var AttributeGroupInterface $attributeGroup */ + $attributeGroup = $this->attributeGroupFactory->create(); } + + $attributeGroup->setAttributeGroupCode($groupCode); + $attributeGroup->setSortOrder($groupSortOrder); + $attributeGroup->setAttributeGroupName($groupName); + $attributeGroup->setAttributeSetId($attributeSet->getAttributeSetId()); + + $this->attributeGroupRepository->save($attributeGroup); + + /** @var AttributeInterface[] $attributesItems */ + $attributesItems = $this->attributeRepository->getList( + ProductAttributeInterface::ENTITY_TYPE_CODE, + $attributeSearchCriteria + )->getItems(); + + array_walk($attributesItems, function (AttributeInterface $attribute) use ($attributeSet, $attributeGroup) { + $this->attributeManagement->assign( + ProductAttributeInterface::ENTITY_TYPE_CODE, + $attributeSet->getAttributeSetId(), + $attributeGroup->getAttributeGroupId(), + $attribute->getAttributeCode(), + '0' + ); + }); } catch (\Exception $e) { $response->setError(true); $response->setMessage($e->getMessage()); } + return $this->resultJsonFactory->create()->setJsonData($response->toJson()); } + + /** + * Adding basic filters + * + * @param SearchCriteriaBuilder $attributeSearchCriteriaBuilder + * @param AttributeSetInterface $attributeSet + * @return SearchCriteriaBuilder + * @throws \Magento\Framework\Exception\LocalizedException + */ + private function addBasicAttributeSearchFilters( + SearchCriteriaBuilder $attributeSearchCriteriaBuilder, + AttributeSetInterface $attributeSet + ) { + $attributesIds = (array)$this->getRequest()->getParam('attributesIds', []); + + if (!empty($attributesIds['selected'])) { + $attributeSearchCriteriaBuilder->addFilter( + 'attribute_id', + [$attributesIds['selected']], + 'in' + ); + } else { + throw new \Magento\Framework\Exception\LocalizedException(__('Please, specify attributes')); + } + + return $attributeSearchCriteriaBuilder; + } } diff --git a/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php b/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php index 9c02bda805670..6799e989d285f 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php @@ -10,10 +10,13 @@ interface AttributeGroupInterface extends ExtensibleDataInterface { const GROUP_ID = 'attribute_group_id'; - const GROUP_NAME = 'attribute_group_name'; - const ATTRIBUTE_SET_ID = 'attribute_set_id'; + const SORT_ORDER = 'sort_order'; + const DEFAULT_ID = 'default_id'; + const ATTRIBUTE_GROUP_CODE = 'attribute_group_code'; + const TAB_GROUP_CODE = 'tab_group_code'; + /** * Retrieve id @@ -60,6 +63,66 @@ public function getAttributeSetId(); */ public function setAttributeSetId($attributeSetId); + /** + * Retrieve sort order + * + * @return int + */ + public function getSortOrder(); + + /** + * Set sort order + * + * @param int $sortOrder + * @return $this + */ + public function setSortOrder($sortOrder); + + /** + * Retrieve default ID + * + * @return int + */ + public function getDefaultId(); + + /** + * Set default ID + * + * @param int $value + * @return $this + */ + public function setDefaultId($value); + + /** + * Retrieve attribute group code + * + * @return string + */ + public function getAttributeGroupCode(); + + /** + * Set attribute group code + * + * @param string $attributeGroupCode + * @return $this + */ + public function setAttributeGroupCode($attributeGroupCode); + + /** + * Retrieve tab group code + * + * @return string + */ + public function getTabGroupCode(); + + /** + * Set tab group code + * + * @param string $tabGroupCode + * @return $this + */ + public function setTabGroupCode($tabGroupCode); + /** * Retrieve existing extension attributes object. * diff --git a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php index d5bebb357123c..caa85a5d66d3d 100644 --- a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php +++ b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php @@ -121,6 +121,10 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr $collection->setAttributeSetFilter($attributeSetId); $collection->setSortOrder(); + if ($attributeGroupCode = $this->retrieveAttributeGroupCodeFromSearchCriteria($searchCriteria)) { + $collection->addFilter('attribute_group_code', $attributeGroupCode); + } + $searchResult = $this->searchResultsFactory->create(); $searchResult->setSearchCriteria($searchCriteria); $searchResult->setItems($collection->getItems()); @@ -188,4 +192,23 @@ protected function retrieveAttributeSetIdFromSearchCriteria( } return null; } + + /** + * Retrieve attribute group code + * + * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria + * @return null|string + */ + protected function retrieveAttributeGroupCodeFromSearchCriteria( + \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria + ) { + foreach ($searchCriteria->getFilterGroups() as $group) { + foreach ($group->getFilters() as $filter) { + if ($filter->getField() == 'attribute_group_code') { + return $filter->getValue(); + } + } + } + return null; + } } diff --git a/app/code/Magento/Eav/Model/AttributeRepository.php b/app/code/Magento/Eav/Model/AttributeRepository.php index 6545375a245cf..9c23d9b276d3f 100644 --- a/app/code/Magento/Eav/Model/AttributeRepository.php +++ b/app/code/Magento/Eav/Model/AttributeRepository.php @@ -103,7 +103,7 @@ public function getList($entityTypeCode, \Magento\Framework\Api\SearchCriteriaIn 'main_table.entity_type_id = entity_type.entity_type_id', [] ); - $attributeCollection->join( + $attributeCollection->joinLeft( ['eav_entity_attribute' => $attributeCollection->getTable('eav_entity_attribute')], 'main_table.attribute_id = eav_entity_attribute.attribute_id', [] diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php index 3ade99cd99a7e..fbd2d51c72c46 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php @@ -13,14 +13,6 @@ * * @method \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group _getResource() * @method \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group getResource() - * @method int getSortOrder() - * @method \Magento\Eav\Model\Entity\Attribute\Group setSortOrder(int $value) - * @method int getDefaultId() - * @method \Magento\Eav\Model\Entity\Attribute\Group setDefaultId(int $value) - * @method string getAttributeGroupCode() - * @method \Magento\Eav\Model\Entity\Attribute\Group setAttributeGroupCode(string $value) - * @method string getTabGroupCode() - * @method \Magento\Eav\Model\Entity\Attribute\Group setTabGroupCode(string $value) */ class Group extends \Magento\Framework\Model\AbstractExtensibleModel implements \Magento\Eav\Api\Data\AttributeGroupInterface @@ -172,6 +164,70 @@ public function setAttributeSetId($attributeSetId) return $this->setData(self::ATTRIBUTE_SET_ID, $attributeSetId); } + /** + * {@inheritdoc} + */ + public function getSortOrder() + { + return $this->getData(self::SORT_ORDER); + } + + /** + * {@inheritdoc} + */ + public function setSortOrder($sortOrder) + { + return $this->setData(self::SORT_ORDER); + } + + /** + * {@inheritdoc} + */ + public function getDefaultId() + { + return $this->getData(self::DEFAULT_ID); + } + + /** + * {@inheritdoc} + */ + public function setDefaultId($value) + { + return $this->setData(self::DEFAULT_ID); + } + + /** + * {@inheritdoc} + */ + public function getAttributeGroupCode() + { + return $this->getData(self::ATTRIBUTE_GROUP_CODE); + } + + /** + * {@inheritdoc} + */ + public function setAttributeGroupCode($attributeGroupCode) + { + return $this->setData(self::ATTRIBUTE_GROUP_CODE); + } + + /** + * {@inheritdoc} + */ + public function getTabGroupCode() + { + return $this->getData(self::TAB_GROUP_CODE); + } + + /** + * {@inheritdoc} + */ + public function setTabGroupCode($tabGroupCode) + { + return $this->setData(self::TAB_GROUP_CODE); + } + /** * {@inheritdoc} * diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php index de66653672dd6..33c3e576337b3 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php @@ -518,6 +518,33 @@ public function join($table, $cond, $cols = '*') return $this; } + /** + * Join table to collection select + * + * @param string $table + * @param string $cond + * @param string $cols + * @return $this + */ + public function joinLeft($table, $cond, $cols = '*') + { + if (is_array($table)) { + foreach ($table as $k => $v) { + $alias = $k; + $table = $v; + break; + } + } else { + $alias = $table; + } + + if (!isset($this->_joinedTables[$alias])) { + $this->getSelect()->joinLeft([$alias => $this->getTable($table)], $cond, $cols); + $this->_joinedTables[$alias] = true; + } + return $this; + } + /** * Redeclare before load method for adding event * From 4d975e1a4b1037481302ee8f0844fdfd36c48630 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Fri, 19 Feb 2016 12:51:06 +0200 Subject: [PATCH 010/278] MAGETWO-49382: Refactor service layer --- .../Product/AddAttributeToTemplate.php | 22 +++++-------------- .../Eav/Api/Data/AttributeGroupInterface.php | 5 ++--- .../Eav/Model/Entity/Attribute/Group.php | 10 ++++----- .../Model/Attribute/GroupRepositoryTest.php | 6 ++--- 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php index 804951258959e..849e6854f9773 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php @@ -20,6 +20,8 @@ /** * Class AddAttributeToTemplate + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AddAttributeToTemplate extends \Magento\Catalog\Controller\Adminhtml\Product { @@ -58,11 +60,6 @@ class AddAttributeToTemplate extends \Magento\Catalog\Controller\Adminhtml\Produ */ protected $attributeGroupFactory; - /** - * @var CatalogEavResource - */ - protected $catalogEavResourceFactory; - /** * @var AttributeManagementInterfaces */ @@ -124,10 +121,7 @@ public function execute() $groupName = $request->getParam('groupName'); $groupSortOrder = $request->getParam('groupSortOrder'); - $attributeSearchCriteriaBuilder = $this->addBasicAttributeSearchFilters( - $attributeSearchCriteriaBuilder, - $attributeSet - ); + $attributeSearchCriteriaBuilder = $this->addBasicAttributeSearchFilters($attributeSearchCriteriaBuilder); $attributeSearchCriteria = $attributeSearchCriteriaBuilder->create(); $attributeGroupSearchCriteria = $groupSearchCriteriaBuilder @@ -187,26 +181,22 @@ public function execute() * Adding basic filters * * @param SearchCriteriaBuilder $attributeSearchCriteriaBuilder - * @param AttributeSetInterface $attributeSet * @return SearchCriteriaBuilder * @throws \Magento\Framework\Exception\LocalizedException */ private function addBasicAttributeSearchFilters( - SearchCriteriaBuilder $attributeSearchCriteriaBuilder, - AttributeSetInterface $attributeSet + SearchCriteriaBuilder $attributeSearchCriteriaBuilder ) { $attributesIds = (array)$this->getRequest()->getParam('attributesIds', []); if (!empty($attributesIds['selected'])) { - $attributeSearchCriteriaBuilder->addFilter( + return $attributeSearchCriteriaBuilder->addFilter( 'attribute_id', [$attributesIds['selected']], 'in' ); - } else { - throw new \Magento\Framework\Exception\LocalizedException(__('Please, specify attributes')); } - return $attributeSearchCriteriaBuilder; + throw new \Magento\Framework\Exception\LocalizedException(__('Please, specify attributes')); } } diff --git a/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php b/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php index 6799e989d285f..93a1744068b7f 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php @@ -17,7 +17,6 @@ interface AttributeGroupInterface extends ExtensibleDataInterface const ATTRIBUTE_GROUP_CODE = 'attribute_group_code'; const TAB_GROUP_CODE = 'tab_group_code'; - /** * Retrieve id * @@ -88,10 +87,10 @@ public function getDefaultId(); /** * Set default ID * - * @param int $value + * @param int $defaultId * @return $this */ - public function setDefaultId($value); + public function setDefaultId($defaultId); /** * Retrieve attribute group code diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php index fbd2d51c72c46..20a43b7fb0faf 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php @@ -177,7 +177,7 @@ public function getSortOrder() */ public function setSortOrder($sortOrder) { - return $this->setData(self::SORT_ORDER); + return $this->setData(self::SORT_ORDER, $sortOrder); } /** @@ -191,9 +191,9 @@ public function getDefaultId() /** * {@inheritdoc} */ - public function setDefaultId($value) + public function setDefaultId($defaultId) { - return $this->setData(self::DEFAULT_ID); + return $this->setData(self::DEFAULT_ID, $defaultId); } /** @@ -209,7 +209,7 @@ public function getAttributeGroupCode() */ public function setAttributeGroupCode($attributeGroupCode) { - return $this->setData(self::ATTRIBUTE_GROUP_CODE); + return $this->setData(self::ATTRIBUTE_GROUP_CODE, $attributeGroupCode); } /** @@ -225,7 +225,7 @@ public function getTabGroupCode() */ public function setTabGroupCode($tabGroupCode) { - return $this->setData(self::TAB_GROUP_CODE); + return $this->setData(self::TAB_GROUP_CODE, $tabGroupCode); } /** diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php index 00b4cfc09b087..97bf81d808cb9 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php @@ -279,10 +279,10 @@ public function testGetList() false ); $groupCollectionMock->expects($this->once())->method('getItems')->willReturn([$groupMock]); - $searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroupMock]); + $searchCriteriaMock->expects($this->exactly(2))->method('getFilterGroups')->willReturn([$filterGroupMock]); - $filterGroupMock->expects($this->once())->method('getFilters')->willReturn([$filterInterfaceMock]); - $filterInterfaceMock->expects($this->once())->method('getField')->willReturn('attribute_set_id'); + $filterGroupMock->expects($this->exactly(2))->method('getFilters')->willReturn([$filterInterfaceMock]); + $filterInterfaceMock->expects($this->exactly(2))->method('getField')->willReturn('attribute_set_id'); $filterInterfaceMock->expects($this->once())->method('getValue')->willReturn($attributeSetId); $this->setRepositoryMock->expects($this->once()) From d5fb6a9e57acd920c64e9860d78fe6fd7b39e4eb Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 19 Feb 2016 13:44:24 +0200 Subject: [PATCH 011/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../catalog/product/edit/super/wizard.phtml | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index e19789219d3eb..ceb8cb853b336 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -12,8 +12,13 @@ $productMatrix = $block->getProductMatrix(); $attributes = $block->getProductAttributes(); $currencySymbol = $block->getCurrencySymbol(); + +$stepWizardHtml = $block->getVariationWizard([ + 'attributes' => $attributes, + 'configurations' => $productMatrix +]); ?> -
+
\ No newline at end of file From b1634131b347101e564a5e4275d1299b2fe15b1d Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 19 Feb 2016 13:46:56 +0200 Subject: [PATCH 012/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../DataProvider/Product/Form/Modifier/Configurable.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php index 0abc7c7c9734a..de0e0cacdc5a0 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -141,7 +141,13 @@ protected function getButtonSet() 'actions' => [ [ 'targetName' => - 'configurableVariations', + 'product_form.product_form.configurableModal', + 'actionName' => 'trigger', + 'params' => ['active', true], + ], + [ + 'targetName' => + 'product_form.product_form.configurableModal', 'actionName' => 'openModal', ], ], From 5710affd793516b62108f9b3879acda35d7fbeef Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 19 Feb 2016 16:56:35 +0200 Subject: [PATCH 013/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../product/edit/super/wizard-ajax.phtml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml new file mode 100644 index 0000000000000..913c751ddfd49 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml @@ -0,0 +1,19 @@ + +getProductMatrix(); +$attributes = $block->getProductAttributes(); + +/* @escapeNotVerified */ echo $block->getVariationWizard([ + 'attributes' => $attributes, + 'configurations' => $productMatrix +]); +?> \ No newline at end of file From 22804f4733d09b988ef9385d28fa153f8864ca60 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 19 Feb 2016 16:59:29 +0200 Subject: [PATCH 014/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../layout/catalog_product_wizard.xml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_wizard.xml diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_wizard.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_wizard.xml new file mode 100644 index 0000000000000..11d43fa985e5d --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_wizard.xml @@ -0,0 +1,30 @@ + + + + + + + + false + + 3333 + true + fieldset + + + + + + + + + + + + + From 53053cc9a9b0001cde5be81fe023e722c7998300 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Fri, 19 Feb 2016 17:06:21 +0200 Subject: [PATCH 015/278] MAGETWO-49479: Create Controller for ajax requests --- .../Controller/Adminhtml/Product/Wizard.php | 46 +++++++++++++++++++ .../catalog/product/edit/super/wizard.phtml | 8 +++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Wizard.php diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Wizard.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Wizard.php new file mode 100644 index 0000000000000..22f94a2bc42c4 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Wizard.php @@ -0,0 +1,46 @@ +productBuilder = $productBuilder; + } + + /** + * {@inheritdoc} + */ + public function execute() + { + $product = $this->productBuilder->build($this->getRequest()); + + /** @var \Magento\Framework\View\Result\Layout $resultLayout */ + $resultLayout = $this->resultFactory->create(ResultFactory::TYPE_PAGE); + $resultLayout->getLayout()->getUpdate()->removeHandle('default'); + + return $resultLayout; + } +} \ No newline at end of file diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index fc166100e1516..f4be2308e0cfa 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -30,7 +30,13 @@ $currencySymbol = $block->getCurrencySymbol(); "components": { "product_form.product_form.configurableModal": { "component": "Magento_Ui/js/modal/modal-component", - "options": {"type": "slide", "title": ""} + "options": {"type": "slide", "title": ""}, + "children": { + "wizard": { + "url": "getUrl('catalog/product/wizard', ['id' => $block->getProduct()->getId()]) ?>", + "component": "Magento_Ui/js/form/components/html" + } + } }, "configurableVariations": { "component": "Magento_ConfigurableProduct/js/variations/variations", From e39761c91c94e7a0270460540628c02c9633f8c5 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 19 Feb 2016 17:38:38 +0200 Subject: [PATCH 016/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../Product/Form/Modifier/Configurable.php | 110 +++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php index de0e0cacdc5a0..99133d42ee142 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -10,7 +10,7 @@ use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType; use Magento\Catalog\Model\Product\Type; use Magento\Ui\Component\Form; -use Magento\Ui\Component\Modal; +use Magento\Ui\Component\DynamicRows; /** * Data provider for Configurable products @@ -156,6 +156,114 @@ protected function getButtonSet() ], ], ], + //'variations' => $this->getGrid(), + ], + ]; + } + + /** + * Returns dynamic rows configuration + * + * @return array + */ + /*protected function getGrid() + { + return [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'additionalClasses' => 'admin__field-wide', + 'componentType' => DynamicRows::NAME, + 'label' => __('Current Variations'), + 'renderDefaultRecord' => true, + 'template' => 'ui/dynamic-rows/templates/grid', + 'component' => 'Magento_Ui/js/dynamic-rows/dynamic-rows-grid', + 'addButton' => false, + 'itemTemplate' => 'record', + 'dataScope' => 'data.links', + 'deleteButtonLabel' => __('Remove'), + 'dataProvider' => 'grouped_product_listing', + 'map' => [ + 'id' => 'entity_id', + 'name' => 'name', + ], + 'links' => ['insertData' => '${ $.provider }:${ $.dataProvider }'], + 'sortOrder' => 20, + 'columnsHeader' => true, + 'columnsHeaderAfterRender' => false, + ], + ], + ], + 'children' => $this->getRows(), + ]; + }*/ + + /** + * Returns Dynamic rows records configuration + * + * @return array + */ + protected function getRows() + { + return [ + 'record' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'componentType' => 'container', + 'isTemplate' => false, + 'is_collection' => true, + 'component' => 'Magento_Ui/js/dynamic-rows/record', + 'dataScope' => '', + ], + ], + ], + 'children' => [ + 'id' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'dataType' => Form\Element\DataType\Number::NAME, + 'formElement' => Form\Element\Input::NAME, + 'componentType' => Form\Field::NAME, + 'dataScope' => 'qty', + 'label' => __('Default Quantity'), + 'fit' => true, + 'additionalClasses' => 'admin__field-small', + 'sortOrder' => 80, + ], + ], + ], + ], + 'actionDelete' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'additionalClasses' => 'data-grid-actions-cell', + 'componentType' => 'actionDelete', + 'dataType' => Form\Element\DataType\Text::NAME, + 'label' => __('Actions'), + 'sortOrder' => 90, + 'fit' => true, + ], + ], + ], + ], + 'position' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'dataType' => Form\Element\DataType\Number::NAME, + 'formElement' => Form\Element\Input::NAME, + 'componentType' => Form\Field::NAME, + 'dataScope' => 'position', + 'sortOrder' => 100, + 'visible' => false, + ], + ], + ], + ], + ], ], ]; } From 1db7c323566fd48de4ecf4ae2a42c3abfe75876d Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Fri, 19 Feb 2016 18:22:06 +0200 Subject: [PATCH 017/278] MAGETWO-47246: Add Attribute and Attributes Panel --- .../Model/Product/Attribute/DataProvider.php | 116 -------- .../product_attribute_add_form.xml | 255 +++++++++++++----- .../web/js/components/visible-on-option.js | 12 +- 3 files changed, 190 insertions(+), 193 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php b/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php index 8fba13dc1b6c8..587ee975b5706 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php @@ -84,122 +84,6 @@ public function getMeta() ] ]; -// $meta['base_fieldset']['children']['attribute_options_container'] = [ -// 'arguments' => [ -// 'data' => [ -// 'config' => [ -// 'formElement' => 'container', -// 'componentType' => 'container', -// 'component' => 'Magento_Catalog/js/components/visible-on-option', -// 'valuesForOptions' => [ -// 'select', -// 'multiselect' -// ] -// ] -// ] -// ], -// 'children' => [ -// 'attribute_options' => [ -// 'arguments' => [ -// 'data' => [ -// 'config' => [ -// 'componentType' => 'dynamicRows', -// 'dataScope' => 'attribute_options', -// 'addButtonLabel' => __('Add Value') -// ] -// ] -// ], -// 'children' => [ -// 'record' => [ -// 'arguments' => [ -// 'data' => [ -// 'config' => [ -// 'componentType' => 'container', -// 'isTemplate' => true, -// 'is_collection' => true, -// 'component' => 'Magento_Ui/js/dynamic-rows/record', -// 'positionProvider' => 'attribute_options.position' -// ], -// ], -// ], -// 'children' => [ -// 'is_default' => [ -// 'arguments' => [ -// 'data' => [ -// 'config' => [ -// 'componentType' => 'field', -// 'dataType' => Form\Element\DataType\Boolean::NAME, -// 'formElement' => Form\Element\Checkbox::NAME, -// 'label' => __('Is Default'), -// 'dataScope' => 'is_default', -// 'prefer' => 'radio', -// 'value' => '1', -// 'sortOrder' => 10, -// ], -// ], -// ], -// ], -// 'options[0]' => [ -// 'arguments' => [ -// 'data' => [ -// 'config' => [ -// 'componentType' => Form\Field::NAME, -// 'dataType' => Form\Element\DataType\Text::NAME, -// 'dataScope' => 'option[0]', -// 'formElement' => Form\Element\Input::NAME, -// 'label' => __('Default Store View'), -// 'sortOrder' => 20, -// ] -// ] -// ] -// ], -// 'options[1]' => [ -// 'arguments' => [ -// 'data' => [ -// 'config' => [ -// 'componentType' => Form\Field::NAME, -// 'dataType' => Form\Element\DataType\Text::NAME, -// 'dataScope' => 'options[1]', -// 'formElement' => Form\Element\Input::NAME, -// 'label' => __('Admin'), -// 'sortOrder' => 30, -// ] -// ] -// ] -// ], -// 'position' => [ -// 'arguments' => [ -// 'data' => [ -// 'config' => [ -// 'componentType' => Form\Field::NAME, -// 'dataType' => Form\Element\DataType\Text::NAME, -// 'formElement' => Form\Element\Input::NAME, -// 'dataScope' => 'position', -// 'visible' => false, -// 'additionalClasses' => ['_hidden' => true] -// ], -// ], -// ], -// ], -// 'action_delete' => [ -// 'arguments' => [ -// 'data' => [ -// 'config' => [ -// 'componentType' => 'actionDelete', -// 'dataType' => Form\Element\DataType\Text::NAME, -// 'label' => '', -// 'fit' => true, -// ], -// ], -// ], -// ], -// ] -// ] -// ] -// ] -// ] -// ]; - return $meta; } } diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml index b5a7d15102387..fb97a4d97f75a 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml @@ -100,94 +100,207 @@ - +
+
+ + + Magento_Catalog/js/components/visible-on-option + Values + true + 15 + + + select + multiselect + + + + - container - container - Magento_Catalog/js/components/visible-on-option - - select - multiselect - + dynamicRows + + Add Value - + - dynamicRows - attribute_options - Add Value + true + true + Magento_Ui/js/dynamic-rows/record + container + attribute_options.position + - + - true - true - Magento_Ui/js/dynamic-rows/record - container - attribute_options.position - false + boolean + checkbox + Is Default + is_default + radio + 1 + 0 - - - - boolean - checkbox - Is Default - is_default - radio - 1 - - - - - - - text - input - Default Store View - option[0] - - - - - - - text - input - Admin - option[1] + + + + + text + input + Default Store View + value.option_1 + + + + + + + text + input + Admin + value.option_0 + + + + + + + text + input + position + false + + true - - - - - - text - input - Admin - position - false - - true - + + + + + + + actionDelete + text + true + + + + + +
+ +
+ + + Magento_Catalog/js/components/visible-on-option + Manage Swatch (Values of Your Attribute) + true + 15 + + swatch_text + + + + + + + dynamicRows + text_swatch + Add Swatch + + + + + + true + true + Magento_Ui/js/dynamic-rows/record + container + text_swatch.position + + + + + + + boolean + checkbox + Is Default + defaulttext[] + radio + 1 + 0 + + + + + + + text + input + Swatch + swatchtext.value.option_1 + + + + + + + text + input + Default Store View + optiontext.value.option_1 + + + + + + + text + input + Swatch + swatchtext.value.option_0 + + + + + + + text + input + Admin + optiontext.value.option_0 + + + + + + + text + input + position + false + + true - - - - + + + + + + actionDelete text - true - - - - - + + + + +
diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js b/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js index 3c76eca54d302..3594aacc4702a 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/components/visible-on-option.js @@ -3,16 +3,16 @@ * See COPYING.txt for license details. */ define([ - 'uiCollection' -], function (Group) { + 'Magento_Ui/js/form/components/fieldset' +], function (Fieldset) { 'use strict'; - return Group.extend({ + return Fieldset.extend({ defaults: { valuesForOptions: [], visibilityState: true, imports: { - toggleVisibility: '${ $.parentName }.frontend_input:value' + toggleVisibility: '${ $.parentName }.base_fieldset.frontend_input:value' } }, @@ -23,8 +23,8 @@ define([ }, toggleVisibility: function (selected) { - var isShown = this.visibilityState = selected in this.valuesForOptions; //this.valuesForOptions.indexOf(selected) !== -1; - + var isShown = this.visibilityState = selected in this.valuesForOptions; + this.visible(isShown); this.elems.each(function (child) { child.set('visible', isShown); }); From eee2e5ea0fdc1d13b5e5b71b2b3e15d9eaa26b76 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 19 Feb 2016 18:34:45 +0200 Subject: [PATCH 018/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../templates/catalog/product/edit/super/wizard-ajax.phtml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml index 913c751ddfd49..7bcf0650c5c77 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml @@ -16,4 +16,9 @@ $attributes = $block->getProductAttributes(); 'attributes' => $attributes, 'configurations' => $productMatrix ]); -?> \ No newline at end of file +?> + From 9ed39f9f910df2489d6dd5af71fc3fa3d70de6bd Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 19 Feb 2016 18:34:56 +0200 Subject: [PATCH 019/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../templates/catalog/product/edit/super/wizard.phtml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index f4be2308e0cfa..53a1c4316b61d 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -14,14 +14,7 @@ $attributes = $block->getProductAttributes(); $currencySymbol = $block->getCurrencySymbol(); ?>
- - getVariationWizard([ - 'attributes' => $attributes, - 'configurations' => $productMatrix - ]); - ?> - +
+ diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml index 7bcf0650c5c77..45112badcd1b8 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard-ajax.phtml @@ -7,8 +7,7 @@ // @codingStandardsIgnoreFile /** @var $block \Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Variations\Config\Matrix */ -?> -getProductMatrix(); $attributes = $block->getProductAttributes(); @@ -19,6 +18,8 @@ $attributes = $block->getProductAttributes(); ?> diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index 53a1c4316b61d..787a9df83f0bd 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -22,7 +22,7 @@ $currencySymbol = $block->getCurrencySymbol(); "Magento_Ui/js/core/app": { "components": { "product_form.product_form.configurableModal": { - "component": "Magento_Ui/js/modal/modal-component", + "component": "Magento_ConfigurableProduct/js/components/modal-configurable", "options": {"type": "slide", "title": ""}, "children": { "wizard": { diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js new file mode 100644 index 0000000000000..d36990b15f5e7 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js @@ -0,0 +1,29 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'Magento_Ui/js/modal/modal-component', + 'uiRegistry' +], function (Modal, registry) { + 'use strict'; + + return Modal.extend({ + + /** + * Open modal + */ + 'openModal': function () { + this.trigger('active', true); + var form = registry.get('product_form.product_form'); + form.source.trigger('data.validate'); + var validated = form.source.get('params.invalid'); + //if (!validated && typeof(registry.get('variation-steps-wizard')) !== "undefined") { + if (typeof(registry.get('variation-steps-wizard')) !== "undefined") { + registry.get('variation-steps-wizard').open(); + this._super(); + } + } + }); +}); \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js b/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js index 1d0b583ea40c8..b366232a124c0 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js @@ -184,15 +184,16 @@ define([ this.selectedStep(this.wizard.prev()); }, open: function () { - require('uiRegistry').get('product_form.product_form').validate(); - if (!require('uiRegistry').get('product_form.product_form').source.get('params.invalid')) { + //require('uiRegistry').get('product_form.product_form').validate(); + //if (!require('uiRegistry').get('product_form.product_form').source.get('params.invalid')) { this.selectedStep(this.stepsNames.first()); this.wizard = new Wizard(this.steps); - $('[data-role=step-wizard-dialog]').trigger('openModal'); - } + //$('[data-role=step-wizard-dialog]').trigger('openModal'); + //} }, close: function () { - $('[data-role=step-wizard-dialog]').trigger('closeModal'); + //$('[data-role=step-wizard-dialog]').trigger('closeModal'); + require('uiRegistry').get('product_form.product_form.configurableModal').closeModal(); }, showSpecificStep: function () { var index = _.indexOf(this.stepsNames, event.target.hash.substr(1)), From cbdc121504636954b2022c38a58733bd7de313e1 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Wed, 24 Feb 2016 10:34:45 +0200 Subject: [PATCH 025/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../catalog/product/edit/super/wizard.phtml | 3 +++ .../web/js/components/modal-configurable.js | 20 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index 787a9df83f0bd..54aa5771ee8d3 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -24,6 +24,9 @@ $currencySymbol = $block->getCurrencySymbol(); "product_form.product_form.configurableModal": { "component": "Magento_ConfigurableProduct/js/components/modal-configurable", "options": {"type": "slide", "title": ""}, + "formName": "product_form.product_form", + "isTemplate": false, + "wizardName": "variation-steps-wizard", "children": { "wizard": { "url": "getUrl('catalog/product/wizard', ['id' => $block->getProduct()->getId()]) ?>", diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js index d36990b15f5e7..0407411ba4266 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js @@ -4,25 +4,27 @@ */ define([ - 'Magento_Ui/js/modal/modal-component', - 'uiRegistry' -], function (Modal, registry) { + 'Magento_Ui/js/modal/modal-component' +], function (Modal) { 'use strict'; return Modal.extend({ + defaults: { + modules: { + form: '${ $.formName }', + wizard: '${ $.wizardName }' + } + }, /** * Open modal */ 'openModal': function () { this.trigger('active', true); - var form = registry.get('product_form.product_form'); - form.source.trigger('data.validate'); - var validated = form.source.get('params.invalid'); - //if (!validated && typeof(registry.get('variation-steps-wizard')) !== "undefined") { - if (typeof(registry.get('variation-steps-wizard')) !== "undefined") { - registry.get('variation-steps-wizard').open(); + this.form().validate(); + if (this.form().source.get('params.invalid') === false) { this._super(); + this.wizard().open(); } } }); From 88264b6143c0e70aa3237dc95e5ddc444f64bb94 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Wed, 24 Feb 2016 10:44:11 +0200 Subject: [PATCH 026/278] MAGETWO-49382: Refactor service layer --- .../Controller/Adminhtml/Product/AddAttributeToTemplate.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php index 849e6854f9773..6e1e9df7cc61e 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php @@ -76,6 +76,7 @@ class AddAttributeToTemplate extends \Magento\Catalog\Controller\Adminhtml\Produ * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param SortOrderBuilder $sortOrderBuilder * @param AttributeManagementInterface $attributeManagement + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Backend\App\Action\Context $context, From 22876c1815ab0d5f67e5872ff7a1a66856435dbc Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Wed, 24 Feb 2016 11:14:28 +0200 Subject: [PATCH 027/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../view/adminhtml/web/js/components/modal-configurable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js index 0407411ba4266..005683b0522e8 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js @@ -12,7 +12,7 @@ define([ defaults: { modules: { form: '${ $.formName }', - wizard: '${ $.wizardName }' + targetWizard: '${ $.wizardName }' } }, @@ -24,7 +24,7 @@ define([ this.form().validate(); if (this.form().source.get('params.invalid') === false) { this._super(); - this.wizard().open(); + this.targetWizard().open(); } } }); From dcf6a786b8e5fc63ff3f3a630f79e7b50909676c Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Wed, 24 Feb 2016 11:15:02 +0200 Subject: [PATCH 028/278] MAGETWO-47227: Add Step Wizard as Modal component --- app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js b/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js index b366232a124c0..c2be0ea41f381 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js @@ -184,15 +184,10 @@ define([ this.selectedStep(this.wizard.prev()); }, open: function () { - //require('uiRegistry').get('product_form.product_form').validate(); - //if (!require('uiRegistry').get('product_form.product_form').source.get('params.invalid')) { - this.selectedStep(this.stepsNames.first()); - this.wizard = new Wizard(this.steps); - //$('[data-role=step-wizard-dialog]').trigger('openModal'); - //} + this.selectedStep(this.stepsNames.first()); + this.wizard = new Wizard(this.steps); }, close: function () { - //$('[data-role=step-wizard-dialog]').trigger('closeModal'); require('uiRegistry').get('product_form.product_form.configurableModal').closeModal(); }, showSpecificStep: function () { From e32c0de84166717e7a7cca9dd0faf7536c15d838 Mon Sep 17 00:00:00 2001 From: vpaladiychuk Date: Wed, 24 Feb 2016 13:19:50 +0200 Subject: [PATCH 029/278] MAGETWO-47246: Add Attribute and Attributes Panel --- .../Product/Form/Modifier/Attributes.php | 211 ++++++++++-------- .../product_attribute_add_form.xml | 1 + .../components/attributes-insert-listing.js | 1 + 3 files changed, 121 insertions(+), 92 deletions(-) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php index ea2624b67154d..53f55d4ca7599 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php @@ -85,22 +85,24 @@ public function modifyMeta(array $meta) return $meta; } - $general = $this->getGeneralPanelName($meta); - - if (!isset($meta[static::GROUP_CODE])) { - $meta[static::GROUP_CODE]['arguments']['data']['config'] = [ - 'label' => __('Attributes'), - 'collapsible' => true, - 'dataScope' => self::DATA_SCOPE_PRODUCT, - 'sortOrder' => $this->getNextGroupSortOrder($meta, $general, static::GROUP_SORT_ORDER), - 'componentType' => Component\Form\Fieldset::NAME - ]; + if (isset($meta[static::GROUP_CODE])) { + $meta[static::GROUP_CODE]['arguments']['data']['config']['component'] = + 'Magento_Catalog/js/components/attributes-fieldset'; } - $meta[static::GROUP_CODE]['arguments']['data']['config']['component'] = - 'Magento_Catalog/js/components/attributes-fieldset'; - $meta[static::GROUP_CODE]['arguments']['data']['config']['visible'] = - !empty($meta[static::GROUP_CODE]['children']); + $meta = $this->customizeAddAttributeModal($meta); + $meta = $this->customizeCreateAttributeModal($meta); + $meta = $this->customizeAttributesGrid($meta); + + return $meta; + } + + /** + * @param array $meta + * @return array + */ + private function customizeAddAttributeModal(array $meta) + { $meta['add_attribute_modal']['arguments']['data']['config'] = [ 'isTemplate' => false, 'componentType' => Component\Modal::NAME, @@ -179,95 +181,120 @@ public function modifyMeta(array $meta) ], ], ], - 'create_new_attribute_modal' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'isTemplate' => false, - 'componentType' => Component\Modal::NAME, - 'dataScope' => '', - 'provider' => 'product_form.product_form_data_source', - 'options' => [ - 'title' => __('New Attribute') - ], - ] + ]; + return $meta; + } + + /** + * @param array $meta + * @return array + */ + private function customizeCreateAttributeModal(array $meta) + { + $params = [ + 'group' => $this->getGeneralPanelName($meta), + 'store' => $this->locator->getStore()->getId(), + 'product' => $this->locator->getProduct()->getId(), + 'type' => $this->locator->getProduct()->getTypeId(), + 'popup' => 1 + ]; + + $meta['add_attribute_modal']['children']['create_new_attribute_modal'] = [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'isTemplate' => false, + 'componentType' => Component\Modal::NAME, + 'dataScope' => '', + 'provider' => 'product_form.product_form_data_source', + 'options' => [ + 'title' => __('New Attribute') + ], ] - ], - 'children' => [ - 'product_attribute_add_form' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'label' => __('New Attribute'), - 'componentType' => Component\Container::NAME, - 'component' => 'Magento_Ui/js/form/components/insert-form', - 'dataScope' => '', - 'update_url' => $this->urlBuilder->getUrl('mui/index/render'), - 'render_url' => $this->urlBuilder->getUrl( - 'mui/index/render_handle', - [ - 'handle' => 'catalog_product_attribute_edit_form', - 'buttons' => 1 - ] - ), - 'autoRender' => false, - 'ns' => 'product_attribute_add_form', - 'externalProvider' => 'product_attribute_add_form' - . '.product_attribute_add_form_data_source', - 'toolbarContainer' => '${ $.parentName }', - 'formSubmitType' => 'ajax', - 'group' => $this->urlBuilder->getUrl( - 'catalog/product_attribute/save', - [ - 'group' => $this->getGeneralPanelName($meta) - ] - ), - 'exports' => [ - 'group' => '${ $.externalProvider }:client.urls.save' + ] + ], + 'children' => [ + 'product_attribute_add_form' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'label' => __('New Attribute'), + 'componentType' => Component\Container::NAME, + 'component' => 'Magento_Ui/js/form/components/insert-form', + 'dataScope' => '', + 'update_url' => $this->urlBuilder->getUrl('mui/index/render'), + 'render_url' => $this->urlBuilder->getUrl( + 'mui/index/render_handle', + [ + 'handle' => 'catalog_product_attribute_edit_form', + 'buttons' => 1 ] + ), + 'autoRender' => false, + 'ns' => 'product_attribute_add_form', + 'externalProvider' => 'product_attribute_add_form' + . '.product_attribute_add_form_data_source', + 'toolbarContainer' => '${ $.parentName }', + 'formSubmitType' => 'ajax', + 'saveUrl' => $this->urlBuilder->getUrl('catalog/product_attribute/save', $params), + 'validateUrl' => $this->urlBuilder->getUrl( + 'catalog/product_attribute/validate', + $params + ), + 'exports' => [ + 'saveUrl' => '${ $.externalProvider }:client.urls.save', + 'validateUrl' => '${ $.externalProvider }:client.urls.beforeSave' ] ] ] ] ] - ], - 'product_attributes_grid' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'component' => 'Magento_Catalog/js/components/attributes-insert-listing', - 'componentType' => Component\Container::NAME, - 'autoRender' => false, - 'dataScope' => 'product_attributes_grid', - 'externalProvider' => 'product_attributes_grid.product_attributes_grid_data_source', - 'selectionsProvider' => '${ $.ns }.${ $.ns }.product_attributes_columns.ids', - 'ns' => 'product_attributes_grid', - 'render_url' => $this->urlBuilder->getUrl('mui/index/render'), - 'immediateUpdateBySelection' => true, - 'behaviourType' => 'edit', - 'externalFilterMode' => true, - 'dataLinks' => ['imports' => false, 'exports' => true], - 'formProvider' => 'ns = ${ $.namespace }, index = product_form', - 'groupCode' => static::GROUP_CODE, - 'groupName' => static::GROUP_NAME, - 'groupSortOrder' => static::GROUP_SORT_ORDER, - 'addAttributeUrl' => - $this->urlBuilder->getUrl('catalog/product/addAttributeToTemplate'), - 'productId' => $this->locator->getProduct()->getId(), - 'productType' => $this->locator->getProduct()->getTypeId(), - 'loading' => false, - 'imports' => [ - 'attributeSetId' => '${ $.provider }:data.product.attribute_set_id' - ], - 'exports' => [ - 'attributeSetId' => '${ $.externalProvider }:params.template_id' - ] + ] + ]; + return $meta; + } + + /** + * @param array $meta + * @return array + */ + private function customizeAttributesGrid(array $meta) + { + $meta['add_attribute_modal']['children']['product_attributes_grid'] = [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'component' => 'Magento_Catalog/js/components/attributes-insert-listing', + 'componentType' => Component\Container::NAME, + 'autoRender' => false, + 'dataScope' => 'product_attributes_grid', + 'externalProvider' => 'product_attributes_grid.product_attributes_grid_data_source', + 'selectionsProvider' => '${ $.ns }.${ $.ns }.product_attributes_columns.ids', + 'ns' => 'product_attributes_grid', + 'render_url' => $this->urlBuilder->getUrl('mui/index/render'), + 'immediateUpdateBySelection' => true, + 'behaviourType' => 'edit', + 'externalFilterMode' => true, + 'dataLinks' => ['imports' => false, 'exports' => true], + 'formProvider' => 'ns = ${ $.namespace }, index = product_form', + 'groupCode' => static::GROUP_CODE, + 'groupName' => static::GROUP_NAME, + 'groupSortOrder' => static::GROUP_SORT_ORDER, + 'addAttributeUrl' => + $this->urlBuilder->getUrl('catalog/product/addAttributeToTemplate'), + 'productId' => $this->locator->getProduct()->getId(), + 'productType' => $this->locator->getProduct()->getTypeId(), + 'loading' => false, + 'imports' => [ + 'attributeSetId' => '${ $.provider }:data.product.attribute_set_id' ], + 'exports' => [ + 'attributeSetId' => '${ $.externalProvider }:params.template_id' + ] ], ], - ], + ] ]; - return $meta; } } diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml index df6735568abbf..6d2f04f70f8b9 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml @@ -35,6 +35,7 @@ + diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/components/attributes-insert-listing.js b/app/code/Magento/Catalog/view/adminhtml/web/js/components/attributes-insert-listing.js index 5b371881aea02..248ec751babd7 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/components/attributes-insert-listing.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/components/attributes-insert-listing.js @@ -68,6 +68,7 @@ define([ }; this.form().reload(); this.modal().state(false); + this.reload(); }.bind(this) }); } From 0a2dce2b0d33ae56cf960b49c8b92e01d532b37b Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 24 Feb 2016 15:15:41 +0200 Subject: [PATCH 030/278] MAGETWO-49680: Implement import of products from wizard and grid to dynamic rows --- .../Form/Modifier/AbstractModifier.php | 1 + .../Product/Form/Modifier/Configurable.php | 216 +++++++++++++----- ...onfigurable_associated_product_listing.xml | 9 + .../components/dynamic-rows-configurable.js | 192 ++++++++++++++++ 4 files changed, 363 insertions(+), 55 deletions(-) create mode 100644 app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AbstractModifier.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AbstractModifier.php index 2b1758e758991..ca8de41a83614 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AbstractModifier.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AbstractModifier.php @@ -15,6 +15,7 @@ */ abstract class AbstractModifier implements ModifierInterface { + const FORM_NAME = 'product_form'; const DATA_SOURCE_DEFAULT = 'product'; const DATA_SCOPE_PRODUCT = 'data.product'; diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php index 2d85d26176b8a..823c5c639b45b 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -9,8 +9,11 @@ use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier; use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType; use Magento\Catalog\Model\Product\Type; +use Magento\Ui\Component\Container; use Magento\Ui\Component\Form; use Magento\Ui\Component\DynamicRows; +use Magento\Ui\Component\Modal; +use Magento\Framework\UrlInterface; /** * Data provider for Configurable products @@ -18,6 +21,8 @@ class Configurable extends AbstractModifier { const GROUP_CONFIGURABLE = 'configurable'; + const ASSOCIATED_PRODUCT_MODAL = 'configurable_associated_product_modal'; + const ASSOCIATED_PRODUCT_LISTING = 'configurable_associated_product_listing'; /** * @var array @@ -43,13 +48,21 @@ class Configurable extends AbstractModifier */ protected $locator; + /** + * @var UrlInterface + */ + protected $urlBuilder; + /** * @param LocatorInterface $locator + * @param UrlInterface $urlBuilder */ public function __construct( - LocatorInterface $locator + LocatorInterface $locator, + UrlInterface $urlBuilder ) { $this->locator = $locator; + $this->urlBuilder = $urlBuilder; } /** @@ -89,6 +102,63 @@ public function modifyMeta(array $meta) ], 'children' => $this->getPanelChildren(), ], + static::ASSOCIATED_PRODUCT_MODAL => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'componentType' => Modal::NAME, + 'dataScope' => '', + 'provider' => static::FORM_NAME . '.product_form_data_source', + 'options' => [ + 'title' => __('Select Associated Product'), + 'buttons' => [ + [ + 'text' => __('Done'), + 'class' => 'action-primary', + 'actions' => [ + [ + 'targetName' => 'index=' . static::ASSOCIATED_PRODUCT_LISTING, + 'actionName' => 'save' + ], + 'closeModal' + ], + ], + ], + ], + ], + ], + ], + 'children' => [ + static::ASSOCIATED_PRODUCT_LISTING => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'autoRender' => false, + 'componentType' => 'insertListing', + 'dataScope' => static::ASSOCIATED_PRODUCT_LISTING, + 'externalProvider' => static::ASSOCIATED_PRODUCT_LISTING . '.' + . static::ASSOCIATED_PRODUCT_LISTING . '_data_source', + 'selectionsProvider' => static::ASSOCIATED_PRODUCT_LISTING . '.' + . static::ASSOCIATED_PRODUCT_LISTING . '.product_columns.ids', + 'ns' => static::ASSOCIATED_PRODUCT_LISTING, + 'render_url' => $this->urlBuilder->getUrl('mui/index/render'), + 'realTimeLink' => true, + 'behaviourType' => 'simple', + 'externalFilterMode' => true, + 'currentProductId' => $this->locator->getProduct()->getId(), + 'dataLinks' => [ + 'imports' => false, + 'exports' => true + ], +// 'exports' => [ +// 'currentProductId' => '${ $.externalProvider }:params.current_product_id' +// ] + ], + ], + ], + ], + ], + ], ] ); } @@ -104,6 +174,7 @@ public function modifyMeta(array $meta) protected function getPanelChildren() { return [ 'configurable_products_button_set' => $this->getButtonSet(), + 'variations-matrix' => $this->getGrid(), ]; } @@ -131,6 +202,32 @@ protected function getButtonSet() ], ], 'children' => [ + 'add_products_manually_button' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'formElement' => 'container', + 'componentType' => 'container', + 'component' => 'Magento_Ui/js/form/components/button', + 'displayAsLink' => true, + 'actions' => [ + [ + 'targetName' => 'ns=' . static::FORM_NAME . ', index=' + . static::ASSOCIATED_PRODUCT_MODAL, + 'actionName' => 'openModal', + ], + [ + 'targetName' => 'ns=' . static::ASSOCIATED_PRODUCT_LISTING + . ', index=' . static::ASSOCIATED_PRODUCT_LISTING, + 'actionName' => 'render', + ], + ], + 'title' => __('Add Products Manually'), + 'sortOrder' => 10, + ], + ], + ], + ], 'create_configurable_products_button' => [ 'arguments' => [ 'data' => [ @@ -152,11 +249,11 @@ protected function getButtonSet() ], ], 'title' => __('Create Configurations'), + 'sortOrder' => 20, ], ], ], ], - //'variations' => $this->getGrid(), ], ]; } @@ -174,23 +271,27 @@ protected function getGrid() 'config' => [ 'additionalClasses' => 'admin__field-wide', 'componentType' => DynamicRows::NAME, + 'dndConfig' => [ + 'enabled' => false, + ], 'label' => __('Current Variations'), - 'renderDefaultRecord' => true, + 'renderDefaultRecord' => false, 'template' => 'ui/dynamic-rows/templates/grid', - 'component' => 'Magento_Ui/js/dynamic-rows/dynamic-rows-grid', + 'component' => 'Magento_ConfigurableProduct/js/components/dynamic-rows-configurable', 'addButton' => false, 'itemTemplate' => 'record', - 'dataScope' => 'data.links', - 'deleteButtonLabel' => __('Remove'), - 'dataProvider' => 'grouped_product_listing', + 'dataScope' => 'data', + 'dataProviderFromGrid' => static::ASSOCIATED_PRODUCT_LISTING, 'map' => [ 'id' => 'entity_id', 'name' => 'name', + 'sku' => 'sku', + 'price' => 'price', ], - 'links' => ['insertData' => '${ $.provider }:${ $.dataProvider }'], + 'links' => ['insertDataFromGrid' => '${$.provider}:${$.dataProviderFromGrid}'], 'sortOrder' => 20, 'columnsHeader' => true, - 'columnsHeaderAfterRender' => false, + 'columnsHeaderAfterRender' => true, ], ], ], @@ -210,8 +311,8 @@ protected function getRows() 'arguments' => [ 'data' => [ 'config' => [ - 'componentType' => 'container', - 'isTemplate' => false, + 'componentType' => Container::NAME, + 'isTemplate' => true, 'is_collection' => true, 'component' => 'Magento_Ui/js/dynamic-rows/record', 'dataScope' => '', @@ -219,52 +320,57 @@ protected function getRows() ], ], 'children' => [ - 'id' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'dataType' => Form\Element\DataType\Number::NAME, - 'formElement' => Form\Element\Input::NAME, - 'componentType' => Form\Field::NAME, - 'dataScope' => 'qty', - 'label' => __('Default Quantity'), - 'fit' => true, - 'additionalClasses' => 'admin__field-small', - 'sortOrder' => 80, - ], - ], - ], - ], - 'actionDelete' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'additionalClasses' => 'data-grid-actions-cell', - 'componentType' => 'actionDelete', - 'dataType' => Form\Element\DataType\Text::NAME, - 'label' => __('Actions'), - 'sortOrder' => 90, - 'fit' => true, - ], - ], - ], - ], - 'position' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'dataType' => Form\Element\DataType\Number::NAME, - 'formElement' => Form\Element\Input::NAME, - 'componentType' => Form\Field::NAME, - 'dataScope' => 'position', - 'sortOrder' => 100, - 'visible' => false, - ], - ], - ], - ], + 'name_container' => $this->getColumn('name', __('Name'), 'name'), + 'sku_container' => $this->getColumn('sku', __('SKU'), 'sku'), + 'price_container' => $this->getColumn('price', __('Price'), 'price'), + //'quantity_container' => $this->getColumn('quantity', __('Quantity'), 'quantity'), ], ], ]; } + + /** + * @param string $name + * @param \Magento\Framework\Phrase $label + * @param string $dataScope + * @return array + */ + protected function getColumn($name, \Magento\Framework\Phrase $label, $dataScope = '') + { + $fieldEdit['arguments']['data']['config'] = [ + 'dataType' => Form\Element\DataType\Number::NAME, + 'formElement' => Form\Element\Input::NAME, + 'componentType' => Form\Field::NAME, + 'dataScope' => $dataScope, + 'fit' => true, + 'additionalClasses' => 'admin__field-small', + 'imports' => [ + 'visible' => '${$.provider}:${$.parentScope}.canEdit', + ], + ]; + $fieldText['arguments']['data']['config'] = [ + 'componentType' => Form\Field::NAME, + 'formElement' => Form\Element\Input::NAME, + 'elementTmpl' => 'ui/dynamic-rows/cells/text', + 'dataType' => Form\Element\DataType\Text::NAME, + 'dataScope' => $dataScope, + 'imports' => [ + 'visible' => '!${$.provider}:${$.parentScope}.canEdit', + ], + ]; + $container['arguments']['data']['config'] = [ + 'additionalClasses' => 'admin__field', + 'componentType' => Container::NAME, + 'formElement' => Container::NAME, + 'component' => 'Magento_Ui/js/form/components/group', + 'label' => $label, + 'dataScope' => '', + ]; + $container['children'] = [ + $name . '_edit' => $fieldEdit, + $name . '_text' => $fieldText, + ]; + + return $container; + } } \ No newline at end of file diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml index e57b11e84072b..6050c60f680af 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml @@ -141,5 +141,14 @@ + + + + textRange + true + Quantity + + + diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js new file mode 100644 index 0000000000000..97cc7feab2776 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js @@ -0,0 +1,192 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'underscore', + 'Magento_Ui/js/dynamic-rows/dynamic-rows' +], function (_, dynamicRows) { + 'use strict'; + + return dynamicRows.extend({ + defaults: { + canEditField: 'canEdit', + dataProviderFromGrid: '', + insertDataFromGrid: [], + map: null, + cacheGridData: [], + deleteProperty: false, + dataLength: 0, + identificationProperty: 'id', + listens: { + 'insertDataFromGrid': 'processingInsertData', + 'elems': 'mappingValue' + } + }, + + /** + * Calls 'initObservable' of parent + * + * @returns {Object} Chainable. + */ + initObservable: function () { + this._super() + .observe([ + 'insertDataFromGrid' + ]); + + return this; + }, + + /** + * Initialize children, + * set data from server to grid dataScope + */ + initChildren: function () { + var insertData = []; + + if (this.recordData().length) { + this.recordData.each(function (recordData) { + var unmappingValue = this.unmappingValue(recordData); + unmappingValue[this.canEditField] = false; + insertData.push(unmappingValue); + }, this); + + this.source.set(this.dataProviderFromGrid, insertData); + } + + return this; + }, + + /** + * Unmapping value, + * unmapping data from server to grid dataScope + * + * @param {Object} data - data object + */ + unmappingValue: function (data) { + var obj = {}; + + _.each(this.map, function (prop, index) { + obj[prop] = data[index]; + }, this); + + return obj; + }, + + /** + * Rerender dynamic-rows elems + */ + reload: function () { + this.cacheGridData = []; + this._super(); + }, + + /** + * Parsed data + * + * @param {Array} data - array with data + * about selected records + */ + processingInsertData: function (data) { + var changes; + + if (!data.length) { + this.elems([]); + } + + changes = this._checkGridData(data); + this.cacheGridData = data; + + changes.each(function (changedObject) { + this.addChild(changedObject, false, parseInt(changedObject[this.map.id], 10)); + }, this); + }, + + /** + * Delete record instance + * update data provider dataScope + * + * @param {String|Number} index - record index + */ + deleteRecord: function (index, recordId) { + var data = this.getElementData(this.insertDataFromGrid(), recordId); + + this.mapping = true; + this._super(); + this.insertDataFromGrid(_.reject(this.source.get(this.dataProviderFromGrid), function (recordData) { + return parseInt(recordData[this.map.id], 10) === parseInt(data[this.map.id], 10); + }, this)); + this.mapping = false; + }, + + /** + * Check changed records + * + * @param {Array} data - array with records data + * @returns {Array} Changed records + */ + _checkGridData: function (data) { + var cacheLength = this.cacheGridData.length, + curData = data.length, + max = cacheLength > curData ? this.cacheGridData : data, + changes = [], + obj = {}; + + max.each(function (record, index) { + obj[this.map.id] = record[this.map.id]; + + if (!_.where(this.cacheGridData, obj).length) { + changes.push(data[index]); + } + }, this); + + return changes; + }, + + /** + * Mapped value + */ + mappingValue: function () { + var path, + data, + elements = this.elems(); + + if (this.mapping) { + return false; + } + + elements.each(function (record) { + data = this.getElementData(this.insertDataFromGrid(), record.recordId); + _.each(this.map, function (prop, index) { + path = record.dataScope + '.' + index; + this.source.set(path, data[prop]); + }, this); + path = record.dataScope + '.' + this.canEditField; + this.source.set(path, false); + }, this); + }, + + /** + * Find data object by index + * + * @param {Array} array - data collection + * @param {Number} index - element index + * @param {String} property - to find by property + * + * @returns {Object} data object + */ + getElementData: function (array, index, property) { + var obj = {}, + result; + + property ? obj[property] = index : obj[this.map.id] = index; + result = _.findWhere(array, obj); + !result ? property ? obj[property] = index.toString() : obj[this.map.id] = index.toString() : false; + result = _.findWhere(array, obj); + + return result; + } + }); +}); From 31dc513ed250e864f7e4289d9603e25b73162992 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Wed, 24 Feb 2016 15:18:15 +0200 Subject: [PATCH 031/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../view/adminhtml/web/js/components/modal-configurable.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js index 005683b0522e8..a1ff27d39c564 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/modal-configurable.js @@ -15,14 +15,13 @@ define([ targetWizard: '${ $.wizardName }' } }, - + /** * Open modal */ 'openModal': function () { - this.trigger('active', true); this.form().validate(); - if (this.form().source.get('params.invalid') === false) { + if (this.form().source.get('params.invalid') === false && this.targetWizard()) { this._super(); this.targetWizard().open(); } From c93a3b761acc2702c3b3496a273d63236e0ac374 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Wed, 24 Feb 2016 15:55:33 +0200 Subject: [PATCH 032/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../templates/catalog/product/edit/super/wizard.phtml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index 54aa5771ee8d3..7fd4dc4672f29 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -16,6 +16,9 @@ $currencySymbol = $block->getCurrencySymbol();
+
+
+
\ No newline at end of file From 41407e7620ea3c586dd65f70dff14c60d0e01d26 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Wed, 24 Feb 2016 16:18:29 +0200 Subject: [PATCH 033/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../Catalog/view/adminhtml/web/js/product-gallery.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js b/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js index 36038fce6c20b..0b969dab0262f 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js @@ -383,7 +383,11 @@ define([ this.dialogTmpl = mageTemplate(template.html().trim()); } - this.dialogContainerTmpl = mageTemplate(containerTmpl.html().trim()); + if (containerTmpl.length) { + this.dialogContainerTmpl = mageTemplate(containerTmpl.html().trim()); + } else { + this.dialogContainerTmpl = mageTemplate(''); + } this._initDialog(); }, From f606f8d56246598039101b97d6919e186beca342 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Wed, 24 Feb 2016 17:05:19 +0200 Subject: [PATCH 034/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../view/adminhtml/web/js/variations/steps/summary.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summary.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summary.js index 0a1088393c04f..21bc87888852a 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summary.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summary.js @@ -15,7 +15,8 @@ define([ return Component.extend({ defaults: { modules: { - variationsComponent: '${ $.variationsComponent }' + variationsComponent: '${ $.variationsComponent }', + modalComponent: '${ $.modalComponent }' }, notificationMessage: { text: null, @@ -159,7 +160,7 @@ define([ }, force: function () { this.variationsComponent().render(this.variations, this.attributes()); - $('[data-role=step-wizard-dialog]').trigger('closeModal'); + this.modalComponent().closeModal(); }, back: function () { } From cfd49c2112b58f7bb0dee2390405879cb0472a7c Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Wed, 24 Feb 2016 17:08:26 +0200 Subject: [PATCH 035/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../catalog/product/edit/attribute/steps/summary.phtml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/attribute/steps/summary.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/attribute/steps/summary.phtml index a93fcf5837519..63a30db901acf 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/attribute/steps/summary.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/attribute/steps/summary.phtml @@ -49,7 +49,8 @@ "getComponentName()?>": { "component": "Magento_ConfigurableProduct/js/variations/steps/summary", "appendTo": "getParentComponentName()?>", - "variationsComponent": "configurableVariations" + "variationsComponent": "configurableVariations", + "modalComponent": "product_form.product_form.configurableModal" } } } From 6bb13c7b21b69ab27c2980bb2f8f1284c87ac563 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 24 Feb 2016 17:12:21 +0200 Subject: [PATCH 036/278] MAGETWO-49680: Implement import of products from wizard and grid to dynamic rows --- .../Product/Form/Modifier/Configurable.php | 10 ++++--- .../web/js/components/field-configurable.js | 26 +++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/field-configurable.js diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php index 823c5c639b45b..4f881f6ce5605 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -287,6 +287,7 @@ protected function getGrid() 'name' => 'name', 'sku' => 'sku', 'price' => 'price', + 'quantity_and_stock_status.qty' => 'qty' ], 'links' => ['insertDataFromGrid' => '${$.provider}:${$.dataProviderFromGrid}'], 'sortOrder' => 20, @@ -323,7 +324,7 @@ protected function getRows() 'name_container' => $this->getColumn('name', __('Name'), 'name'), 'sku_container' => $this->getColumn('sku', __('SKU'), 'sku'), 'price_container' => $this->getColumn('price', __('Price'), 'price'), - //'quantity_container' => $this->getColumn('quantity', __('Quantity'), 'quantity'), + 'quantity_container' => $this->getColumn('quantity', __('Quantity'), 'quantity_and_stock_status.qty'), ], ], ]; @@ -338,6 +339,7 @@ protected function getRows() protected function getColumn($name, \Magento\Framework\Phrase $label, $dataScope = '') { $fieldEdit['arguments']['data']['config'] = [ + 'component' => 'Magento_ConfigurableProduct/js/components/field-configurable', 'dataType' => Form\Element\DataType\Number::NAME, 'formElement' => Form\Element\Input::NAME, 'componentType' => Form\Field::NAME, @@ -345,17 +347,19 @@ protected function getColumn($name, \Magento\Framework\Phrase $label, $dataScope 'fit' => true, 'additionalClasses' => 'admin__field-small', 'imports' => [ - 'visible' => '${$.provider}:${$.parentScope}.canEdit', + 'parentComponentScope' => '${$.parentName}:dataScope', ], ]; $fieldText['arguments']['data']['config'] = [ + 'component' => 'Magento_ConfigurableProduct/js/components/field-configurable', 'componentType' => Form\Field::NAME, 'formElement' => Form\Element\Input::NAME, 'elementTmpl' => 'ui/dynamic-rows/cells/text', 'dataType' => Form\Element\DataType\Text::NAME, 'dataScope' => $dataScope, 'imports' => [ - 'visible' => '!${$.provider}:${$.parentScope}.canEdit', + 'parentComponentScope' => '${$.parentName}:dataScope', + //'visible' => '!${$.provider}:${$.someData}.canEdit', ], ]; $container['arguments']['data']['config'] = [ diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/field-configurable.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/field-configurable.js new file mode 100644 index 0000000000000..a37b5d6fd8cae --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/field-configurable.js @@ -0,0 +1,26 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'uiRegistry', + 'Magento_Ui/js/form/element/abstract' +], function (registry, Abstract) { + 'use strict'; + + return Abstract.extend({ + defaults: { + parentComponentScope: '', + canEditField: 'canEdit', + listens: { + 'parentComponentScope': 'setVisibility' + } + }, + + setVisibility: function (parentScope) { + var canEdit = registry.get(this.provider + ':' + parentScope + '.' + this.canEditField); + //this.visible(canEdit); + } + }); +}); From c36eb72a0fb0de4e5336f64529eddfd9777f5bf1 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Wed, 24 Feb 2016 18:06:08 +0200 Subject: [PATCH 037/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../view/adminhtml/web/js/variations/variations.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index f05e524439af5..4e035d722f1e4 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -29,20 +29,23 @@ define([ fullAttributes: [], rowIndexToEdit: false, productAttributesMap: null, + value: {}, modules: { associatedProductGrid: '${ $.configurableProductGrid }' + }, + links: { + value: '${ $.provider }:${ $.dataScope }' } }, initialize: function () { this._super(); - if (this.variations.length) { this.render(this.variations, this.productAttributes); } this.initProductAttributesMap(); }, initObservable: function () { - this._super().observe('actions opened attributes productMatrix'); + this._super().observe('actions opened attributes productMatrix value'); return this; }, @@ -169,11 +172,16 @@ define([ this.initImageUpload(); this.disableConfigurableAttributes(attributes); this.showPrice(); + this.handleValue(); }, changeButtonWizard: function () { var $button = $('[data-action=open-steps-wizard] [data-role=button-label]'); $button.text($button.attr('data-edit-label')); }, + handleValue: function () { + this.value = {}; + }, + /** * Get attributes options From 19a304d4cbb9b931abff22c7a57370e410f52c1f Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Wed, 24 Feb 2016 18:07:17 +0200 Subject: [PATCH 038/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../adminhtml/templates/catalog/product/edit/super/wizard.phtml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index 7fd4dc4672f29..55916762c528d 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -39,6 +39,8 @@ $currencySymbol = $block->getCurrencySymbol(); }, "configurableVariations": { "component": "Magento_ConfigurableProduct/js/variations/variations", + "provider": "product_form.product_form_data_source", + "dataScope": "data.variations", "variations": helper('Magento\Framework\Json\Helper\Data')->jsonEncode($productMatrix) ?>, "productAttributes": helper('Magento\Framework\Json\Helper\Data')->jsonEncode($attributes) ?>, "productUrl": "getUrl('catalog/product/edit', ['id' => '%id%']) ?>", From 97d8dbf06be79e09f5a276693d59f961bdd98c9e Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 24 Feb 2016 18:28:17 +0200 Subject: [PATCH 039/278] MAGETWO-49680: Implement import of products from wizard and grid to dynamic rows --- .../Product/Form/Modifier/Configurable.php | 3 ++- .../configurable_associated_product_listing.xml | 9 +++++++++ .../web/js/components/field-configurable.js | 15 +++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php index 4f881f6ce5605..97bc8348d92ed 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -346,6 +346,7 @@ protected function getColumn($name, \Magento\Framework\Phrase $label, $dataScope 'dataScope' => $dataScope, 'fit' => true, 'additionalClasses' => 'admin__field-small', + 'visibleIfCanEdit' => true, 'imports' => [ 'parentComponentScope' => '${$.parentName}:dataScope', ], @@ -357,9 +358,9 @@ protected function getColumn($name, \Magento\Framework\Phrase $label, $dataScope 'elementTmpl' => 'ui/dynamic-rows/cells/text', 'dataType' => Form\Element\DataType\Text::NAME, 'dataScope' => $dataScope, + 'visibleIfCanEdit' => false, 'imports' => [ 'parentComponentScope' => '${$.parentName}:dataScope', - //'visible' => '!${$.provider}:${$.someData}.canEdit', ], ]; $container['arguments']['data']['config'] = [ diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml index 6050c60f680af..83abf6c5beadf 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml @@ -150,5 +150,14 @@ + + + + text + true + Weight + + + diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/field-configurable.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/field-configurable.js index a37b5d6fd8cae..40b6d289bcc71 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/field-configurable.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/field-configurable.js @@ -4,23 +4,30 @@ */ define([ - 'uiRegistry', 'Magento_Ui/js/form/element/abstract' -], function (registry, Abstract) { +], function (Abstract) { 'use strict'; return Abstract.extend({ defaults: { parentComponentScope: '', canEditField: 'canEdit', + visibleIfCanEdit: true, listens: { 'parentComponentScope': 'setVisibility' } }, + /** + * Set visibility for current component + * + * @param {String} parentScope + */ setVisibility: function (parentScope) { - var canEdit = registry.get(this.provider + ':' + parentScope + '.' + this.canEditField); - //this.visible(canEdit); + var canEdit = this.source.get(parentScope + '.' + this.canEditField); + var visible = this.visibleIfCanEdit ? canEdit : !canEdit; + + this.visible(visible); } }); }); From dc1c5acd149bcf189fb40b71505a846e53ae0c95 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Thu, 25 Feb 2016 13:27:51 +0200 Subject: [PATCH 040/278] MAGETWO-49680: Implement import of products from wizard and grid to dynamic rows --- .../AssociatedProduct/Columns/Name.php | 62 ++++++++++++++++ .../AssociatedProduct/Columns/Price.php | 73 +++++++++++++++++++ .../Product/Form/Modifier/Configurable.php | 60 ++++++++++++--- ...onfigurable_associated_product_listing.xml | 4 +- .../web/template/components/cell-html.html | 13 ++++ 5 files changed, 198 insertions(+), 14 deletions(-) create mode 100644 app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns/Name.php create mode 100644 app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns/Price.php create mode 100644 app/code/Magento/ConfigurableProduct/view/adminhtml/web/template/components/cell-html.html diff --git a/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns/Name.php b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns/Name.php new file mode 100644 index 0000000000000..132f8d960e298 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns/Name.php @@ -0,0 +1,62 @@ +urlBuilder = $urlBuilder; + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return array + */ + public function prepareDataSource(array $dataSource) + { + if (isset($dataSource['data']['items'])) { + $fieldName = $this->getData('name'); + foreach ($dataSource['data']['items'] as & $item) { + if (isset($item[$fieldName]) && isset($item['entity_id'])) { + $url = $this->urlBuilder->getUrl('catalog/product/edit', ['id' => $item['entity_id']]); + $item['product_link'] = '' . $item[$fieldName] . ''; + } + } + } + + return $dataSource; + } +} diff --git a/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns/Price.php b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns/Price.php new file mode 100644 index 0000000000000..c965095964dc5 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns/Price.php @@ -0,0 +1,73 @@ +localeCurrency = $localeCurrency; + $this->storeManager = $storeManager; + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return array + */ + public function prepareDataSource(array $dataSource) + { + if (isset($dataSource['data']['items'])) { + $store = $this->storeManager->getStore( + $this->context->getFilterParam('store_id', \Magento\Store\Model\Store::DEFAULT_STORE_ID) + ); + $currency = $this->localeCurrency->getCurrency($store->getBaseCurrencyCode()); + + $fieldName = $this->getData('name'); + foreach ($dataSource['data']['items'] as & $item) { + if (isset($item[$fieldName])) { + $item['price_number'] = $currency->toCurrency( + sprintf("%f", $item[$fieldName]), + ['display' => false] + ); + $item['price_currency'] = $store->getBaseCurrency()->getCurrencySymbol(); + $item[$fieldName] = $currency->toCurrency(sprintf("%f", $item[$fieldName])); + } + } + } + + return $dataSource; + } +} diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php index 97bc8348d92ed..17cfd39703525 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -284,10 +284,14 @@ protected function getGrid() 'dataProviderFromGrid' => static::ASSOCIATED_PRODUCT_LISTING, 'map' => [ 'id' => 'entity_id', + 'product_link' => 'product_link', 'name' => 'name', 'sku' => 'sku', - 'price' => 'price', - 'quantity_and_stock_status.qty' => 'qty' + 'price' => 'price_number', + 'price_string' => 'price', + 'price_currency' => 'price_currency', + 'quantity_and_stock_status.qty' => 'qty', + 'weight' => 'weight', ], 'links' => ['insertDataFromGrid' => '${$.provider}:${$.dataProviderFromGrid}'], 'sortOrder' => 20, @@ -321,10 +325,29 @@ protected function getRows() ], ], 'children' => [ - 'name_container' => $this->getColumn('name', __('Name'), 'name'), - 'sku_container' => $this->getColumn('sku', __('SKU'), 'sku'), - 'price_container' => $this->getColumn('price', __('Price'), 'price'), - 'quantity_container' => $this->getColumn('quantity', __('Quantity'), 'quantity_and_stock_status.qty'), + 'name_container' => $this->getColumn( + 'name', + __('Name'), + [], + ['dataScope' => 'product_link'] + ), + 'sku_container' => $this->getColumn('sku', __('SKU')), + 'price_container' => $this->getColumn( + 'price', + __('Price'), + [ + 'imports' => ['addbefore' => '${$.provider}:${$.parentScope}.price_currency'], + 'validation' => ['validate-zero-or-greater' => true] + ], + ['dataScope' => 'price_string'] + ), + 'quantity_container' => $this->getColumn( + 'quantity', + __('Quantity'), + ['dataScope' => 'quantity_and_stock_status.qty'], + ['dataScope' => 'quantity_and_stock_status.qty'] + ), + 'price_weight' => $this->getColumn('weight', __('Weight')), ], ], ]; @@ -333,17 +356,22 @@ protected function getRows() /** * @param string $name * @param \Magento\Framework\Phrase $label - * @param string $dataScope + * @param array $editConfig + * @param array $textConfig * @return array */ - protected function getColumn($name, \Magento\Framework\Phrase $label, $dataScope = '') - { + protected function getColumn( + $name, + \Magento\Framework\Phrase $label, + $editConfig = [], + $textConfig = [] + ) { $fieldEdit['arguments']['data']['config'] = [ 'component' => 'Magento_ConfigurableProduct/js/components/field-configurable', 'dataType' => Form\Element\DataType\Number::NAME, 'formElement' => Form\Element\Input::NAME, 'componentType' => Form\Field::NAME, - 'dataScope' => $dataScope, + 'dataScope' => $name, 'fit' => true, 'additionalClasses' => 'admin__field-small', 'visibleIfCanEdit' => true, @@ -355,14 +383,22 @@ protected function getColumn($name, \Magento\Framework\Phrase $label, $dataScope 'component' => 'Magento_ConfigurableProduct/js/components/field-configurable', 'componentType' => Form\Field::NAME, 'formElement' => Form\Element\Input::NAME, - 'elementTmpl' => 'ui/dynamic-rows/cells/text', + 'elementTmpl' => 'Magento_ConfigurableProduct/components/cell-html', 'dataType' => Form\Element\DataType\Text::NAME, - 'dataScope' => $dataScope, + 'dataScope' => $name, 'visibleIfCanEdit' => false, 'imports' => [ 'parentComponentScope' => '${$.parentName}:dataScope', ], ]; + $fieldEdit['arguments']['data']['config'] = array_replace_recursive( + $fieldEdit['arguments']['data']['config'], + $editConfig + ); + $fieldText['arguments']['data']['config'] = array_replace_recursive( + $fieldText['arguments']['data']['config'], + $textConfig + ); $container['arguments']['data']['config'] = [ 'additionalClasses' => 'admin__field', 'componentType' => Container::NAME, diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml index 83abf6c5beadf..dc4d6b5126734 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml @@ -112,7 +112,7 @@ - + text @@ -131,7 +131,7 @@ - + textRange diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/template/components/cell-html.html b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/template/components/cell-html.html new file mode 100644 index 0000000000000..541836b7b74c5 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/template/components/cell-html.html @@ -0,0 +1,13 @@ + +
+ + +
\ No newline at end of file From 9a01a57f7024598b24b44b998b017aa7b53ee052 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Thu, 25 Feb 2016 14:23:39 +0200 Subject: [PATCH 041/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../adminhtml/web/js/variations/variations.js | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index 4e035d722f1e4..d483b9688ddae 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -29,7 +29,7 @@ define([ fullAttributes: [], rowIndexToEdit: false, productAttributesMap: null, - value: {}, + value: [], modules: { associatedProductGrid: '${ $.configurableProductGrid }' }, @@ -166,20 +166,38 @@ define([ option.value + '][' + field + ']'; }, render: function (variations, attributes) { - this.changeButtonWizard(); + //this.changeButtonWizard(); this.populateVariationMatrix(variations); this.attributes(attributes); this.initImageUpload(); this.disableConfigurableAttributes(attributes); this.showPrice(); - this.handleValue(); + this.handleValue(variations); }, changeButtonWizard: function () { var $button = $('[data-action=open-steps-wizard] [data-role=button-label]'); $button.text($button.attr('data-edit-label')); }, - handleValue: function () { - this.value = {}; + handleValue: function (variations) { + this.value([]); + _.each(variations, function (variation) { + var attributes = _.reduce(variation.options, function (memo, option) { + var attribute = {}; + attribute[option['attribute_code']] = option.value; + + return _.extend(memo, attribute); + }, {}); + this.value.push(_.extend(variation, { + productId: variation.productId || null, + name: variation.name || variation.sku, + weight: variation.weight, + attribute: JSON.stringify(attributes), + variationKey: this.getVariationKey(variation.options), + editable: variation.editable === undefined ? !variation.productId : variation.editable, + productUrl: this.buildProductUrl(variation.productId), + status: variation.status === undefined ? 1 : parseInt(variation.status, 10) + })); + }, this); }, From 674fadbbba45a0d0c23538e953b8dd0b7ceda46e Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Thu, 25 Feb 2016 15:45:23 +0200 Subject: [PATCH 042/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../view/adminhtml/web/js/variations/variations.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index d483b9688ddae..24d28fbcb8c1e 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -171,7 +171,7 @@ define([ this.attributes(attributes); this.initImageUpload(); this.disableConfigurableAttributes(attributes); - this.showPrice(); + //this.showPrice(); this.handleValue(variations); }, changeButtonWizard: function () { From 15f86e30a79e8837bf3cf1c2ac59dc898a291c87 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Thu, 25 Feb 2016 15:48:25 +0200 Subject: [PATCH 043/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../adminhtml/templates/catalog/product/edit/super/wizard.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index 55916762c528d..15fcac8478db6 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -40,7 +40,7 @@ $currencySymbol = $block->getCurrencySymbol(); "configurableVariations": { "component": "Magento_ConfigurableProduct/js/variations/variations", "provider": "product_form.product_form_data_source", - "dataScope": "data.variations", + "dataScope": "variations", "variations": helper('Magento\Framework\Json\Helper\Data')->jsonEncode($productMatrix) ?>, "productAttributes": helper('Magento\Framework\Json\Helper\Data')->jsonEncode($attributes) ?>, "productUrl": "getUrl('catalog/product/edit', ['id' => '%id%']) ?>", From c6a62adc6730699b3b8597578b98ccc7996554a0 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Thu, 25 Feb 2016 16:08:35 +0200 Subject: [PATCH 044/278] MAGETWO-49382: Refactor service layer --- .../Adminhtml/Product/AddAttributeToTemplate.php | 11 +++++++---- .../web/js/components/attributes-insert-listing.js | 4 ++-- .../Api/ProductAttributeGroupRepositoryTest.php | 6 +++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php index 6e1e9df7cc61e..7865365b47200 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php @@ -170,9 +170,12 @@ public function execute() '0' ); }); - } catch (\Exception $e) { + } catch (\LocalizedException $e) { $response->setError(true); $response->setMessage($e->getMessage()); + } catch (\Exception $e) { + $response->setError(true); + $response->setMessage(__('Unable to add attribute')); } return $this->resultJsonFactory->create()->setJsonData($response->toJson()); @@ -188,12 +191,12 @@ public function execute() private function addBasicAttributeSearchFilters( SearchCriteriaBuilder $attributeSearchCriteriaBuilder ) { - $attributesIds = (array)$this->getRequest()->getParam('attributesIds', []); + $attributeIds = (array)$this->getRequest()->getParam('attributeIds', []); - if (!empty($attributesIds['selected'])) { + if (!empty($attributeIds['selected'])) { return $attributeSearchCriteriaBuilder->addFilter( 'attribute_id', - [$attributesIds['selected']], + [$attributeIds['selected']], 'in' ); } diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/components/attributes-insert-listing.js b/app/code/Magento/Catalog/view/adminhtml/web/js/components/attributes-insert-listing.js index 5b371881aea02..b99d907d3eca4 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/components/attributes-insert-listing.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/components/attributes-insert-listing.js @@ -15,7 +15,7 @@ define([ defaults: { addAttributeUrl: '', attributeSetId: '', - attributesIds: '', + attributeIds: '', groupCode: '', groupName: '', groupSortOrder: 0, @@ -52,7 +52,7 @@ define([ type: 'POST', dataType: 'json', data: { - attributesIds: this.selections().getSelections(), + attributeIds: this.selections().getSelections(), templateId: this.attributeSetId, groupCode: this.groupCode, groupName: this.groupName, diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeGroupRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeGroupRepositoryTest.php index 26fa6b15e179c..2c867839035d8 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeGroupRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeGroupRepositoryTest.php @@ -165,7 +165,11 @@ protected function createGroupData($attributeSetId) { return [ 'attribute_group_name' => 'empty_attribute_group', - 'attribute_set_id' => $attributeSetId + 'attribute_set_id' => $attributeSetId, + 'sort_order' => 10, + 'default_id' => 5, + 'attribute_group_code' => 'empty_attribute_group', + 'tab_group_code' => 'default_tab', ]; } From da13a4b9244cff2d07832e8dbc7ebe4019b84e5a Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 26 Feb 2016 11:46:43 +0200 Subject: [PATCH 045/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../templates/catalog/product/edit/super/wizard.phtml | 4 +++- .../view/adminhtml/web/js/variations/variations.js | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index 15fcac8478db6..0a7026305c318 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -40,7 +40,9 @@ $currencySymbol = $block->getCurrencySymbol(); "configurableVariations": { "component": "Magento_ConfigurableProduct/js/variations/variations", "provider": "product_form.product_form_data_source", - "dataScope": "variations", + "dataScopeVariations": "variations", + "dataScopeAttributes": "attributes", + "wizardModalButton": "product_form.product_form.configurable.configurable_products_button_set.create_configurable_products_button", "variations": helper('Magento\Framework\Json\Helper\Data')->jsonEncode($productMatrix) ?>, "productAttributes": helper('Magento\Framework\Json\Helper\Data')->jsonEncode($attributes) ?>, "productUrl": "getUrl('catalog/product/edit', ['id' => '%id%']) ?>", diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index 24d28fbcb8c1e..39fb10b3c869e 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -34,7 +34,8 @@ define([ associatedProductGrid: '${ $.configurableProductGrid }' }, links: { - value: '${ $.provider }:${ $.dataScope }' + value: '${ $.provider }:${ $.dataScopeVariations }', + attributes: '${ $.provider }:${ $.dataScopeAttributes }' } }, initialize: function () { @@ -170,7 +171,7 @@ define([ this.populateVariationMatrix(variations); this.attributes(attributes); this.initImageUpload(); - this.disableConfigurableAttributes(attributes); + //this.disableConfigurableAttributes(attributes); //this.showPrice(); this.handleValue(variations); }, @@ -190,6 +191,7 @@ define([ this.value.push(_.extend(variation, { productId: variation.productId || null, name: variation.name || variation.sku, + priceCurrency: this.currencySymbol, weight: variation.weight, attribute: JSON.stringify(attributes), variationKey: this.getVariationKey(variation.options), From a1ea48df729ad4c808d63f1cdcb33e0f691e78cd Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 26 Feb 2016 11:51:34 +0200 Subject: [PATCH 046/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../adminhtml/templates/catalog/product/edit/super/wizard.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index 0a7026305c318..682305158085f 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -41,7 +41,7 @@ $currencySymbol = $block->getCurrencySymbol(); "component": "Magento_ConfigurableProduct/js/variations/variations", "provider": "product_form.product_form_data_source", "dataScopeVariations": "variations", - "dataScopeAttributes": "attributes", + "dataScopeAttributes": "data.attributes", "wizardModalButton": "product_form.product_form.configurable.configurable_products_button_set.create_configurable_products_button", "variations": helper('Magento\Framework\Json\Helper\Data')->jsonEncode($productMatrix) ?>, "productAttributes": helper('Magento\Framework\Json\Helper\Data')->jsonEncode($attributes) ?>, From e762215208415e9364859ca1ba5713041b483944 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Fri, 26 Feb 2016 14:44:21 +0200 Subject: [PATCH 047/278] MAGETWO-49382: Refactor service layer --- .../Product/AddAttributeToTemplate.php | 2 ++ .../Magento/Eav/Model/AttributeProvider.php | 2 +- .../Eav/Model/ResourceModel/CreateHandler.php | 2 +- .../Entity/Attribute/Collection.php | 27 +++++++++++++++++++ .../Eav/Model/ResourceModel/ReadHandler.php | 3 ++- .../Eav/Model/ResourceModel/UpdateHandler.php | 3 ++- .../Db/Collection/AbstractCollection.php | 27 ------------------- 7 files changed, 35 insertions(+), 31 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php index 7865365b47200..da652ca1f6ec1 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php @@ -201,6 +201,8 @@ private function addBasicAttributeSearchFilters( ); } + $attributeSearchCriteriaBuilder->addFilter('attribute_set_id', null); + throw new \Magento\Framework\Exception\LocalizedException(__('Please, specify attributes')); } } diff --git a/app/code/Magento/Eav/Model/AttributeProvider.php b/app/code/Magento/Eav/Model/AttributeProvider.php index 56eb5b46a5ba8..1bb21fae46d14 100644 --- a/app/code/Magento/Eav/Model/AttributeProvider.php +++ b/app/code/Magento/Eav/Model/AttributeProvider.php @@ -60,7 +60,7 @@ public function getAttributes($entityType) $metadata = $this->metadataPool->getMetadata($entityType); $searchResult = $this->attributeRepository->getList( $metadata->getEavEntityType(), - $this->searchCriteriaBuilder->create() + $this->searchCriteriaBuilder->addFilter('attribute_set_id', null, 'neq')->create() ); $attributes = []; foreach ($searchResult->getItems() as $attribute) { diff --git a/app/code/Magento/Eav/Model/ResourceModel/CreateHandler.php b/app/code/Magento/Eav/Model/ResourceModel/CreateHandler.php index 016ec7dfc35cd..cb9f36fceb53b 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/CreateHandler.php +++ b/app/code/Magento/Eav/Model/ResourceModel/CreateHandler.php @@ -63,7 +63,7 @@ protected function getAttributes($entityType) $metadata = $this->metadataPool->getMetadata($entityType); $searchResult = $this->attributeRepository->getList( $metadata->getEavEntityType(), - $this->searchCriteriaBuilder->create() + $this->searchCriteriaBuilder->addFilter('attribute_set_id', null, 'neq')->create() ); return $searchResult->getItems(); } diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php index b750d50f7419f..f9b3a80981695 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php @@ -477,4 +477,31 @@ public function getSelectCountSql() $countSelect->columns('COUNT(DISTINCT main_table.attribute_id)'); return $countSelect; } + + /** + * Join table to collection select + * + * @param string $table + * @param string $cond + * @param string $cols + * @return $this + */ + public function joinLeft($table, $cond, $cols = '*') + { + if (is_array($table)) { + foreach ($table as $k => $v) { + $alias = $k; + $table = $v; + break; + } + } else { + $alias = $table; + } + + if (!isset($this->_joinedTables[$alias])) { + $this->getSelect()->joinLeft([$alias => $this->getTable($table)], $cond, $cols); + $this->_joinedTables[$alias] = true; + } + return $this; + } } diff --git a/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php b/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php index 51c07dd02d603..0a924a6cbb914 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php +++ b/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php @@ -71,9 +71,10 @@ public function __construct( protected function getAttributes($entityType) { $metadata = $this->metadataPool->getMetadata($entityType); + $searchResult = $this->attributeRepository->getList( $metadata->getEavEntityType(), - $this->searchCriteriaBuilder->create() + $this->searchCriteriaBuilder->addFilter('attribute_set_id', null, 'neq')->create() ); return $searchResult->getItems(); } diff --git a/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php b/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php index c2f390e90e5d6..b76390b712d6c 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php +++ b/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php @@ -71,9 +71,10 @@ public function __construct( protected function getAttributes($entityType) { $metadata = $this->metadataPool->getMetadata($entityType); + $searchResult = $this->attributeRepository->getList( $metadata->getEavEntityType(), - $this->searchCriteriaBuilder->create() + $this->searchCriteriaBuilder->addFilter('attribute_set_id', null, 'neq')->create() ); return $searchResult->getItems(); } diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php index 33c3e576337b3..de66653672dd6 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php @@ -518,33 +518,6 @@ public function join($table, $cond, $cols = '*') return $this; } - /** - * Join table to collection select - * - * @param string $table - * @param string $cond - * @param string $cols - * @return $this - */ - public function joinLeft($table, $cond, $cols = '*') - { - if (is_array($table)) { - foreach ($table as $k => $v) { - $alias = $k; - $table = $v; - break; - } - } else { - $alias = $table; - } - - if (!isset($this->_joinedTables[$alias])) { - $this->getSelect()->joinLeft([$alias => $this->getTable($table)], $cond, $cols); - $this->_joinedTables[$alias] = true; - } - return $this; - } - /** * Redeclare before load method for adding event * From 25adb2e3f5d26b6437f929c6865f517b780dc463 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 26 Feb 2016 16:26:13 +0200 Subject: [PATCH 048/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../Magento/Ui/view/base/web/js/form/components/button.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/form/components/button.js b/app/code/Magento/Ui/view/base/web/js/form/components/button.js index 2506a09eb1d24..8b043a11e6eda 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/components/button.js +++ b/app/code/Magento/Ui/view/base/web/js/form/components/button.js @@ -19,7 +19,8 @@ define([ elementTmpl: 'ui/form/element/button', template: 'ui/form/components/button/simple', visible: true, - disabled: false + disabled: false, + title: '' }, /** @@ -37,7 +38,8 @@ define([ return this._super() .observe([ 'visible', - 'disabled' + 'disabled', + 'title' ]); }, From 96477d7eeda10c8f2f54a5df201079f8908274ed Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Fri, 26 Feb 2016 16:42:38 +0200 Subject: [PATCH 049/278] MAGETWO-49680: Implement import of products from wizard and grid to dynamic rows --- .../view/adminhtml/web/js/variations/variations.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index 39fb10b3c869e..4d67613a8d520 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -180,7 +180,8 @@ define([ $button.text($button.attr('data-edit-label')); }, handleValue: function (variations) { - this.value([]); + var tmpArray = []; + _.each(variations, function (variation) { var attributes = _.reduce(variation.options, function (memo, option) { var attribute = {}; @@ -188,7 +189,7 @@ define([ return _.extend(memo, attribute); }, {}); - this.value.push(_.extend(variation, { + tmpArray.push(_.extend(variation, { productId: variation.productId || null, name: variation.name || variation.sku, priceCurrency: this.currencySymbol, @@ -200,6 +201,8 @@ define([ status: variation.status === undefined ? 1 : parseInt(variation.status, 10) })); }, this); + + this.value(tmpArray); }, From acfc1384ca00478f5a4ce0cf9f60d8d8a11e7cad Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 26 Feb 2016 16:48:32 +0200 Subject: [PATCH 050/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../templates/catalog/product/edit/super/wizard.phtml | 3 ++- .../view/adminhtml/web/js/variations/variations.js | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml index 682305158085f..22bebe076b10f 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/wizard.phtml @@ -42,7 +42,8 @@ $currencySymbol = $block->getCurrencySymbol(); "provider": "product_form.product_form_data_source", "dataScopeVariations": "variations", "dataScopeAttributes": "data.attributes", - "wizardModalButton": "product_form.product_form.configurable.configurable_products_button_set.create_configurable_products_button", + "wizardModalButtonName": "product_form.product_form.configurable.configurable_products_button_set.create_configurable_products_button", + "wizardModalButtonTitle": "", "variations": helper('Magento\Framework\Json\Helper\Data')->jsonEncode($productMatrix) ?>, "productAttributes": helper('Magento\Framework\Json\Helper\Data')->jsonEncode($attributes) ?>, "productUrl": "getUrl('catalog/product/edit', ['id' => '%id%']) ?>", diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index 39fb10b3c869e..5bb7a9c0b4d36 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -31,7 +31,8 @@ define([ productAttributesMap: null, value: [], modules: { - associatedProductGrid: '${ $.configurableProductGrid }' + associatedProductGrid: '${ $.configurableProductGrid }', + wizardButtonElement: '${ $.wizardModalButtonName }' }, links: { value: '${ $.provider }:${ $.dataScopeVariations }', @@ -167,7 +168,7 @@ define([ option.value + '][' + field + ']'; }, render: function (variations, attributes) { - //this.changeButtonWizard(); + this.changeButtonWizard(); this.populateVariationMatrix(variations); this.attributes(attributes); this.initImageUpload(); @@ -176,8 +177,7 @@ define([ this.handleValue(variations); }, changeButtonWizard: function () { - var $button = $('[data-action=open-steps-wizard] [data-role=button-label]'); - $button.text($button.attr('data-edit-label')); + this.wizardButtonElement().title(this.wizardModalButtonTitle); }, handleValue: function (variations) { this.value([]); From 736fa04d1d37e7de149e085b84029cb2b927bbaa Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 26 Feb 2016 16:52:14 +0200 Subject: [PATCH 051/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../view/adminhtml/web/js/variations/variations.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index 0851cbe50e0b5..fec103d4d1b4d 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -205,7 +205,6 @@ define([ this.value(tmpArray); }, - /** * Get attributes options * @see use in matrix.phtml From 4a97d6d963608cb49c108a8ec18cf0260794d6e9 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 26 Feb 2016 18:13:05 +0200 Subject: [PATCH 052/278] MAGETWO-47227: Add Step Wizard as Modal component --- .../adminhtml/web/js/variations/variations.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index fec103d4d1b4d..0de4f5129782a 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -23,6 +23,7 @@ define([ defaults: { opened: false, attributes: [], + usedAttributes: [], productMatrix: [], variations: [], productAttributes: [], @@ -36,7 +37,7 @@ define([ }, links: { value: '${ $.provider }:${ $.dataScopeVariations }', - attributes: '${ $.provider }:${ $.dataScopeAttributes }' + usedAttributes: '${ $.provider }:${ $.dataScopeAttributes }' } }, initialize: function () { @@ -47,7 +48,7 @@ define([ this.initProductAttributesMap(); }, initObservable: function () { - this._super().observe('actions opened attributes productMatrix value'); + this._super().observe('actions opened attributes productMatrix value usedAttributes'); return this; }, @@ -175,6 +176,7 @@ define([ //this.disableConfigurableAttributes(attributes); //this.showPrice(); this.handleValue(variations); + this.handleAttributes(); }, changeButtonWizard: function () { this.wizardButtonElement().title(this.wizardModalButtonTitle); @@ -204,6 +206,15 @@ define([ this.value(tmpArray); }, + handleAttributes: function () { + var tmpArray = []; + + _.each(this.attributes(), function (attribute) { + tmpArray.push(attribute.id); + }, this); + + this.usedAttributes(tmpArray); + }, /** * Get attributes options From b35b06604a191f91c64bfd4d0944d4aeb9dd7e64 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Fri, 26 Feb 2016 20:07:58 +0200 Subject: [PATCH 053/278] MAGETWO-49680: Implement import of products from wizard and grid to dynamic rows --- .../Helper/Plugin/Configurable.php | 30 ++- .../Helper/Plugin/UpdateConfigurations.php | 31 ++- .../Product/Form/Modifier/Configurable.php | 14 +- .../components/dynamic-rows-configurable.js | 183 ++++++++---------- 4 files changed, 157 insertions(+), 101 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php index ee09e6ae6a221..a83e051dc8b2a 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php @@ -58,7 +58,7 @@ public function afterInitialize( $product->setNewVariationsAttributeSetId($setId); $associatedProductIds = $this->request->getPost('associated_product_ids', []); - $variationsMatrix = $this->request->getParam('variations-matrix', []); + $variationsMatrix = $this->getVariationMatrix(); if (!empty($variationsMatrix)) { $generatedProductIds = $this->variationHandler->generateSimpleProducts($product, $variationsMatrix); $associatedProductIds = array_merge($associatedProductIds, $generatedProductIds); @@ -72,4 +72,32 @@ public function afterInitialize( return $product; } + + /** + * Get variation-matrix from request + * + * @return array + */ + protected function getVariationMatrix() + { + $result = []; + $configurableMatrix = $this->request->getParam('configurable-matrix', []); + foreach ($configurableMatrix as $item) { + if ($item['newProduct']) { + $result[$item['variationKey']] = [ + 'status' => isset($item['status']) ? $item['status'] : '', + 'sku' => isset($item['sku']) ? $item['sku'] : '', + 'name' => isset($item['name']) ? $item['name'] : '', + 'price' => isset($item['price']) ? $item['price'] : '', + 'configurable_attribute' => isset($item['configurable_attribute']) + ? $item['configurable_attribute'] : '', + 'quantity_and_stock_status' => isset($item['quantity_and_stock_status']) + ? $item['quantity_and_stock_status'] : '', + 'weight' => isset($item['weight']) ? $item['weight'] : '', + ]; + } + } + + return $result; + } } diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php index 5d06fed5c9078..703428c39ea81 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php @@ -46,7 +46,8 @@ public function afterInitialize( \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, \Magento\Catalog\Model\Product $configurableProduct ) { - $configurations = $this->request->getParam('configurations', []); + //$configurations = $this->request->getParam('configurations', []); + $configurations = $this->getConfigurations(); $configurations = $this->variationHandler->duplicateImagesForVariations($configurations); foreach ($configurations as $productId => $productData) { /** @var \Magento\Catalog\Model\Product $product */ @@ -59,4 +60,32 @@ public function afterInitialize( } return $configurableProduct; } + + /** + * Get configurations from request + * + * @return array + */ + protected function getConfigurations() + { + $result = []; + $configurableMatrix = $this->request->getParam('configurable-matrix', []); + foreach ($configurableMatrix as $configurations) { + if (!$configurations['newProduct']) { + $result[$item['id']] = [ + 'status' => isset($item['status']) ? $item['status'] : '', + 'sku' => isset($item['sku']) ? $item['sku'] : '', + 'name' => isset($item['name']) ? $item['name'] : '', + 'price' => isset($item['price']) ? $item['price'] : '', + 'configurable_attribute' => isset($item['configurable_attribute']) + ? $item['configurable_attribute'] : '', + 'quantity_and_stock_status' => isset($item['quantity_and_stock_status']) + ? $item['quantity_and_stock_status'] : '', + 'weight' => isset($item['weight']) ? $item['weight'] : '', + ]; + } + } + + return $result; + } } diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php index 17cfd39703525..a78bfcabf90b3 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Configurable.php @@ -70,6 +70,12 @@ public function __construct( */ public function modifyData(array $data) { + if (in_array($this->locator->getProduct()->getTypeId(), self::$availableProductTypes)) { + $model = $this->locator->getProduct(); + $data[$model->getId()]['affect_configurable_product_attributes'] = '1'; + //$data[$model->getId()]['configurable-matrix'] = $this->getConfigurableMatrix(); + } + return $data; } @@ -174,7 +180,7 @@ public function modifyMeta(array $meta) protected function getPanelChildren() { return [ 'configurable_products_button_set' => $this->getButtonSet(), - 'variations-matrix' => $this->getGrid(), + 'configurable-matrix' => $this->getGrid(), ]; } @@ -282,6 +288,7 @@ protected function getGrid() 'itemTemplate' => 'record', 'dataScope' => 'data', 'dataProviderFromGrid' => static::ASSOCIATED_PRODUCT_LISTING, + 'dataProviderFromWizard' => 'variations', 'map' => [ 'id' => 'entity_id', 'product_link' => 'product_link', @@ -293,7 +300,10 @@ protected function getGrid() 'quantity_and_stock_status.qty' => 'qty', 'weight' => 'weight', ], - 'links' => ['insertDataFromGrid' => '${$.provider}:${$.dataProviderFromGrid}'], + 'links' => [ + 'insertDataFromGrid' => '${$.provider}:${$.dataProviderFromGrid}', + 'insertDataFromWizard' => '${$.provider}:${$.dataProviderFromWizard}', + ], 'sortOrder' => 20, 'columnsHeader' => true, 'columnsHeaderAfterRender' => true, diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js index 97cc7feab2776..62b3f46eb0c6c 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js @@ -12,19 +12,38 @@ define([ return dynamicRows.extend({ defaults: { canEditField: 'canEdit', + newProductField: 'newProduct', + dataScopeAssociatedProduct: 'data.associated_product_ids', + associatedProductIncrement: 0, dataProviderFromGrid: '', insertDataFromGrid: [], + dataProviderFromWizard: '', + insertDataFromWizard: [], map: null, cacheGridData: [], + unionInsertData: [], deleteProperty: false, dataLength: 0, identificationProperty: 'id', + attribute_set_id: '', listens: { - 'insertDataFromGrid': 'processingInsertData', - 'elems': 'mappingValue' + 'insertDataFromGrid': 'processingInsertDataFromGrid', + 'insertDataFromWizard': 'processingInsertDataFromWizard', + 'unionInsertData': 'processingUnionInsertData' + }, + imports: { + 'attribute_set_id': '${$.provider}:data.product.attribute_set_id' + }, + 'exports': { + 'attribute_set_id': '${$.provider}:data.new-variations-attribute-set-id' } }, + addAssociatedProduct: function (productId) { + this.source.set(this.dataScopeAssociatedProduct + '.' + this.associatedProductIncrement, productId); + ++this.associatedProductIncrement; + }, + /** * Calls 'initObservable' of parent * @@ -33,54 +52,24 @@ define([ initObservable: function () { this._super() .observe([ - 'insertDataFromGrid' + 'insertDataFromGrid', 'unionInsertData' ]); return this; }, - /** - * Initialize children, - * set data from server to grid dataScope - */ - initChildren: function () { - var insertData = []; - - if (this.recordData().length) { - this.recordData.each(function (recordData) { - var unmappingValue = this.unmappingValue(recordData); - unmappingValue[this.canEditField] = false; - insertData.push(unmappingValue); - }, this); - - this.source.set(this.dataProviderFromGrid, insertData); - } - - return this; - }, + processingUnionInsertData: function (data) { + this.clear(); + this.source.set(this.dataScope + '.' + this.index, []); - /** - * Unmapping value, - * unmapping data from server to grid dataScope - * - * @param {Object} data - data object - */ - unmappingValue: function (data) { - var obj = {}; + _.each(data, function (row) { + _.each(row, function (value, key) { + var path = this.dataScope + '.' + this.index + '.' + this.recordIterator + '.' + key; + this.source.set(path, value); + }, this); - _.each(this.map, function (prop, index) { - obj[prop] = data[index]; + this.addChild(data, false); }, this); - - return obj; - }, - - /** - * Rerender dynamic-rows elems - */ - reload: function () { - this.cacheGridData = []; - this._super(); }, /** @@ -89,36 +78,68 @@ define([ * @param {Array} data - array with data * about selected records */ - processingInsertData: function (data) { + processingInsertDataFromGrid: function (data) { var changes; if (!data.length) { - this.elems([]); + return; } + var tmpArray = this.unionInsertData(); + changes = this._checkGridData(data); this.cacheGridData = data; changes.each(function (changedObject) { - this.addChild(changedObject, false, parseInt(changedObject[this.map.id], 10)); + this.addAssociatedProduct(changedObject[this.map.id]); + + var mappedData = this.mappingValue(changedObject); + mappedData[this.canEditField] = 0; + mappedData[this.newProductField] = 0; + tmpArray.push(mappedData); }, this); + + this.unionInsertData(tmpArray); }, - /** - * Delete record instance - * update data provider dataScope - * - * @param {String|Number} index - record index - */ - deleteRecord: function (index, recordId) { - var data = this.getElementData(this.insertDataFromGrid(), recordId); - - this.mapping = true; - this._super(); - this.insertDataFromGrid(_.reject(this.source.get(this.dataProviderFromGrid), function (recordData) { - return parseInt(recordData[this.map.id], 10) === parseInt(data[this.map.id], 10); - }, this)); - this.mapping = false; + processingInsertDataFromWizard: function (data) { + var tmpArray = this.unionInsertData(); + tmpArray = this.unsetArrayItem(tmpArray, {'id': null}); + + _.each(data, function (row) { + var product = { + 'id': row.productId, + 'name': row.name, + 'sku': row.sku, + 'status': row.status, + 'price': row.price, + 'price_currency': row.priceCurrency, + 'price_string': row.priceCurrency + row.price, + 'weight': row.weight, + 'quantity_and_stock_status.qty': row.quantity, + 'variationKey': row.variationKey, + 'configurable_attribute': row.attribute + }; + product[this.canEditField] = 1; + product[this.newProductField] = 1; + + tmpArray.push(product); + }, this); + + this.unionInsertData(tmpArray); + }, + + unsetArrayItem: function (data, condition) { + var objs = _.where(data, condition); + + _.each(objs, function (obj) { + var index = _.indexOf(data, obj); + if (index > -1) { + data.splice(index, 1); + } + }); + + return data; }, /** @@ -148,43 +169,11 @@ define([ /** * Mapped value */ - mappingValue: function () { - var path, - data, - elements = this.elems(); - - if (this.mapping) { - return false; - } - - elements.each(function (record) { - data = this.getElementData(this.insertDataFromGrid(), record.recordId); - _.each(this.map, function (prop, index) { - path = record.dataScope + '.' + index; - this.source.set(path, data[prop]); - }, this); - path = record.dataScope + '.' + this.canEditField; - this.source.set(path, false); - }, this); - }, - - /** - * Find data object by index - * - * @param {Array} array - data collection - * @param {Number} index - element index - * @param {String} property - to find by property - * - * @returns {Object} data object - */ - getElementData: function (array, index, property) { - var obj = {}, - result; - - property ? obj[property] = index : obj[this.map.id] = index; - result = _.findWhere(array, obj); - !result ? property ? obj[property] = index.toString() : obj[this.map.id] = index.toString() : false; - result = _.findWhere(array, obj); + mappingValue: function (data) { + var result = {}; + _.each(this.map, function (prop, index) { + result[index] = data[prop]; + }); return result; } From 5a9446b45387a838974c0498c0abc0f30c39911f Mon Sep 17 00:00:00 2001 From: Anton Ohorodnyk Date: Mon, 29 Feb 2016 03:15:44 +0200 Subject: [PATCH 054/278] MAGETWO-47246: Add Attribute and Attributes Panel - MAGETWO-49384: Resolve Visual Swatch attribute --- .../adminhtml/layout/catalog_product_form.xml | 5 + .../catalog/product/attribute/visual.phtml | 2 +- .../product_attribute_add_form.xml | 109 ++++++ .../view/adminhtml/web/css/swatches.css | 24 +- .../web/js/form/element/swatch-visual.js | 322 ++++++++++++++++++ .../adminhtml/web/template/swatch-visual.html | 28 ++ 6 files changed, 477 insertions(+), 13 deletions(-) create mode 100644 app/code/Magento/Swatches/view/adminhtml/web/js/form/element/swatch-visual.js create mode 100644 app/code/Magento/Swatches/view/adminhtml/web/template/swatch-visual.html diff --git a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_form.xml b/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_form.xml index 2c6b72d46301c..a1a2315445696 100644 --- a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_form.xml @@ -6,6 +6,11 @@ */ --> + + + + + diff --git a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml index 7edb8806e2393..de8a5e60492a2 100644 --- a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml +++ b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml @@ -57,7 +57,7 @@ getReadOnly()):?>disabled="disabled"/> - +
diff --git a/app/code/Magento/Swatches/view/adminhtml/ui_component/product_attribute_add_form.xml b/app/code/Magento/Swatches/view/adminhtml/ui_component/product_attribute_add_form.xml index 0c2d3b21cfcc9..b7890f864d39a 100644 --- a/app/code/Magento/Swatches/view/adminhtml/ui_component/product_attribute_add_form.xml +++ b/app/code/Magento/Swatches/view/adminhtml/ui_component/product_attribute_add_form.xml @@ -118,4 +118,113 @@
+ +
+ + + Magento_Catalog/js/components/visible-on-option + Manage Swatch (Values of Your Attribute) + true + 15 + + swatch_visual + + + + + + + + dynamicRows + visual_swatch + Add Swatch + + true + true + + + + + + + true + true + Magento_Ui/js/dynamic-rows/record + container + text_swatch.position + + + + + + + boolean + checkbox + Is Default + defaulttext[] + radio + 1 + 0 + + + + + + + select + Magento_Swatches/js/form/element/swatch-visual + Magento_Swatches/swatch-visual + Swatch + swatchtext.value.option_0 + + true + + + + + + + + text + input + Default Store View + optiontext.value.option_1 + + + + + + + text + input + Admin + optiontext.value.option_0 + + + + + + + text + input + position + false + + true + + + + + + + + actionDelete + text + true + + + + + +
diff --git a/app/code/Magento/Swatches/view/adminhtml/web/css/swatches.css b/app/code/Magento/Swatches/view/adminhtml/web/css/swatches.css index 796f28f8c463a..a3a1f905b2b58 100644 --- a/app/code/Magento/Swatches/view/adminhtml/web/css/swatches.css +++ b/app/code/Magento/Swatches/view/adminhtml/web/css/swatches.css @@ -39,7 +39,7 @@ border: 1px solid black; width: 30px; height: 30px; overflow: hidden; } -.ui-sortable .col-default div[id*="swatch_window_option"] { +div[id*="swatch_window_option"] { border: 1px solid #c6c5c3 !important; cursor: pointer; overflow: visible !important; @@ -47,7 +47,7 @@ width: 25px !important; height: 24px !important; } -.ui-sortable .col-default div[id*="swatch_window_option"]:after { +div[id*="swatch_window_option"]:after { position: absolute; content: '\2193'; top: -5px; @@ -61,7 +61,7 @@ border: 1px solid rgb(173, 173, 173); z-index: 8; } -.ui-sortable .col-default div[id*="swatch_window_option"]:before { +div[id*="swatch_window_option"]:before { position: absolute; content: ''; top: -4px; @@ -76,31 +76,31 @@ z-index: 1; outline: 1px solid rgb(173, 173, 173); } -.ui-sortable .col-default div[id*="swatch_container_option"] { +div[id*="swatch_container_option"] { border: 1px solid rgb(173, 173, 173) !important; border-radius: 5px 0 5px 5px; box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.22); } -.ui-sortable .col-default div[id*="swatch_container_option"] .swatch_row { +div[id*="swatch_container_option"] .swatch_row { border: 0 !important; text-align: left; cursor: pointer; border-bottom: 1px solid #e3e3e3 !important; } -.ui-sortable .col-default div[id*="swatch_container_option"] .swatch_row:first-child { +div[id*="swatch_container_option"] .swatch_row:first-child { border-radius: 5px 0 0 0; } -.ui-sortable .col-default div[id*="swatch_container_option"] .swatch_row:last-child { +div[id*="swatch_container_option"] .swatch_row:last-child { border-bottom: 0 !important; border-radius: 0 0 5px 5px; } -.ui-sortable .col-default div[id*="swatch_container_option"] .swatch_row .swatch_row_name p { +div[id*="swatch_container_option"] .swatch_row .swatch_row_name p { padding-left: 12px; } -.ui-sortable .col-default div[id*="swatch_container_option"] .swatch_row .swatch_row_name { +div[id*="swatch_container_option"] .swatch_row .swatch_row_name { background: #fff !important; } -.ui-sortable .col-default div[id*="swatch_container_option"] .swatch_row:hover .swatch_row_name { +div[id*="swatch_container_option"] .swatch_row:hover .swatch_row_name { background: #FBFAF6 !important; } .swatch_sub-menu_container { @@ -116,13 +116,13 @@ content: ''; position: absolute; } -.col-default[class*="swatch-window-col"] { +.swatches-visual-col { position: relative; } .col-swatch { .width: 50px; } -.col-default[class*="swatch-window-col"].unavailable:after { +.swatches-visual-col.unavailable:after { content: ''; position: absolute; width: 35px; diff --git a/app/code/Magento/Swatches/view/adminhtml/web/js/form/element/swatch-visual.js b/app/code/Magento/Swatches/view/adminhtml/web/js/form/element/swatch-visual.js new file mode 100644 index 0000000000000..0d94c69799737 --- /dev/null +++ b/app/code/Magento/Swatches/view/adminhtml/web/js/form/element/swatch-visual.js @@ -0,0 +1,322 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +/* global $break $ $$ FORM_KEY */ + +define([ + 'jquery', + 'mage/template', + 'uiRegistry', + 'prototype', + 'Magento_Ui/js/form/element/abstract', + 'jquery/ui' +], function (jQuery, mageTemplate, rg, prototype, Abstract) { + 'use strict'; + + function oldCode(value, container) { + var swatchVisualOption = { + itemCount: 0, + totalItems: 0, + rendered: 0, + isReadOnly: false, + + initialize: function () { + if (_.isEmpty(value)) { + container.addClassName('unavailable'); + } + + jQuery(container).on( + 'click', + '.colorpicker_handler', + this.initColorPicker + ); + }, + + /** + * ColorPicker initialization process + */ + initColorPicker: function () { + debugger; + var element = this, + hiddenColorPicker = !jQuery(element).data('colorpickerId'); + + jQuery(this).ColorPicker({ + + /** + * ColorPicker onShow action + */ + onShow: function () { + var color = jQuery(element).parent().parent().prev().prev('input').val(), + menu = jQuery(this).parents('.swatch_sub-menu_container'); + + menu.hide(); + jQuery(element).ColorPickerSetColor(color); + }, + + /** + * ColorPicker onSubmit action + * + * @param {String} hsb + * @param {String} hex + * @param {String} rgb + * @param {String} el + */ + onSubmit: function (hsb, hex, rgb, el) { + var container = jQuery(el).parent().parent().prev(); + + jQuery(el).ColorPickerHide(); + container.parent().removeClass('unavailable'); + container.prev('input').val('#' + hex); + container.css('background', '#' + hex); + } + }); + + if (hiddenColorPicker) { + jQuery(this).ColorPickerShow(); + } + }, + + /** + * Remove action + * + * @param {Object} event + */ + remove: function (event) { + var element = $(Event.findElement(event, 'tr')), + elementFlags; // !!! Button already have table parent in safari + + // Safari workaround + element.ancestors().each(function (parentItem) { + if (parentItem.hasClassName('option-row')) { + element = parentItem; + throw $break; + } else if (parentItem.hasClassName('box')) { + throw $break; + } + }); + + if (element) { + elementFlags = element.getElementsByClassName('delete-flag'); + + if (elementFlags[0]) { + elementFlags[0].value = 1; + } + + element.addClassName('no-display'); + element.addClassName('template'); + element.hide(); + this.totalItems--; + this.updateItemsCountField(); + } + }, + + /** + * Update items count field + */ + updateItemsCountField: function () { + $('swatch-visual-option-count-check').value = this.totalItems > 0 ? '1' : ''; + } + }; + + //swatchVisualOption.initColorPicker(); + + jQuery('body').on('click', function (event) { + var element = jQuery(event.target); + + if ( + element.parents('.swatch_sub-menu_container').length === 1 || + element.next('div.swatch_sub-menu_container').length === 1 + ) { + return true; + } + jQuery('.swatch_sub-menu_container').hide(); + }); + + window.swatchVisualOption = swatchVisualOption; + + rg.set('swatch-visual-options-panel', swatchVisualOption); + + jQuery(function ($) { + + var swatchComponents = { + + /** + * div wrapper for to hide all evement + */ + wrapper: null, + + /** + * iframe component to perform file upload without page reload + */ + iframe: null, + + /** + * form component for upload image + */ + form: null, + + /** + * Input file component for upload image + */ + inputFile: null, + + /** + * Create swatch component for upload files + * + * @this {swatchComponents} + * @public + */ + create: function () { + this.wrapper = $('
').css({ + display: 'none' + }).appendTo($('body')); + + this.iframe = $('