moduleDataSetup = $moduleDataSetup; $this->categorySetupFactory = $categorySetupFactory; } /** * {@inheritdoc} */ public function apply() { /** @var CategorySetup $categorySetup */ $categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]); $this->changePriceAttributeDefaultScope($categorySetup); } /** * @param CategorySetup $categorySetup * @return void */ private function changePriceAttributeDefaultScope($categorySetup) { $entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY); foreach (['price', 'cost', 'special_price'] as $attributeCode) { $attribute = $categorySetup->getAttribute($entityTypeId, $attributeCode); if (isset($attribute['attribute_id'])) { $categorySetup->updateAttribute( $entityTypeId, $attribute['attribute_id'], 'is_global', \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL ); } } } /** * {@inheritdoc} */ public static function getDependencies() { return [ UpdateProductMetaDescription::class, ]; } /** * {@inheritdoc} */ public static function getVersion() { return '2.1.3'; } /** * {@inheritdoc} */ public function getAliases() { return []; } }