diff --git a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleSkuTest.php b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleSkuTest.php index 86f3739235a85..ba34843c7ed73 100644 --- a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleSkuTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleSkuTest.php @@ -6,7 +6,7 @@ namespace Magento\Bundle\Test\Unit\Ui\DataProvider\Product\Form\Modifier; use Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\BundleSku; -use Magento\Catalog\Model\AttributeConstantsInterface; +use Magento\Catalog\Api\Data\ProductAttributeInterface; /** * Class BundleSkuTest @@ -31,7 +31,7 @@ public function testModifyMeta() $sourceMeta = [ 'testGroup' => [ 'children' => [ - AttributeConstantsInterface::CODE_SKU => [ + ProductAttributeInterface::CODE_SKU => [ 'componentType' => 'testComponent', ], ] diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php index f75e778fa21b1..d36a7e25fbcef 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php @@ -5,8 +5,8 @@ */ namespace Magento\Bundle\Ui\DataProvider\Product\Form\Modifier; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier; -use Magento\Catalog\Model\AttributeConstantsInterface as Constants; /** * Customize Advanced Pricing modal panel @@ -32,13 +32,15 @@ public function modifyMeta(array $meta) unset($parentNode['container_' . self::CODE_MSRP]); unset($parentNode['container_' . self::CODE_MSRP_DISPLAY_ACTUAL_PRICE_TYPE]); } - if (isset($parentNode['container_' . Constants::CODE_SPECIAL_PRICE])) { - $currentNode = &$parentNode['container_' . Constants::CODE_SPECIAL_PRICE]['children']; - $currentNode[Constants::CODE_SPECIAL_PRICE]['arguments']['data']['config']['addbefore'] = "%"; + if (isset($parentNode['container_' . ProductAttributeInterface::CODE_SPECIAL_PRICE])) { + $currentNode = &$parentNode['container_' . ProductAttributeInterface::CODE_SPECIAL_PRICE]['children']; + $currentNode[ProductAttributeInterface::CODE_SPECIAL_PRICE]['arguments']['data']['config']['addbefore'] + = "%"; } - $parentNodeChildren = &$parentNode[Constants::CODE_TIER_PRICE]['children']; - if (isset( $parentNodeChildren[self::CODE_RECORD]['children'][Constants::CODE_PRICE])) { - $currentNode = &$parentNodeChildren[self::CODE_RECORD]['children'][Constants::CODE_PRICE]; + $parentNodeChildren = &$parentNode[ProductAttributeInterface::CODE_TIER_PRICE]['children']; + if (isset($parentNodeChildren[self::CODE_RECORD]['children'][ProductAttributeInterface::CODE_PRICE])) { + $currentNode = + &$parentNodeChildren[self::CODE_RECORD]['children'][ProductAttributeInterface::CODE_PRICE]; $currentNode['arguments']['data']['config']['label'] = __('Percent Discount'); } } diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php index 5d48fe4bab615..48330fa0cf658 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php @@ -5,8 +5,8 @@ */ namespace Magento\Bundle\Ui\DataProvider\Product\Form\Modifier; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier; -use Magento\Catalog\Model\AttributeConstantsInterface; use Magento\Ui\Component\Form; use Magento\Framework\Stdlib\ArrayManager; use Magento\Catalog\Model\Locator\LocatorInterface; @@ -49,11 +49,11 @@ public function __construct( */ public function modifyMeta(array $meta) { - if ($groupCode = $this->getGroupCodeByField($meta, AttributeConstantsInterface::CODE_PRICE) + if ($groupCode = $this->getGroupCodeByField($meta, ProductAttributeInterface::CODE_PRICE) ?: $this->getGroupCodeByField($meta, self::CODE_GROUP_PRICE) ) { $isNewProduct = ($this->locator->getProduct()->getId()) ? false : true; - $pricePath = $this->getElementArrayPath($meta, AttributeConstantsInterface::CODE_PRICE) + $pricePath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_PRICE) ?: $this->getElementArrayPath($meta, self::CODE_GROUP_PRICE); $meta[$groupCode]['children'][self::CODE_PRICE_TYPE] = [ @@ -91,7 +91,7 @@ public function modifyMeta(array $meta) $meta[$groupCode]['children'][self::CODE_GROUP_PRICE], [ 'children' => [ - AttributeConstantsInterface::CODE_PRICE => [ + ProductAttributeInterface::CODE_PRICE => [ 'arguments' => [ 'data' => [ 'config' => [ diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleSku.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleSku.php index e676916b0c31c..20f4d2d0055c4 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleSku.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleSku.php @@ -5,8 +5,8 @@ */ namespace Magento\Bundle\Ui\DataProvider\Product\Form\Modifier; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier; -use Magento\Catalog\Model\AttributeConstantsInterface; use Magento\Ui\Component\Form; use Magento\Framework\Stdlib\ArrayManager; @@ -36,15 +36,15 @@ public function __construct(ArrayManager $arrayManager) */ public function modifyMeta(array $meta) { - if ($groupCode = $this->getGroupCodeByField($meta, AttributeConstantsInterface::CODE_SKU)) { - $skuPath = $this->getElementArrayPath($meta, AttributeConstantsInterface::CODE_SKU); + if ($groupCode = $this->getGroupCodeByField($meta, ProductAttributeInterface::CODE_SKU)) { + $skuPath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_SKU); $meta[$groupCode]['children'][self::CODE_SKU_TYPE] = [ 'arguments' => [ 'data' => [ 'config' => [ 'sortOrder' => $this->getNextAttributeSortOrder( $meta, - [AttributeConstantsInterface::CODE_SKU], + [ProductAttributeInterface::CODE_SKU], self::SORT_ORDER ), 'formElement' => Form\Element\Checkbox::NAME, diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php index 0b3d5bf1d371b..0d45cc3d077e6 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php @@ -5,8 +5,8 @@ */ namespace Magento\Bundle\Ui\DataProvider\Product\Form\Modifier; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier; -use Magento\Catalog\Model\AttributeConstantsInterface; use Magento\Ui\Component\Form; use Magento\Framework\Stdlib\ArrayManager; @@ -37,10 +37,10 @@ public function __construct(ArrayManager $arrayManager) */ public function modifyMeta(array $meta) { - if (($groupCode = $this->getGroupCodeByField($meta, AttributeConstantsInterface::CODE_WEIGHT) + if (($groupCode = $this->getGroupCodeByField($meta, ProductAttributeInterface::CODE_WEIGHT) ?: $this->getGroupCodeByField($meta, self::CODE_CONTAINER_WEIGHT)) ) { - $weightPath = $this->getElementArrayPath($meta, AttributeConstantsInterface::CODE_WEIGHT) + $weightPath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_WEIGHT) ?: $this->getElementArrayPath($meta, self::CODE_CONTAINER_WEIGHT); $meta[$groupCode]['children'][self::CODE_WEIGHT_TYPE] = [ 'arguments' => [ @@ -76,7 +76,7 @@ public function modifyMeta(array $meta) $meta[$groupCode]['children'][self::CODE_CONTAINER_WEIGHT], [ 'children' => [ - AttributeConstantsInterface::CODE_HAS_WEIGHT => [ + ProductAttributeInterface::CODE_HAS_WEIGHT => [ 'arguments' => [ 'data' => [ 'config' => [ @@ -93,7 +93,7 @@ public function modifyMeta(array $meta) $meta[$groupCode]['children'][self::CODE_CONTAINER_WEIGHT], [ 'children' => [ - AttributeConstantsInterface::CODE_WEIGHT => [ + ProductAttributeInterface::CODE_WEIGHT => [ 'arguments' => [ 'data' => [ 'config' => [ diff --git a/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php b/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php index 705f55f93a552..8d6b3e46b2eb4 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php @@ -12,4 +12,21 @@ interface ProductAttributeInterface extends \Magento\Catalog\Api\Data\EavAttributeInterface { const ENTITY_TYPE_CODE = 'catalog_product'; + const CODE_TIER_PRICE_FIELD_PRICE = 'price'; + const CODE_HAS_WEIGHT = 'product_has_weight'; + const CODE_SPECIAL_PRICE = 'special_price'; + const CODE_PRICE = 'price'; + const CODE_TIER_PRICE_FIELD_PRICE_QTY = 'price_qty'; + const CODE_SHORT_DESCRIPTION = 'short_description'; + const CODE_SEO_FIELD_META_TITLE = 'meta_title'; + const CODE_STATUS = 'status'; + const CODE_NAME = 'name'; + const CODE_SKU = 'sku'; + const CODE_SEO_FIELD_META_KEYWORD = 'meta_keyword'; + const CODE_DESCRIPTION = 'description'; + const CODE_COST = 'cost'; + const CODE_SEO_FIELD_URL_KEY = 'url_key'; + const CODE_TIER_PRICE = 'tier_price'; + const CODE_SEO_FIELD_META_DESCRIPTION = 'meta_description'; + const CODE_WEIGHT = 'weight'; } diff --git a/app/code/Magento/Catalog/Model/AttributeConstantsInterface.php b/app/code/Magento/Catalog/Model/AttributeConstantsInterface.php deleted file mode 100644 index d19730faecaa9..0000000000000 --- a/app/code/Magento/Catalog/Model/AttributeConstantsInterface.php +++ /dev/null @@ -1,31 +0,0 @@ -objectManager = new ObjectManager($this); - $this->grouper = $this->objectManager->getObject(Grouper::class); - } - - public function testGroupMetaElementMinimalOptions() - { - $meta = [ - 'group1' => [ - 'children' => [ - 'element1' => [ - 'label' => 'Element 1', - 'sortOrder' => 10 - ], - 'element2' => [ - 'label' => 'Element 2', - 'sortOrder' => 20 - ] - ] - ] - ]; - - $elements = ['element1', 'element2']; - - $result = [ - 'group1' => [ - 'children' => [ - 'element1' => [ - 'formElement' => 'container', - 'componentType' => 'container', - 'component' => 'Magento_Ui/js/form/components/group', - 'dataScope' => '', - 'label' => 'Element 1', - 'sortOrder' => 10, - 'children' => [ - 'element1' => [ - 'label' => 'Element 1', - 'sortOrder' => 10, - 'dataScope' => 'element1' - ], - 'element2' => [ - 'label' => 'Element 2', - 'sortOrder' => 20, - 'dataScope' => 'element2' - ] - ] - ] - ] - ] - ]; - - $this->assertSame($result, $this->grouper->groupMetaElements($meta, $elements)); - } - - public function testGroupMetaElementsDifferentGroups() - { - $meta = [ - 'group1' => [ - 'children' => [ - 'element1' => [ - 'label' => 'Element 1', - 'sortOrder' => 10 - ] - ] - ], - 'group2' => [ - 'children' => [ - 'element2' => [ - 'label' => 'Element 2', - 'sortOrder' => 10 - ] - ] - ] - ]; - - $elements = [ - 'element1' => [ - 'requiredMeta' => [ - 'required' => true - ] - ], - 'element2' => [ - 'meta' => [ - 'additionalClasses' => 'inline' - ] - ] - ]; - - $result = [ - 'group1' => [ - 'children' => [ - 'element1' => [ - 'label' => 'Element 1', - 'sortOrder' => 10, - 'required' => true - ] - ] - ], - 'group2' => [ - 'children' => [ - 'element2' => [ - 'label' => 'Element 2', - 'sortOrder' => 10 - ] - ] - ] - ]; - - $this->assertSame($result, $this->grouper->groupMetaElements($meta, $elements)); - } - - public function testGroupMetaElementsFullOptions() - { - $meta = [ - 'group1' => [ - 'children' => [ - 'element1' => [ - 'label' => 'Element 1', - 'sortOrder' => 10 - ], - ] - ], - 'group2' => [ - 'children' => [ - 'element2' => [ - 'label' => 'Element 2', - 'sortOrder' => 10 - ] - ] - ] - ]; - - $elements = [ - 'element1' => [ - 'requiredMeta' => [ - 'required' => true - ], - 'meta' => [ - 'additionalClasses' => 'inline' - ] - ], - 'element2' => [ - 'isTarget' => true, - 'requiredMeta' => [ - 'validation' => [ - 'validate-number' => true - ] - ], - 'meta' => [ - 'additionalClasses' => 'inline last', - 'sortOrder' => 20 - ] - ] - ]; - - $groupOptions = [ - 'targetCode' => 'container1', - 'groupNonSiblings' => true, - 'meta' => [ - 'additionalClasses' => 'group' - ] - ]; - - $result = [ - 'group1' => [ - 'children' => [] - ], - 'group2' => [ - 'children' => [ - 'container1' => [ - 'formElement' => 'container', - 'componentType' => 'container', - 'component' => 'Magento_Ui/js/form/components/group', - 'dataScope' => '', - 'label' => 'Element 2', - 'sortOrder' => 10, - 'additionalClasses' => 'group', - 'children' => [ - 'element1' => [ - 'label' => 'Element 1', - 'sortOrder' => 10, - 'required' => true, - 'additionalClasses' => 'inline', - 'dataScope' => 'element1' - ], - 'element2' => [ - 'label' => 'Element 2', - 'sortOrder' => 20, - 'validation' => [ - 'validate-number' => true - ], - 'additionalClasses' => 'inline last', - 'dataScope' => 'element2' - ] - ] - ] - ] - ] - ]; - - $this->assertSame($result, $this->grouper->groupMetaElements($meta, $elements, $groupOptions)); - } -} diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php index 83286105a0ab6..218507d0dd145 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php @@ -13,7 +13,6 @@ use Magento\Store\Model\Store; use Magento\Ui\DataProvider\Modifier\ModifierInterface; use Magento\Framework\Stdlib\ArrayManager; -use Magento\Catalog\Ui\DataProvider\Grouper; /** * Class AbstractDataProviderTest @@ -51,11 +50,6 @@ abstract class AbstractModifierTest extends \PHPUnit_Framework_TestCase */ protected $arrayManagerMock; - /** - * @var Grouper|\PHPUnit_Framework_MockObject_MockObject - */ - protected $grouperMock; - protected function setUp() { $this->objectManager = new ObjectManager($this); @@ -77,9 +71,6 @@ protected function setUp() $this->arrayManagerMock = $this->getMockBuilder(ArrayManager::class) ->disableOriginalConstructor() ->getMock(); - $this->grouperMock = $this->getMockBuilder(Grouper::class) - ->disableOriginalConstructor() - ->getMock(); $this->arrayManagerMock->expects($this->any()) ->method('replace') @@ -93,12 +84,6 @@ protected function setUp() $this->arrayManagerMock->expects($this->any()) ->method('merge') ->willReturnArgument(1); - $this->grouperMock->expects($this->any()) - ->method('groupMetaElements') - ->willReturnArgument(0); - $this->grouperMock->expects($this->any()) - ->method('remove') - ->willReturnArgument(1); $this->arrayManagerMock->expects($this->any()) ->method('remove') ->willReturnArgument(1); diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php index 14fc7e4757af1..ae8d2f8138529 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php @@ -6,7 +6,6 @@ namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing; -use Magento\Catalog\Ui\DataProvider\Grouper; use Magento\Store\Model\StoreManagerInterface; use Magento\Customer\Api\Data\GroupInterface as CustomerGroupInterface; use Magento\Customer\Api\GroupManagementInterface; @@ -25,11 +24,6 @@ */ class AdvancedPricingTest extends AbstractModifierTest { - /** - * @var Grouper|\PHPUnit_Framework_MockObject_MockObject - */ - protected $grouperMock; - /** * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -78,9 +72,6 @@ class AdvancedPricingTest extends AbstractModifierTest protected function setUp() { parent::setUp(); - $this->grouperMock = $this->getMockBuilder(Grouper::class) - ->disableOriginalConstructor() - ->getMock(); $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class) ->getMockForAbstractClass(); $this->groupRepositoryMock = $this->getMockBuilder(GroupRepositoryInterface::class) @@ -117,7 +108,6 @@ protected function createModel() { return $this->objectManager->getObject(AdvancedPricing::class, [ 'locator' => $this->locatorMock, - 'grouper' => $this->grouperMock, 'storeManager' => $this->storeManagerMock, 'groupRepository' => $this->groupRepositoryMock, 'groupManagement' => $this->groupManagementMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php index 5f85887501726..d5aad8be60f56 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php @@ -5,7 +5,6 @@ */ namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier; -use Magento\Catalog\Model\AttributeConstantsInterface; use Magento\Catalog\Model\Product\Type; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\General; @@ -23,7 +22,6 @@ protected function createModel() { return $this->objectManager->getObject(General::class, [ 'locator' => $this->locatorMock, - 'grouper' => $this->grouperMock, 'arrayManager' => $this->arrayManagerMock, ]); } diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ImagesTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ImagesTest.php index 44801bf0646c4..537bfdab3d4d8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ImagesTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ImagesTest.php @@ -5,8 +5,8 @@ */ namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Model\Product\Type; -use Magento\Catalog\Model\AttributeConstantsInterface; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\General; /** @@ -32,9 +32,9 @@ public function testModifyData() $data = [ $modelId => [ \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\General::DATA_SOURCE_DEFAULT => [ - AttributeConstantsInterface::CODE_SKU => 'product_42', - AttributeConstantsInterface::CODE_PRICE => '42.00', - AttributeConstantsInterface::CODE_STATUS => '1', + ProductAttributeInterface::CODE_SKU => 'product_42', + ProductAttributeInterface::CODE_PRICE => '42.00', + ProductAttributeInterface::CODE_STATUS => '1', \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_MEDIA_GALLERY => [ 'images' => [ [ @@ -55,9 +55,9 @@ public function testModifyData() $expectedData = [ $modelId => [ General::DATA_SOURCE_DEFAULT => [ - AttributeConstantsInterface::CODE_SKU => 'product_42', - AttributeConstantsInterface::CODE_PRICE => '42.00', - AttributeConstantsInterface::CODE_STATUS => '1', + ProductAttributeInterface::CODE_SKU => 'product_42', + ProductAttributeInterface::CODE_PRICE => '42.00', + ProductAttributeInterface::CODE_STATUS => '1', ] ] ]; diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Grouper.php b/app/code/Magento/Catalog/Ui/DataProvider/Grouper.php deleted file mode 100644 index 2cdcca04847c5..0000000000000 --- a/app/code/Magento/Catalog/Ui/DataProvider/Grouper.php +++ /dev/null @@ -1,236 +0,0 @@ - false - ]; - - /** - * @var array - */ - protected $defaultGroupMeta = [ - 'formElement' => 'container', - 'componentType' => 'container', - 'component' => 'Magento_Ui/js/form/components/group', - 'dataScope' => '' - ]; - - /** - * @var array - */ - protected $defaultElementOptions = [ - 'autoDataScope' => true - ]; - - /** - * Return updated metadata with the set of elements put into a group - * - * @param array $meta - * @param array $elements - * @param array $groupOptions - * @return array - */ - public function groupMetaElements(array $meta, array $elements, array $groupOptions = []) - { - if (!$elements) { - return $meta; - } - - $grouped = true; - $this->meta = $meta; - $this->groupOptions = array_replace_recursive($this->defaultGroupOptions, $groupOptions); - $this->groupCode = null; - $this->elementCode = null; - $this->groupMeta = $this->defaultGroupMeta; - $this->elementsMeta = []; - - foreach ($elements as $elementCode => $elementOptions) { - if (!is_array($elementOptions)) { - $elementCode = $elementOptions; - $elementOptions = []; - } - - $meta = $this->applyElementRequiredOptions($meta, $elementCode, $elementOptions); - $grouped = $grouped && $this->handleElementOptions($meta, $elementCode, $elementOptions); - } - - if ($grouped) { - $this->meta[$this->groupCode]['children'][$this->elementCode] = array_replace_recursive( - $this->groupMeta, - ['children' => $this->elementsMeta] - ); - - return $this->meta; - } - - return $meta; - } - - /** - * Handle element options - * - * @param array $meta - * @param string $elementCode - * @param array $elementOptions - * @return bool - */ - protected function handleElementOptions(array $meta, $elementCode, array $elementOptions) - { - $groupCode = $this->getGroupCodeByField($meta, $elementCode); - - if (!$groupCode) { - return false; - } - - if (!$this->groupOptions['groupNonSiblings'] && $this->groupCode && $this->groupCode != $groupCode) { - return false; - } - - $elementOptions = array_replace_recursive($this->defaultElementOptions, $elementOptions); - $this->handleGroupOptions($meta, $groupCode, $elementCode, $elementOptions); - - $this->elementsMeta[$elementCode] = array_replace_recursive( - $meta[$groupCode]['children'][$elementCode], - isset($elementOptions['meta']) ? $elementOptions['meta'] : [] - ); - - if ($elementOptions['autoDataScope']) { - $this->elementsMeta[$elementCode]['dataScope'] = $elementCode; - } - - unset($this->meta[$groupCode]['children'][$elementCode]); - - return true; - } - - /** - * Apply only required portion of element options - * - * @param array $meta - * @param string $elementCode - * @param array $elementOptions - * @return array - */ - protected function applyElementRequiredOptions(array $meta, $elementCode, array $elementOptions) - { - if ($groupCode = $this->getGroupCodeByField($meta, $elementCode)) { - $meta[$groupCode]['children'][$elementCode] = array_replace_recursive( - $meta[$groupCode]['children'][$elementCode], - isset($elementOptions['requiredMeta']) ? $elementOptions['requiredMeta'] : [] - ); - } - - return $meta; - } - - /** - * Handle group options - * - * @param array $meta - * @param string $groupCode - * @param string $elementCode - * @param array $elementOptions - * @return void - */ - protected function handleGroupOptions(array $meta, $groupCode, $elementCode, array $elementOptions) - { - $isTarget = !empty($elementOptions['isTarget']); - - if (!$this->groupCode || $isTarget) { - $this->groupCode = $groupCode; - $this->elementCode = isset($this->groupOptions['targetCode']) - ? $this->groupOptions['targetCode'] - : $elementCode; - $this->groupMeta = array_replace_recursive( - $this->groupMeta, - [ - 'label' => $this->getElementOption($meta, $groupCode, $elementCode, 'label'), - 'sortOrder' => $this->getElementOption($meta, $groupCode, $elementCode, 'sortOrder') - ], - isset($this->groupOptions['meta']) ? $this->groupOptions['meta'] : [] - ); - } - } - - /** - * Retrieve element option from metadata - * - * @param array $meta - * @param string $groupCode - * @param string $elementCode - * @param string $optionName - * @param mixed $defaultValue - * @return mixed - */ - protected function getElementOption(array $meta, $groupCode, $elementCode, $optionName, $defaultValue = null) - { - return isset($meta[$groupCode]['children'][$elementCode][$optionName]) - ? $meta[$groupCode]['children'][$elementCode][$optionName] - : $defaultValue; - } - - /** - * Get group code by field - * - * @param array $meta - * @param string $field - * @return string|bool - */ - protected function getGroupCodeByField(array $meta, $field) - { - foreach ($meta as $groupCode => $groupData) { - if (isset($groupData['children'][$field])) { - return $groupCode; - } - } - - return false; - } -} diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php index ea952c8ea24b5..6a9379645d378 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php @@ -5,8 +5,8 @@ */ namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Model\Locator\LocatorInterface; -use Magento\Catalog\Model\AttributeConstantsInterface; use Magento\Directory\Helper\Data; use Magento\Store\Model\StoreManagerInterface; use Magento\Customer\Api\Data\GroupInterface; @@ -22,7 +22,6 @@ use Magento\Ui\Component\Form\Element\Select; use Magento\Ui\Component\Form\Field; use Magento\Ui\Component\Modal; -use Magento\Catalog\Ui\DataProvider\Grouper; use Magento\Framework\Stdlib\ArrayManager; /** @@ -37,11 +36,6 @@ class AdvancedPricing extends AbstractModifier */ protected $locator; - /** - * @var Grouper - */ - protected $grouper; - /** * @var ModuleManager */ @@ -89,7 +83,6 @@ class AdvancedPricing extends AbstractModifier /** * @param LocatorInterface $locator - * @param Grouper $grouper * @param StoreManagerInterface $storeManager * @param GroupRepositoryInterface $groupRepository * @param GroupManagementInterface $groupManagement @@ -101,7 +94,6 @@ class AdvancedPricing extends AbstractModifier */ public function __construct( LocatorInterface $locator, - Grouper $grouper, StoreManagerInterface $storeManager, GroupRepositoryInterface $groupRepository, GroupManagementInterface $groupManagement, @@ -111,7 +103,6 @@ public function __construct( ArrayManager $arrayManager ) { $this->locator = $locator; - $this->grouper = $grouper; $this->storeManager = $storeManager; $this->groupRepository = $groupRepository; $this->groupManagement = $groupManagement; @@ -128,9 +119,9 @@ public function modifyMeta(array $meta) { $this->meta = $meta; - $this->preparePriceFields(AttributeConstantsInterface::CODE_PRICE); - $this->preparePriceFields(AttributeConstantsInterface::CODE_SPECIAL_PRICE); - $this->preparePriceFields(AttributeConstantsInterface::CODE_COST); + $this->preparePriceFields(ProductAttributeInterface::CODE_PRICE); + $this->preparePriceFields(ProductAttributeInterface::CODE_SPECIAL_PRICE); + $this->preparePriceFields(ProductAttributeInterface::CODE_COST); $this->specialPriceDataToInline(); $this->customizeTierPrice(); @@ -185,7 +176,7 @@ protected function preparePriceFields($fieldCode) */ protected function customizeTierPrice() { - $tierPricePath = $this->getElementArrayPath($this->meta, AttributeConstantsInterface::CODE_TIER_PRICE); + $tierPricePath = $this->getElementArrayPath($this->meta, ProductAttributeInterface::CODE_TIER_PRICE); if ($tierPricePath) { $this->meta = $this->arrayManager->set( @@ -195,7 +186,7 @@ protected function customizeTierPrice() ); $this->meta = $this->arrayManager->set( $this->arrayManager->slicePath($tierPricePath, 0, -3) - . '/' . AttributeConstantsInterface::CODE_TIER_PRICE, + . '/' . ProductAttributeInterface::CODE_TIER_PRICE, $this->meta, $this->arrayManager->get($tierPricePath, $this->meta) ); @@ -246,7 +237,7 @@ protected function isScopeGlobal() { return $this->locator->getProduct() ->getResource() - ->getAttribute(AttributeConstantsInterface::CODE_TIER_PRICE) + ->getAttribute(ProductAttributeInterface::CODE_TIER_PRICE) ->isScopeGlobal(); } @@ -358,7 +349,7 @@ protected function isAllowChangeWebsite() */ protected function addAdvancedPriceLink() { - $pricePath = $this->getElementArrayPath($this->meta, AttributeConstantsInterface::CODE_PRICE); + $pricePath = $this->getElementArrayPath($this->meta, ProductAttributeInterface::CODE_PRICE); if ($pricePath) { $this->meta = $this->arrayManager->merge( @@ -613,7 +604,7 @@ protected function customizeAdvancedPricing() ]; $this->meta = $this->arrayManager->merge( - $this->getElementArrayPath($this->meta, static::CONTAINER_PREFIX . AttributeConstantsInterface::CODE_PRICE), + $this->getElementArrayPath($this->meta, static::CONTAINER_PREFIX . ProductAttributeInterface::CODE_PRICE), $this->meta, [ 'arguments' => [ diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php index 37390754e96d2..ce0a8749caaec 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier; -use Magento\Catalog\Model\AttributeConstantsInterface; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Model\Locator\LocatorInterface; use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory; use Magento\Store\Model\StoreManagerInterface; @@ -96,7 +96,7 @@ public function modifyMeta(array $meta) 'filterUrl' => $this->urlBuilder->getUrl('catalog/product/suggestAttributeSets', ['isAjax' => 'true']), 'sortOrder' => $this->getNextAttributeSortOrder( $meta, - [AttributeConstantsInterface::CODE_STATUS], + [ProductAttributeInterface::CODE_STATUS], self::ATTRIBUTE_SET_FIELD_ORDER ), 'multiple' => false, diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php index 3151dc0dc00a0..89a28bce38985 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php @@ -5,10 +5,9 @@ */ namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier; -use Magento\Catalog\Model\AttributeConstantsInterface; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Model\Locator\LocatorInterface; use Magento\Ui\Component\Form; -use Magento\Catalog\Ui\DataProvider\Grouper; use Magento\Framework\Stdlib\ArrayManager; /** @@ -21,11 +20,6 @@ class General extends AbstractModifier */ protected $locator; - /** - * @var Grouper - */ - protected $grouper; - /** * @var ArrayManager */ @@ -33,16 +27,13 @@ class General extends AbstractModifier /** * @param LocatorInterface $locator - * @param Grouper $grouper * @param ArrayManager $arrayManager */ public function __construct( LocatorInterface $locator, - Grouper $grouper, ArrayManager $arrayManager ) { $this->locator = $locator; - $this->grouper = $grouper; $this->arrayManager = $arrayManager; } @@ -55,8 +46,8 @@ public function modifyData(array $data) $data = $this->customizeAdvancedPriceFormat($data); $modelId = $this->locator->getProduct()->getId(); - if (!isset($data[$modelId][static::DATA_SOURCE_DEFAULT][AttributeConstantsInterface::CODE_STATUS])) { - $data[$modelId][static::DATA_SOURCE_DEFAULT][AttributeConstantsInterface::CODE_STATUS] = '1'; + if (!isset($data[$modelId][static::DATA_SOURCE_DEFAULT][ProductAttributeInterface::CODE_STATUS])) { + $data[$modelId][static::DATA_SOURCE_DEFAULT][ProductAttributeInterface::CODE_STATUS] = '1'; } return $data; @@ -73,10 +64,10 @@ protected function customizeNumberFormat(array $data) $model = $this->locator->getProduct(); $modelId = $model->getId(); $numberFields = [ - AttributeConstantsInterface::CODE_PRICE, - AttributeConstantsInterface::CODE_WEIGHT, - AttributeConstantsInterface::CODE_SPECIAL_PRICE, - AttributeConstantsInterface::CODE_COST, + ProductAttributeInterface::CODE_PRICE, + ProductAttributeInterface::CODE_WEIGHT, + ProductAttributeInterface::CODE_SPECIAL_PRICE, + ProductAttributeInterface::CODE_COST, ]; foreach ($numberFields as $fieldCode) { @@ -113,14 +104,14 @@ protected function formatNumber($number, $decimals = 2) protected function customizeAdvancedPriceFormat(array $data) { $modelId = $this->locator->getProduct()->getId(); - $fieldCode = AttributeConstantsInterface::CODE_TIER_PRICE; + $fieldCode = ProductAttributeInterface::CODE_TIER_PRICE; if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][$fieldCode])) { foreach ($data[$modelId][self::DATA_SOURCE_DEFAULT][$fieldCode] as &$value) { - $value[AttributeConstantsInterface::CODE_TIER_PRICE_FIELD_PRICE] = - $this->formatNumber($value[AttributeConstantsInterface::CODE_TIER_PRICE_FIELD_PRICE]); - $value[AttributeConstantsInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY] = - (int)$value[AttributeConstantsInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY]; + $value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE] = + $this->formatNumber($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]); + $value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY] = + (int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY]; } } @@ -182,7 +173,7 @@ protected function customizeStatusField(array $meta) ], ]; - $path = $this->getElementArrayPath($meta, AttributeConstantsInterface::CODE_STATUS); + $path = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_STATUS); $meta = $this->arrayManager->merge($path, $meta, $switcherConfig); return $meta; @@ -196,9 +187,9 @@ protected function customizeStatusField(array $meta) */ protected function customizeWeightField(array $meta) { - if ($weightPath = $this->getElementArrayPath($meta, AttributeConstantsInterface::CODE_WEIGHT)) { + if ($weightPath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_WEIGHT)) { if ($this->locator->getProduct()->getTypeId() !== \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL) { - $weightPath = $this->getElementArrayPath($meta, AttributeConstantsInterface::CODE_WEIGHT); + $weightPath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_WEIGHT); $meta = $this->arrayManager->merge( $weightPath, $meta, @@ -206,7 +197,7 @@ protected function customizeWeightField(array $meta) 'arguments' => [ 'data' => [ 'config' => [ - 'dataScope' => AttributeConstantsInterface::CODE_WEIGHT, + 'dataScope' => ProductAttributeInterface::CODE_WEIGHT, 'validation' => [ 'validate-number' => true, ], @@ -224,7 +215,7 @@ protected function customizeWeightField(array $meta) $containerPath = $this->getElementArrayPath( $meta, - static::CONTAINER_PREFIX . AttributeConstantsInterface::CODE_WEIGHT + static::CONTAINER_PREFIX . ProductAttributeInterface::CODE_WEIGHT ); $meta = $this->arrayManager->merge($containerPath, $meta, [ 'arguments' => [ @@ -237,7 +228,7 @@ protected function customizeWeightField(array $meta) ]); $hasWeightPath = $this->arrayManager->slicePath($weightPath, 0, -1) . '/' - . AttributeConstantsInterface::CODE_HAS_WEIGHT; + . ProductAttributeInterface::CODE_HAS_WEIGHT; $meta = $this->arrayManager->set( $hasWeightPath, $meta, @@ -266,25 +257,6 @@ protected function customizeWeightField(array $meta) ] ] ); - - $meta = $this->grouper->groupMetaElements( - $meta, - [AttributeConstantsInterface::CODE_WEIGHT, AttributeConstantsInterface::CODE_HAS_WEIGHT], - [ - 'meta' => [ - 'arguments' => [ - 'data' => [ - 'config' => [ - 'dataScope' => '', - 'breakLine' => false, - 'scopeLabel' => $this->arrayManager->get($weightPath . '/scopeLabel', $meta) - ], - ], - ], - ], - 'targetCode' => 'container_' . AttributeConstantsInterface::CODE_WEIGHT - ] - ); } } @@ -360,10 +332,10 @@ protected function customizeNewDateRangeField(array $meta) protected function customizeNameListeners(array $meta) { $listeners = [ - AttributeConstantsInterface::CODE_SKU, - AttributeConstantsInterface::CODE_SEO_FIELD_META_TITLE, - AttributeConstantsInterface::CODE_SEO_FIELD_META_KEYWORD, - AttributeConstantsInterface::CODE_SEO_FIELD_META_DESCRIPTION, + ProductAttributeInterface::CODE_SKU, + ProductAttributeInterface::CODE_SEO_FIELD_META_TITLE, + ProductAttributeInterface::CODE_SEO_FIELD_META_KEYWORD, + ProductAttributeInterface::CODE_SEO_FIELD_META_DESCRIPTION, ]; foreach ($listeners as $listener) { $listenerPath = $this->getElementArrayPath($meta, $listener); @@ -383,7 +355,7 @@ protected function customizeNameListeners(array $meta) $meta = $this->arrayManager->merge($listenerPath, $meta, $importsConfig); } - $skuPath = $this->getElementArrayPath($meta, AttributeConstantsInterface::CODE_SKU); + $skuPath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_SKU); $meta = $this->arrayManager->merge( $skuPath, $meta, @@ -399,7 +371,7 @@ protected function customizeNameListeners(array $meta) ] ); - $namePath = $this->getElementArrayPath($meta, AttributeConstantsInterface::CODE_NAME); + $namePath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_NAME); return $this->arrayManager->merge( $namePath, diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedInventoryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedInventoryTest.php index fdb6696c52efc..79f7bfeb06536 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedInventoryTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedInventoryTest.php @@ -8,7 +8,6 @@ use Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier\AbstractModifierTest; use Magento\CatalogInventory\Api\StockRegistryInterface; use Magento\CatalogInventory\Model\Source\Stock; -use Magento\Catalog\Ui\DataProvider\Grouper; use Magento\CatalogInventory\Api\Data\StockItemInterface; use Magento\Store\Model\Store; use Magento\CatalogInventory\Ui\DataProvider\Product\Form\Modifier\AdvancedInventory; @@ -18,11 +17,6 @@ */ class AdvancedInventoryTest extends AbstractModifierTest { - /** - * @var Grouper|\PHPUnit_Framework_MockObject_MockObject - */ - protected $grouperMock; - /** * @var Stock|\PHPUnit_Framework_MockObject_MockObject */ @@ -46,9 +40,6 @@ class AdvancedInventoryTest extends AbstractModifierTest protected function setUp() { parent::setUp(); - $this->grouperMock = $this->getMockBuilder(Grouper::class) - ->disableOriginalConstructor() - ->getMock(); $this->stockMock = $this->getMockBuilder(Stock::class) ->disableOriginalConstructor() ->getMock(); @@ -77,7 +68,6 @@ protected function createModel() { return $this->objectManager->getObject(AdvancedInventory::class, [ 'locator' => $this->locatorMock, - 'grouper' => $this->grouperMock, 'stockRegistry' => $this->stockRegistryMock, 'stock' => $this->stockMock, ]); diff --git a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php index 8e7d6a68a6e30..008bcbf87963e 100644 --- a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php +++ b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php @@ -9,7 +9,6 @@ use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier; use Magento\CatalogInventory\Api\StockRegistryInterface; use Magento\CatalogInventory\Model\Source\Stock; -use Magento\Catalog\Ui\DataProvider\Grouper; use Magento\Framework\Stdlib\ArrayManager; /** @@ -24,11 +23,6 @@ class AdvancedInventory extends AbstractModifier */ protected $locator; - /** - * @var Grouper - */ - protected $grouper; - /** * @var StockRegistryInterface */ @@ -51,20 +45,17 @@ class AdvancedInventory extends AbstractModifier /** * @param LocatorInterface $locator - * @param Grouper $grouper * @param Stock $stock * @param StockRegistryInterface $stockRegistry * @param ArrayManager $arrayManager */ public function __construct( LocatorInterface $locator, - Grouper $grouper, Stock $stock, StockRegistryInterface $stockRegistry, ArrayManager $arrayManager ) { $this->locator = $locator; - $this->grouper = $grouper; $this->stockRegistry = $stockRegistry; $this->stock = $stock; $this->arrayManager = $arrayManager; diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewriteTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewriteTest.php index f1c11fe564b38..e23f480bb8a38 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewriteTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewriteTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogUrlRewrite\Test\Unit\Ui\DataProvider\Product\Form\Modifier; -use Magento\Catalog\Model\AttributeConstantsInterface; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier\AbstractModifierTest; use Magento\CatalogUrlRewrite\Ui\DataProvider\Product\Form\Modifier\ProductUrlRewrite; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -47,7 +47,7 @@ public function testModifyMeta() $this->assertNotEmpty($this->getModel()->modifyMeta([ 'test_group_code' => [ 'children' => [ - AttributeConstantsInterface::CODE_SEO_FIELD_URL_KEY => [ + ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY => [ 'label' => 'label', 'scopeLabel' => 'scopeLabel', ], diff --git a/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php b/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php index e4af2c6a3f359..0c68bb1c5d2a8 100644 --- a/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php +++ b/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php @@ -5,11 +5,11 @@ */ namespace Magento\CatalogUrlRewrite\Ui\DataProvider\Product\Form\Modifier; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier; use Magento\Store\Model\ScopeInterface; use Magento\Catalog\Model\Locator\LocatorInterface; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Catalog\Model\AttributeConstantsInterface as AC; use Magento\Ui\Component\Form\Element\Checkbox; use Magento\Ui\Component\Form\Element\DataType\Text; use Magento\Ui\Component\Form\Field; @@ -80,7 +80,7 @@ public function modifyData(array $data) */ protected function addUrlRewriteCheckbox(array $meta) { - $urlPath = $this->getElementArrayPath($meta, AC::CODE_SEO_FIELD_URL_KEY); + $urlPath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY); if ($urlPath) { $containerPath = $this->arrayManager->slicePath($urlPath, 0, -2); @@ -111,7 +111,8 @@ protected function addUrlRewriteCheckbox(array $meta) 'true' => $urlKey ], 'imports' => [ - 'handleChanges' => '${ $.provider }:data.product.' . AC::CODE_SEO_FIELD_URL_KEY, + 'handleChanges' => '${ $.provider }:data.product.' + . ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY, ], 'description' => __('Create Permanent Redirect for old URL'), 'dataScope' => 'url_key_create_redirect', diff --git a/app/code/Magento/Downloadable/Api/Data/ProductAttributeInterface.php b/app/code/Magento/Downloadable/Api/Data/ProductAttributeInterface.php new file mode 100644 index 0000000000000..f05806d163314 --- /dev/null +++ b/app/code/Magento/Downloadable/Api/Data/ProductAttributeInterface.php @@ -0,0 +1,14 @@ +willReturn($typeId); $resultData = [ $productId => [ - AttributeConstantsInterface::CODE_IS_DOWNLOADABLE => $isDownloadable + ProductAttributeInterface::CODE_IS_DOWNLOADABLE => $isDownloadable ] ]; diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php index 654672d6b8d2d..33e275b7d36ff 100644 --- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php +++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php @@ -6,8 +6,8 @@ namespace Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier; -use Magento\Catalog\Model\AttributeConstantsInterface; use Magento\Catalog\Model\Locator\LocatorInterface; +use Magento\Downloadable\Api\Data\ProductAttributeInterface; use Magento\Downloadable\Model\Product\Type; use Magento\Framework\Stdlib\ArrayManager; use Magento\Ui\Component\Container; @@ -15,6 +15,7 @@ /** * Class adds Downloadable collapsible panel + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class DownloadablePanel extends AbstractModifier { @@ -50,7 +51,7 @@ public function modifyData(array $data) { $model = $this->locator->getProduct(); - $data[$model->getId()][AttributeConstantsInterface::CODE_IS_DOWNLOADABLE] = + $data[$model->getId()][ProductAttributeInterface::CODE_IS_DOWNLOADABLE] = ($model->getTypeId() === Type::TYPE_DOWNLOADABLE) ? '1' : '0'; return $data; @@ -95,7 +96,7 @@ protected function addMessageBox() 'visible' => false, 'imports' => [ 'visible' => '${$.provider}:' . self::DATA_SCOPE_PRODUCT . '.' - . AttributeConstantsInterface::CODE_HAS_WEIGHT + . ProductAttributeInterface::CODE_HAS_WEIGHT ], ]; @@ -109,18 +110,18 @@ protected function addMessageBox() */ protected function addCheckboxIsDownloadable() { - $checkboxPath = Composite::CHILDREN_PATH . '/' . AttributeConstantsInterface::CODE_IS_DOWNLOADABLE; + $checkboxPath = Composite::CHILDREN_PATH . '/' . ProductAttributeInterface::CODE_IS_DOWNLOADABLE; $checkboxConfig['arguments']['data']['config'] = [ 'dataType' => Form\Element\DataType\Number::NAME, 'formElement' => Form\Element\Checkbox::NAME, 'componentType' => Form\Field::NAME, 'component' => 'Magento_Downloadable/js/components/is-downloadable-handler', 'description' => __('Is this downloadable Product?'), - 'dataScope' => AttributeConstantsInterface::CODE_IS_DOWNLOADABLE, + 'dataScope' => ProductAttributeInterface::CODE_IS_DOWNLOADABLE, 'sortOrder' => 10, 'imports' => [ 'disabled' => '${$.provider}:' . self::DATA_SCOPE_PRODUCT . '.' - . AttributeConstantsInterface::CODE_HAS_WEIGHT + . ProductAttributeInterface::CODE_HAS_WEIGHT ], 'valueMap' => [ 'false' => '0', @@ -134,7 +135,7 @@ protected function addCheckboxIsDownloadable() 'formElement' => Form\Element\Hidden::NAME, 'componentType' => Form\Field::NAME, 'value' => '1', - 'dataScope' => AttributeConstantsInterface::CODE_IS_DOWNLOADABLE, + 'dataScope' => ProductAttributeInterface::CODE_IS_DOWNLOADABLE, 'sortOrder' => 10, ]; diff --git a/app/code/Magento/GiftMessage/Test/Unit/Ui/DataProvider/Product/Modifier/GiftMessageTest.php b/app/code/Magento/GiftMessage/Test/Unit/Ui/DataProvider/Product/Modifier/GiftMessageTest.php index dd1914c629924..c9b0163f329bc 100644 --- a/app/code/Magento/GiftMessage/Test/Unit/Ui/DataProvider/Product/Modifier/GiftMessageTest.php +++ b/app/code/Magento/GiftMessage/Test/Unit/Ui/DataProvider/Product/Modifier/GiftMessageTest.php @@ -35,7 +35,6 @@ protected function createModel() { return $this->objectManager->getObject(GiftMessage::class, [ 'locator' => $this->locatorMock, - 'grouper' => $this->grouperMock, 'scopeConfig' => $this->scopeConfigMock, ]); } diff --git a/app/code/Magento/Msrp/Test/Unit/Ui/DataProvider/Product/Form/Modifier/MsrpTest.php b/app/code/Magento/Msrp/Test/Unit/Ui/DataProvider/Product/Form/Modifier/MsrpTest.php index c0e55eb83d246..3e322c27280f2 100644 --- a/app/code/Magento/Msrp/Test/Unit/Ui/DataProvider/Product/Form/Modifier/MsrpTest.php +++ b/app/code/Magento/Msrp/Test/Unit/Ui/DataProvider/Product/Form/Modifier/MsrpTest.php @@ -7,7 +7,6 @@ use Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier\AbstractModifierTest; use Magento\Msrp\Ui\DataProvider\Product\Form\Modifier\Msrp; -use Magento\Catalog\Ui\DataProvider\Grouper; use Magento\Msrp\Model\Config as MsrpConfig; /** @@ -15,11 +14,6 @@ */ class MsrpTest extends AbstractModifierTest { - /** - * @var Grouper|\PHPUnit_Framework_MockObject_MockObject - */ - protected $grouperMock; - /** * @var MsrpConfig|\PHPUnit_Framework_MockObject_MockObject */ @@ -27,9 +21,6 @@ class MsrpTest extends AbstractModifierTest protected function setUp() { - $this->grouperMock = $this->getMockBuilder(Grouper::class) - ->disableOriginalConstructor() - ->getMock(); $this->msrpConfigMock = $this->getMockBuilder(MsrpConfig::class) ->disableOriginalConstructor() ->getMock(); @@ -43,7 +34,6 @@ protected function createModel() { return $this->objectManager->getObject(Msrp::class, [ 'locator' => $this->locatorMock, - 'grouper' => $this->grouperMock, 'msrpConfig' => $this->msrpConfigMock, ]); }