diff --git a/CHANGELOG-PUBLIC.md b/CHANGELOG-PUBLIC.md index e35337a..107fc1a 100644 --- a/CHANGELOG-PUBLIC.md +++ b/CHANGELOG-PUBLIC.md @@ -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 + + diff --git a/CHANGELOG.MD b/CHANGELOG.MD index e35337a..107fc1a 100755 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -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 + + diff --git a/composer.json b/composer.json index 2fb09ce..864e463 100755 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/src/Setup/Patch/Data/InstallAvailabilityDateAttribute.php b/src/Setup/Patch/Data/InstallAvailabilityDateAttribute.php index 22a02a6..393fca0 100644 --- a/src/Setup/Patch/Data/InstallAvailabilityDateAttribute.php +++ b/src/Setup/Patch/Data/InstallAvailabilityDateAttribute.php @@ -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 @@ -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', @@ -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'); + } } diff --git a/src/Setup/Patch/Data/InstallCoreProductAttributes.php b/src/Setup/Patch/Data/InstallCoreProductAttributes.php index dab6058..20b0834 100644 --- a/src/Setup/Patch/Data/InstallCoreProductAttributes.php +++ b/src/Setup/Patch/Data/InstallCoreProductAttributes.php @@ -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 @@ -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', [ @@ -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); + } + } + } } diff --git a/src/Setup/Patch/Data/InstallCrossBorderAttributes.php b/src/Setup/Patch/Data/InstallCrossBorderAttributes.php index 0e3fb9f..0819b22 100644 --- a/src/Setup/Patch/Data/InstallCrossBorderAttributes.php +++ b/src/Setup/Patch/Data/InstallCrossBorderAttributes.php @@ -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 @@ -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'); + } } diff --git a/src/Setup/Patch/Data/InstallDestTypeAttributes.php b/src/Setup/Patch/Data/InstallDestTypeAttributes.php index 56b1c79..1b5be5a 100644 --- a/src/Setup/Patch/Data/InstallDestTypeAttributes.php +++ b/src/Setup/Patch/Data/InstallDestTypeAttributes.php @@ -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; @@ -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'); @@ -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'); + } } diff --git a/src/Setup/Patch/Data/InstallDimensionalProductAttributes.php b/src/Setup/Patch/Data/InstallDimensionalProductAttributes.php index 64b653c..abe5692 100644 --- a/src/Setup/Patch/Data/InstallDimensionalProductAttributes.php +++ b/src/Setup/Patch/Data/InstallDimensionalProductAttributes.php @@ -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 @@ -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); + } + } + } } diff --git a/src/Setup/Patch/Data/InstallFreightAttributes.php b/src/Setup/Patch/Data/InstallFreightAttributes.php index 0a68ae5..e565e73 100644 --- a/src/Setup/Patch/Data/InstallFreightAttributes.php +++ b/src/Setup/Patch/Data/InstallFreightAttributes.php @@ -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 @@ -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); + } + } + } } diff --git a/src/Setup/Patch/Data/UpdateCustomerAddressDestTypeAttribute.php b/src/Setup/Patch/Data/UpdateCustomerAddressDestTypeAttribute.php index e5b680a..c1a74d5 100644 --- a/src/Setup/Patch/Data/UpdateCustomerAddressDestTypeAttribute.php +++ b/src/Setup/Patch/Data/UpdateCustomerAddressDestTypeAttribute.php @@ -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 @@ -79,4 +80,6 @@ public function getAliases() { return []; } + + public function revert() {} } diff --git a/src/Setup/Patch/Data/UpdateIgnoreEmptyZipConfig.php b/src/Setup/Patch/Data/UpdateIgnoreEmptyZipConfig.php index d94b767..286fdac 100644 --- a/src/Setup/Patch/Data/UpdateIgnoreEmptyZipConfig.php +++ b/src/Setup/Patch/Data/UpdateIgnoreEmptyZipConfig.php @@ -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 @@ -68,4 +69,6 @@ public function getAliases() { return []; } + + public function revert() {} } diff --git a/src/Setup/Patch/Data/UpdateMagentoVersionInConfig.php b/src/Setup/Patch/Data/UpdateMagentoVersionInConfig.php index f20a3d7..5006495 100644 --- a/src/Setup/Patch/Data/UpdateMagentoVersionInConfig.php +++ b/src/Setup/Patch/Data/UpdateMagentoVersionInConfig.php @@ -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 @@ -67,4 +68,6 @@ public function getAliases() { return []; } + + public function revert() {} } diff --git a/src/Setup/Patch/Data/UpdateMustShipFreightAttribute.php b/src/Setup/Patch/Data/UpdateMustShipFreightAttribute.php index faab172..b010ea1 100644 --- a/src/Setup/Patch/Data/UpdateMustShipFreightAttribute.php +++ b/src/Setup/Patch/Data/UpdateMustShipFreightAttribute.php @@ -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 @@ -76,4 +77,6 @@ public function getAliases() { return []; } + + public function revert() {} } diff --git a/src/Setup/Uninstall.php b/src/Setup/Uninstall.php deleted file mode 100644 index 221120e..0000000 --- a/src/Setup/Uninstall.php +++ /dev/null @@ -1,233 +0,0 @@ -categorySetupFactory = $categorySetupFactory; - $this->moduleDataSetup = $moduleDataSetupInterface; - } - - /** - * {@inheritdoc} - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context) - { - $setup->startSetup(); - - // Quote tables - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_quote_item_detail"); - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_quote_address_item_detail"); - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_quote_address_detail"); - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_quote_package_items"); - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_quote_packages"); - - // Order tables - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_order_item_detail"); - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_order_package_items"); - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_order_packages"); - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_order_detail"); - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_order_detail_grid"); - $setup->getConnection(self::$connectionName)->dropTable("shipperhq_synchronize"); - - // Instantiate setup classes - $catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]); - - // Remove quote table columns - $quoteColumns = [ - 'carrier_type', - 'carrier_id', - 'carriergroup_shipping_details', - 'is_checkout', - 'split_rates', - 'checkout_display_merged', - 'carriergroup_shipping_html', - 'destination_type', - 'validation_status', - 'validated_country_code', - 'validated_vat_number', - 'carriergroup_id', - 'carriergroup', - 'shq_dispatch_date', - 'shq_delivery_date' - ]; - - foreach ($quoteColumns as $attributeName) { - try { - $setup->getConnection(self::$connectionName)->dropColumn('quote_address', $attributeName); - $setup->getConnection(self::$connectionName)->dropColumn('quote_shipping_rate', $attributeName); - } catch (Exception $exception) { - //Do nothing - } - } - - // Remove quote item columns - $quoteItemColumns = [ - 'carriergroup', - 'carriergroup_id', - 'carriergroup_shipping', - ]; - - foreach ($quoteItemColumns as $attributeName) { - try { - $setup->getConnection(self::$connectionName)->dropColumn('quote_item', $attributeName); - $setup->getConnection(self::$connectionName)->dropColumn('quote_address_item', $attributeName); - } catch (Exception $exception) { - //Do nothing - } - } - - // Remove customer columns - $customerAddressAttributes = [ - 'destination_type', - 'validation_status' - ]; - - foreach ($customerAddressAttributes as $attributeName) { - try { - $catalogSetup->removeAttribute('customer_address', $attributeName); - } catch (Exception $exception) { - //Do nothing - } - } - - // Remove order columns - $orderColumns = [ - 'carrier_type', - 'carrier_id', - 'carriergroup_shipping_details', - 'carriergroup_shipping_html', - 'destination_type', - 'validation_status', - 'carriergroup_shipping', - 'carriergroup' - ]; - - foreach ($orderColumns as $attributeName) { - try { - $setup->getConnection(self::$connectionName)->dropColumn('sales_order', $attributeName); - $setup->getConnection(self::$connectionName)->dropColumn('sales_order_item', $attributeName); - } catch (Exception $exception) { - //Do nothing - } - } - - $setup->endSetup(); - - /* - * Remove catalogue attributes - this is intentionally AFTER endSetup because we want the foreign key checks to be enabled - * such that when we delete the attribute, its removed from ALL tables - * - * See https://community.magento.com/t5/Magento-DevBlog/Mysterious-startSetup-and-endSetup-Methods/ba-p/68483 - */ - $catalogueAttributeNames = [ - 'shipperhq_shipping_group', - 'shipperhq_post_shipping_group', - 'shipperhq_location', - 'shipperhq_royal_mail_group', - 'shipperhq_shipping_qty', - 'shipperhq_shipping_fee', - 'shipperhq_additional_price', - 'freight_class', - 'shipperhq_nmfc_class', - 'shipperhq_nmfc_sub', - 'shipperhq_handling_fee', - 'shipperhq_carrier_code', - 'shipperhq_volume_weight', - 'shipperhq_declared_value', - 'ship_separately', - 'shipperhq_dim_group', - 'shipperhq_poss_boxes', - 'shipperhq_master_boxes', - 'ship_box_tolerance', - 'must_ship_freight', - 'packing_section_name', - 'shipperhq_availability_date', - 'shipperhq_hs_code', - 'ship_height', - 'ship_width', - 'ship_length', - 'shipperhq_warehouse', - 'shipperhq_malleable_product' - ]; - - foreach ($catalogueAttributeNames as $attributeName) { - try { - $catalogSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeName); - } catch (Exception $exception) { - //Do nothing - } - } - } -} diff --git a/src/composer.json b/src/composer.json index 5b1617b..730a36f 100644 --- a/src/composer.json +++ b/src/composer.json @@ -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" diff --git a/src/etc/config.xml b/src/etc/config.xml index bc892fb..4c34c91 100755 --- a/src/etc/config.xml +++ b/src/etc/config.xml @@ -67,7 +67,7 @@ 30 0 1 - 20.50.2 + 20.51.0 300 diff --git a/src/view/frontend/web/template/billing-address/details.html b/src/view/frontend/web/template/billing-address/details.html index 2b35582..8e2cfce 100644 --- a/src/view/frontend/web/template/billing-address/details.html +++ b/src/view/frontend/web/template/billing-address/details.html @@ -18,16 +18,18 @@

- - - -
+ + + + +
+ + +
+ - -
- - -
+
+