Skip to content

Commit

Permalink
20.51.0 MNB-2933 Fix issue with trying to access variables before the…
Browse files Browse the repository at this point in the history
…y exist in templates. MNB-2865 Add revert (uninstall) methods to all setup patches
  • Loading branch information
wsajosh committed Sep 14, 2022
1 parent b5aaf01 commit 321086b
Show file tree
Hide file tree
Showing 19 changed files with 210 additions and 281 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-PUBLIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,3 +712,7 @@ MNB-2863 Fix error thrown when Magento inventory is disabled
MNB-2869 Add check for street lines being present in checkout


## 20.51.0 (2022-09-14)
MNB-2933 Fix issue with trying to access variables before they exist in templates. MNB-2865 Add revert (uninstall) methods to all setup patches


4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -712,3 +712,7 @@ MNB-2863 Fix error thrown when Magento inventory is disabled
MNB-2869 Add check for street lines being present in checkout


## 20.51.0 (2022-09-14)
MNB-2933 Fix issue with trying to access variables before they exist in templates. MNB-2865 Add revert (uninstall) methods to all setup patches


2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shipperhq/module-shipper",
"description": "Magento Shipping integration with ShipperHQ",
"type": "magento2-module",
"version": "20.50.2",
"version": "20.51.0",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
11 changes: 10 additions & 1 deletion src/Setup/Patch/Data/InstallAvailabilityDateAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;

class InstallAvailabilityDateAttribute implements DataPatchInterface
class InstallAvailabilityDateAttribute implements DataPatchInterface, PatchRevertableInterface
{
/**
* @var ModuleDataSetupInterface $moduleDataSetup
Expand Down Expand Up @@ -58,6 +59,7 @@ public static function getVersion()
*/
public function apply()
{
/** @var \Magento\Catalog\Setup\CategorySetup $catalogSetup */
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
$catalogSetup->addAttribute(Product::ENTITY, 'shipperhq_availability_date', [
'type' => 'datetime',
Expand Down Expand Up @@ -86,4 +88,11 @@ public function getAliases()
{
return [];
}

public function revert()
{
/** @var \Magento\Catalog\Setup\CategorySetup $catalogSetup */
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
$catalogSetup->removeAttribute(Product::ENTITY, 'shipperhq_availability_date');
}
}
32 changes: 31 additions & 1 deletion src/Setup/Patch/Data/InstallCoreProductAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;

class InstallCoreProductAttributes implements DataPatchInterface
class InstallCoreProductAttributes implements DataPatchInterface, PatchRevertableInterface
{
/**
* Category setup factory
Expand Down Expand Up @@ -74,6 +75,7 @@ public static function getVersion()
*/
public function apply()
{
/** @var \Magento\Catalog\Setup\CategorySetup $catalogSetup */
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
/* ------ shipperhq_shipping_group -------- */
$catalogSetup->addAttribute(Product::ENTITY, 'shipperhq_shipping_group', [
Expand Down Expand Up @@ -217,4 +219,32 @@ public function getAliases()
{
return [];
}

public function revert()
{
/** @var \Magento\Catalog\Setup\CategorySetup $catalogSetup */
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);

$attributeCodes = ['shipperhq_shipping_group', 'shipperhq_warehouse', 'shipperhq_hs_code'];

foreach ($attributeCodes as $attributeCode) {
$catalogSetup->removeAttribute(Product::ENTITY, $attributeCode);
}

$entityTypeId = $catalogSetup->getEntityTypeId(Product::ENTITY);
$attributeSets = $catalogSetup->getAllAttributeSetIds($entityTypeId);

foreach ($attributeSets as $attributeSet) {
$attributeGroupId = $catalogSetup->getAttributeGroupId(
$entityTypeId,
$attributeSet,
'Shipping'
);


if ($attributeGroupId) {
$catalogSetup->removeAttributeGroup($entityTypeId, $attributeSet, $attributeGroupId);
}
}
}
}
11 changes: 10 additions & 1 deletion src/Setup/Patch/Data/InstallCrossBorderAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;

class InstallCrossBorderAttributes implements DataPatchInterface
class InstallCrossBorderAttributes implements DataPatchInterface, PatchRevertableInterface
{
/**
* @var ModuleDataSetupInterface $moduleDataSetup
Expand Down Expand Up @@ -122,4 +123,12 @@ public function getAliases()
{
return [];
}

public function revert()
{
/** @var \Magento\Catalog\Setup\CategorySetup $catalogSetup */
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);

$catalogSetup->removeAttribute(Product::ENTITY, 'shipperhq_hs_code');
}
}
13 changes: 12 additions & 1 deletion src/Setup/Patch/Data/InstallDestTypeAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace ShipperHQ\Shipper\Setup\Patch\Data;

use Magento\Catalog\Model\Product;
use Magento\Customer\Setup\CustomerSetup;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\ModuleDataSetupInterface;
Expand Down Expand Up @@ -63,7 +65,7 @@ public static function getVersion()
*/
public function apply()
{
/** @var QuoteSetup $quoteSetup */
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);

$existingDestTypeAttribute = $customerSetup->getAttribute('customer_address', 'destination_type');
Expand Down Expand Up @@ -120,4 +122,13 @@ public function getAliases()
{
return [];
}

public function revert()
{
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);

$customerSetup->removeAttribute('customer_address', 'destination_type');
$customerSetup->removeAttribute('customer_address', 'validation_status');
}
}
44 changes: 43 additions & 1 deletion src/Setup/Patch/Data/InstallDimensionalProductAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

use Magento\Catalog\Model\Product;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Customer\Setup\CustomerSetup;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory as AttributeCollectionFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;

class InstallDimensionalProductAttributes implements DataPatchInterface
class InstallDimensionalProductAttributes implements DataPatchInterface, PatchRevertableInterface
{
/**
* Category setup factory
Expand Down Expand Up @@ -392,4 +394,44 @@ public function getAliases()
{
return [];
}

public function revert()
{
/** @var \Magento\Catalog\Setup\CategorySetup $catalogSetup */
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);

$attributeCodes = [
'shipperhq_shipping_fee',
'shipperhq_handling_fee',
'shipperhq_volume_weight',
'shipperhq_declared_value',
'ship_separately',
'shipperhq_dim_group',
'ship_length',
'ship_width',
'ship_height',
'shipperhq_poss_boxes',
'shipperhq_malleable_product',
'shipperhq_master_boxes'
];

foreach ($attributeCodes as $attributeCode) {
$catalogSetup->removeAttribute(Product::ENTITY, $attributeCode);
}

$entityTypeId = $catalogSetup->getEntityTypeId(Product::ENTITY);
$attributeSets = $catalogSetup->getAllAttributeSetIds($entityTypeId);

foreach ($attributeSets as $attributeSet) {
$attributeGroupId = $catalogSetup->getAttributeGroupId(
$entityTypeId,
$attributeSet,
'Dimensional Shipping'
);

if ($attributeGroupId) {
$catalogSetup->removeAttributeGroup($entityTypeId, $attributeSet, $attributeGroupId);
}
}
}
}
35 changes: 34 additions & 1 deletion src/Setup/Patch/Data/InstallFreightAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;

