Skip to content

Commit

Permalink
Merge pull request #36 from webshopapps/SHQ16-2123_A
Browse files Browse the repository at this point in the history
SHQ16-2123 Upgrade script to remove migration attribute groups
  • Loading branch information
wsagen authored Jul 3, 2017
2 parents 8aa7b34 + f893157 commit 1d3bff0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Magento Issues Impacting ShipperHQ
- Magento issue number/patch reference: MDVA-791 - contact Enterprise support for patch
5. Error thrown when placing an order with some shipping methods. Root cause is that some shipping methods have shipping method codes longer than the column length on quote for shipping_method field. Field is truncating the code and order cannot be placed.
- Github Issue: https://github.com/magento/magento2/issues/6475
6. Free shipping via cart rules are never removed once they have been applied, even if conditions are no longer met
- Github Issue: https://github.com/magento/magento2/issues/7388


Contribution
Expand Down
5 changes: 4 additions & 1 deletion src/Setup/InstallData.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface

foreach ($attributeSetArr as $attributeSetId) {
//SHQ16-2123 handle migrated instances from M1 to M2
$catalogSetup->removeAttributeGroup($entityTypeId, $attributeSetId, 'migration-shipping');
$migrated = $catalogSetup->getAttributeGroup($entityTypeId, $attributeSetId, 'migration-shipping');
if ($migrated !== false) {
$catalogSetup->removeAttributeGroup($entityTypeId, $attributeSetId, 'migration-shipping');
}

$catalogSetup->addAttributeGroup($entityTypeId, $attributeSetId, 'Shipping', '99');

Expand Down
16 changes: 13 additions & 3 deletions src/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
}

//1.0.12
if ($context->getVersion() && version_compare($context->getVersion(), '1.0.12') < 0) {
if (version_compare($context->getVersion(), '1.0.12') < 0) {
$this->installFreightAttributes($catalogSetup);
}

Expand Down Expand Up @@ -468,7 +468,14 @@ private function installAttributes($catalogSetup)

foreach ($attributeSetArr as $attributeSetId) {
//SHQ16-2123 handle migrated instances from M1 to M2
$catalogSetup->removeAttributeGroup($entityTypeId, $attributeSetId, 'migration-dimensional-shipping');
$migrated = $catalogSetup->getAttributeGroup(
$entityTypeId,
$attributeSetId,
'migration-dimensional-shipping'
);
if($migrated !== false) {
$catalogSetup->removeAttributeGroup($entityTypeId, $attributeSetId, 'migration-dimensional-shipping');
}

$attributeGroupId = $catalogSetup->getAttributeGroup(
$entityTypeId,
Expand Down Expand Up @@ -587,7 +594,10 @@ private function installFreightAttributes($catalogSetup)

foreach ($attributeSetArr as $attributeSetId) {
//SHQ16-2123 handle migrated instances from M1 to M2
$catalogSetup->removeAttributeGroup($entityTypeId, $attributeSetId, 'migration-freight-shipping');
$migrated = $catalogSetup->getAttributeGroup($entityTypeId, $attributeSetId, 'migration-freight-shipping');
if ($migrated !== false) {
$catalogSetup->removeAttributeGroup($entityTypeId, $attributeSetId, 'migration-freight-shipping');
}

$attributeGroupId = $catalogSetup->getAttributeGroup(
$entityTypeId,
Expand Down

0 comments on commit 1d3bff0

Please sign in to comment.