Skip to content

Commit

Permalink
Merge pull request #1163 from magento-tsg/develop-pr3
Browse files Browse the repository at this point in the history
Fixed issues:
- MAGETWO-69279 Sync upgrade script Magento/Catalog/Setup/UpgradeData.php between 2.1 and 2.2
- MAGETWO-54824 Can't save customer from admin if custom attribute is required and contains digit in code
- MAGETWO-65145 Performance degradation on front end on configurable products with huge amount of variation
  • Loading branch information
Oleksii Korshenko authored Jun 7, 2017
2 parents 2bc3bb0 + 81641fc commit de2308b
Show file tree
Hide file tree
Showing 30 changed files with 709 additions and 843 deletions.
86 changes: 43 additions & 43 deletions app/code/Magento/Catalog/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
*/
namespace Magento\Catalog\Setup;

use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;
Expand All @@ -30,7 +27,7 @@ class UpgradeData implements UpgradeDataInterface
/**
* EAV setup factory
*
* @var EavSetupFactory
* @var \Magento\Eav\Setup\EavSetupFactory
*/
private $eavSetupFactory;

Expand All @@ -43,12 +40,12 @@ class UpgradeData implements UpgradeDataInterface
* Constructor
*
* @param CategorySetupFactory $categorySetupFactory
* @param EavSetupFactory $eavSetupFactory
* @param \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
* @param UpgradeWidgetData $upgradeWidgetData
*/
public function __construct(
CategorySetupFactory $categorySetupFactory,
EavSetupFactory $eavSetupFactory,
\Magento\Eav\Setup\EavSetupFactory $eavSetupFactory,
UpgradeWidgetData $upgradeWidgetData
) {
$this->categorySetupFactory = $categorySetupFactory;
Expand Down Expand Up @@ -100,7 +97,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface

if (version_compare($context->getVersion(), '2.0.2') < 0) {
// set new resource model paths
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
/** @var CategorySetup $categorySetup */
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
$categorySetup->updateEntityType(
\Magento\Catalog\Model\Category::ENTITY,
Expand Down Expand Up @@ -141,69 +138,72 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
}

if (version_compare($context->getVersion(), '2.0.3') < 0) {
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
/** @var CategorySetup $categorySetup */
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
$categorySetup->updateAttribute(3, 54, 'default_value', 1);
}

if (version_compare($context->getVersion(), '2.0.4') < 0) {
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
$mediaBackendType = 'static';
$mediaBackendModel = null;
/** @var CategorySetup $categorySetup */
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
$categorySetup->updateAttribute(
'catalog_product',
'media_gallery',
'backend_type',
'static'
$mediaBackendType
);
$categorySetup->updateAttribute(
'catalog_product',
'media_gallery',
'backend_model'
'backend_model',
$mediaBackendModel
);
}

if (version_compare($context->getVersion(), '2.0.5', '<')) {
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
/** @var CategorySetup $categorySetup */
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);

//Product Details tab
$categorySetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
'status',
'frontend_label',
'Enable Product',
5
);
$categorySetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
'name',
'frontend_label',
'Product Name'
);
$attributeSetId = $categorySetup->getDefaultAttributeSetId(ProductAttributeInterface::ENTITY_TYPE_CODE);
$attributeSetId = $categorySetup->getDefaultAttributeSetId(\Magento\Catalog\Model\Product::ENTITY);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Product Details',
'visibility',
80
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Product Details',
'news_from_date',
90
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Product Details',
'news_to_date',
100
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Product Details',
'country_of_manufacture',
Expand All @@ -212,26 +212,26 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface

//Content tab
$categorySetup->addAttributeGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Content',
15
);
$categorySetup->updateAttributeGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Content',
'tab_group_code',
'basic'
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Content',
'description'
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Content',
'short_description',
Expand All @@ -240,53 +240,53 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface

//Images tab
$groupId = (int)$categorySetup->getAttributeGroupByCode(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'image-management',
'attribute_group_id'
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
$groupId,
'image',
1
);
$categorySetup->updateAttributeGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
$groupId,
'attribute_group_name',
'Images'
);
$categorySetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
'image',
'frontend_label',
'Base'
);
$categorySetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
'small_image',
'frontend_label',
'Small'
);
$categorySetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
'image',
'frontend_input_renderer',
null
);

//Design tab
$categorySetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
'page_layout',
'frontend_label',
'Layout'
);
$categorySetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
'custom_layout_update',
'frontend_label',
'Layout Update XML',
Expand All @@ -295,47 +295,47 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface

//Schedule Design Update tab
$categorySetup->addAttributeGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Schedule Design Update',
55
);
$categorySetup->updateAttributeGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Schedule Design Update',
'tab_group_code',
'advanced'
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Schedule Design Update',
'custom_design_from',
20
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Schedule Design Update',
'custom_design_to',
30
);
$categorySetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
'custom_design',
'frontend_label',
'New Theme',
40
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
$attributeSetId,
'Schedule Design Update',
'custom_design'
);
$categorySetup->addAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
'custom_layout',
[
'type' => 'varchar',
Expand All @@ -344,7 +344,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
'source' => \Magento\Catalog\Model\Product\Attribute\Source\Layout::class,
'required' => false,
'sort_order' => 50,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'group' => 'Schedule Design Update',
'is_used_in_grid' => true,
'is_visible_in_grid' => false,
Expand All @@ -358,7 +358,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$eavSetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
\Magento\Catalog\Model\Product::ENTITY,
'meta_description',
[
'note' => 'Maximum 255 chars. Meta Description should optimally be between 150-160 characters'
Expand All @@ -367,7 +367,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
}

if (version_compare($context->getVersion(), '2.1.3') < 0) {
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
/** @var CategorySetup $categorySetup */
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
$this->changePriceAttributeDefaultScope($categorySetup);
}
Expand All @@ -386,7 +386,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
* Set to 'No' 'Is Allowed Html on Store Front' option on product name attribute, because product name
* is multi entity field (used in order, quote) and cannot be conditionally escaped in all places
*
* @param ModuleDataSetupInterface $categorySetup
* @param ModuleDataSetupInterface $setup
* @return void
*/
private function dissallowUsingHtmlForProductName(ModuleDataSetupInterface $setup)
Expand All @@ -405,7 +405,7 @@ private function dissallowUsingHtmlForProductName(ModuleDataSetupInterface $setu
}

/**
* @param \Magento\Catalog\Setup\CategorySetup $categorySetup
* @param CategorySetup $categorySetup
* @return void
*/
private function changePriceAttributeDefaultScope($categorySetup)
Expand Down
Loading

0 comments on commit de2308b

Please sign in to comment.