class InstallFreightAttributes implements DataPatchInterface
class InstallFreightAttributes implements DataPatchInterface, PatchRevertableInterface
{
/**
* @var ModuleDataSetupInterface $moduleDataSetup
Expand Down Expand Up @@ -240,4 +241,36 @@ public function getAliases()
{
return [];
}

public function revert()
{
/** @var \Magento\Catalog\Setup\CategorySetup $catalogSetup */
$catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);

$attributeCodes = [
'freight_class',
'shipperhq_nmfc_class',
'must_ship_freight',
'shipperhq_nmfc_sub'
];

foreach ($attributeCodes as $attributeCode) {
$catalogSetup->removeAttribute(Product::ENTITY, $attributeCode);
}

$entityTypeId = $catalogSetup->getEntityTypeId(Product::ENTITY);
$attributeSets = $catalogSetup->getAllAttributeSetIds($entityTypeId);

foreach ($attributeSets as $attributeSet) {
$attributeGroupId = $catalogSetup->getAttributeGroupId(
$entityTypeId,
$attributeSet,
'Freight Shipping'
);

if ($attributeGroupId) {
$catalogSetup->removeAttributeGroup($entityTypeId, $attributeSet, $attributeGroupId);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;

class UpdateCustomerAddressDestTypeAttribute implements DataPatchInterface
class UpdateCustomerAddressDestTypeAttribute implements DataPatchInterface, PatchRevertableInterface
{
/**
* @var ModuleDataSetupInterface $moduleDataSetup
Expand Down Expand Up @@ -79,4 +80,6 @@ public function getAliases()
{
return [];
}

public function revert() {}
}
5 changes: 4 additions & 1 deletion src/Setup/Patch/Data/UpdateIgnoreEmptyZipConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
use Magento\Quote\Setup\QuoteSetup;
use Magento\Quote\Setup\QuoteSetupFactory;
use Magento\Sales\Setup\SalesSetupFactory;

class UpdateIgnoreEmptyZipConfig implements DataPatchInterface
class UpdateIgnoreEmptyZipConfig implements DataPatchInterface, PatchRevertableInterface
{
/**
* @var WriterInterface
Expand Down Expand Up @@ -68,4 +69,6 @@ public function getAliases()
{
return [];
}

public function revert() {}
}
5 changes: 4 additions & 1 deletion src/Setup/Patch/Data/UpdateMagentoVersionInConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
use Magento\Framework\App\ProductMetadata;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;

class UpdateMagentoVersionInConfig implements DataPatchInterface
class UpdateMagentoVersionInConfig implements DataPatchInterface, PatchRevertableInterface
{
/**
* @var WriterInterface
Expand Down Expand Up @@ -67,4 +68,6 @@ public function getAliases()
{
return [];
}

public function revert() {}
}
5 changes: 4 additions & 1 deletion src/Setup/Patch/Data/UpdateMustShipFreightAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;

class UpdateMustShipFreightAttribute implements DataPatchInterface
class UpdateMustShipFreightAttribute implements DataPatchInterface, PatchRevertableInterface
{
/**
* @var ModuleDataSetupInterface $moduleDataSetup
Expand Down Expand Up @@ -76,4 +77,6 @@ public function getAliases()
{
return [];
}

public function revert() {}
}
Loading

0 comments on commit 321086b

Please sign in to comment.