From 859b0098e46692463ea7e708de83e4f48e131e3f Mon Sep 17 00:00:00 2001 From: livca Date: Thu, 20 Apr 2023 17:06:55 +0200 Subject: [PATCH 01/10] 1220935 - fix module-store-delivery - compatibility Magento 2.4.6 and PHP8.2 --- Block/Checkout/LayoutProcessor.php | 92 ++++++++++--------- CHANGELOG.md | 16 ++++ Model/Carrier.php | 14 +-- Observer/QuoteSubmit.php | 20 ++-- Plugin/Checkout/Api/SaveAddressPlugin.php | 40 ++++---- Plugin/Quote/Api/ShipmentEstimationPlugin.php | 18 ++-- .../Api/ShippingMethodManagementPlugin.php | 17 ++-- .../ConvertQuoteAddressToOrderAddress.php | 22 +++-- .../SaveCheckoutFieldsObserverPlugin.php | 55 ----------- README.md | 2 +- Setup/InstallData.php | 24 ++--- Setup/InstallSchema.php | 11 ++- composer.json | 7 +- etc/di.xml | 5 +- 14 files changed, 164 insertions(+), 179 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 Plugin/Temando/SaveCheckoutFieldsObserverPlugin.php diff --git a/Block/Checkout/LayoutProcessor.php b/Block/Checkout/LayoutProcessor.php index 902d23b..0fbfea2 100644 --- a/Block/Checkout/LayoutProcessor.php +++ b/Block/Checkout/LayoutProcessor.php @@ -13,11 +13,19 @@ namespace Smile\StoreDelivery\Block\Checkout; use Magento\Checkout\Block\Checkout\LayoutProcessorInterface; +use Magento\Framework\App\CacheInterface; +use Magento\Framework\UrlInterface; use Magento\Shipping\Model\CarrierFactoryInterface; use Smile\Map\Api\MapInterface; +use Smile\Map\Api\MapProviderInterface; use Smile\Map\Model\AddressFormatter; use Smile\Retailer\Api\Data\RetailerInterface; +use Smile\Retailer\Model\ResourceModel\Retailer\Collection; use Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory; +use Smile\StoreDelivery\Model\Carrier; +use Smile\StoreLocator\Helper\Data; +use Smile\StoreLocator\Helper\Schedule; +use Smile\StoreLocator\Model\Retailer\ScheduleManagement; /** * Specific JS Layout processor for StoreDelivery. @@ -32,76 +40,76 @@ class LayoutProcessor implements LayoutProcessorInterface /** * @var string */ - private $methodCode = \Smile\StoreDelivery\Model\Carrier::METHOD_CODE; + private string $methodCode = Carrier::METHOD_CODE; /** * @var MapInterface */ - private $map; + private MapInterface $map; /** * @var CollectionFactory */ - private $retailerCollectionFactory; + private CollectionFactory $retailerCollectionFactory; /** - * @var \Smile\StoreLocator\Helper\Data + * @var Data */ - private $storeLocatorHelper; + private Data $storeLocatorHelper; /** - * @var \Smile\Map\Model\AddressFormatter + * @var AddressFormatter */ - private $addressFormatter; + private AddressFormatter $addressFormatter; /** - * @var \Smile\StoreLocator\Helper\Schedule + * @var Schedule */ - private $scheduleHelper; + private Schedule $scheduleHelper; /** - * @var \Smile\StoreLocator\Model\Retailer\ScheduleManagement + * @var ScheduleManagement */ - private $scheduleManager; + private ScheduleManagement $scheduleManager; /** - * @var \Magento\Shipping\Model\CarrierFactoryInterface + * @var CarrierFactoryInterface */ - private $carrierFactory; + private CarrierFactoryInterface $carrierFactory; /** - * @var \Magento\Framework\UrlInterface + * @var UrlInterface */ - private $urlBuilder; + private UrlInterface $urlBuilder; /** - * @var \Magento\Framework\App\CacheInterface + * @var CacheInterface */ - private $cache; + private CacheInterface $cache; /** * Constructor. * - * @param \Smile\Map\Api\MapProviderInterface $mapProvider Map provider. - * @param \Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory $retailerCollectionFactory Retailer collection factory. - * @param \Smile\StoreLocator\Helper\Data $storeLocatorHelper Store locator helper. - * @param \Smile\Map\Model\AddressFormatter $addressFormatter Address formatter tool. - * @param \Smile\StoreLocator\Helper\Schedule $scheduleHelper Schedule Helper - * @param \Smile\StoreLocator\Model\Retailer\ScheduleManagement $scheduleManagement Schedule Management - * @param CarrierFactoryInterface $carrierFactory Carrier Factory - * @param \Magento\Framework\UrlInterface $urlBuilder URL Builder - * @param \Magento\Framework\App\CacheInterface $cacheInterface Cache Interface + * @param MapProviderInterface $mapProvider $mapProvider Map provider. + * @param CollectionFactory $retailerCollectionFactory Retailer collection factory. + * @param Data $storeLocatorHelper Store locator helper. + * @param AddressFormatter $addressFormatter Address formatter tool. + * @param Schedule $scheduleHelper Schedule Helper + * @param ScheduleManagement $scheduleManagement Schedule Management + * @param CarrierFactoryInterface $carrierFactory Carrier Factory + * @param UrlInterface $urlBuilder URL Builder + * @param CacheInterface $cacheInterface Cache Interface */ public function __construct( - \Smile\Map\Api\MapProviderInterface $mapProvider, - \Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory $retailerCollectionFactory, - \Smile\StoreLocator\Helper\Data $storeLocatorHelper, - \Smile\Map\Model\AddressFormatter $addressFormatter, - \Smile\StoreLocator\Helper\Schedule $scheduleHelper, - \Smile\StoreLocator\Model\Retailer\ScheduleManagement $scheduleManagement, - CarrierFactoryInterface $carrierFactory, - \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Framework\App\CacheInterface $cacheInterface + MapProviderInterface $mapProvider, + CollectionFactory $retailerCollectionFactory, + Data $storeLocatorHelper, + AddressFormatter $addressFormatter, + Schedule $scheduleHelper, + ScheduleManagement $scheduleManagement, + CarrierFactoryInterface $carrierFactory, + UrlInterface $urlBuilder, + CacheInterface $cacheInterface ) { $this->map = $mapProvider->getMap(); $this->retailerCollectionFactory = $retailerCollectionFactory; @@ -117,7 +125,7 @@ public function __construct( /** * {@inheritdoc} */ - public function process($jsLayout) + public function process($jsLayout): array { if ($this->carrierFactory->getIfActive($this->methodCode)) { // @codingStandardsIgnoreStart @@ -164,7 +172,7 @@ public function process($jsLayout) * * @return array */ - private function getStores() + private function getStores(): array { $collection = $this->getRetailerCollection(); $cacheKey = sprintf("%s_%s", 'checkout_storedelivery', $collection->getStoreId()); @@ -214,9 +222,9 @@ private function getStores() /** * Collection of displayed retailers. * - * @return \Smile\Retailer\Model\ResourceModel\Retailer\Collection + * @return Collection */ - private function getRetailerCollection() + private function getRetailerCollection(): Collection { $retailerCollection = $this->retailerCollectionFactory->create(); $retailerCollection->addAttributeToSelect( @@ -232,11 +240,11 @@ private function getRetailerCollection() /** * Get the JSON post data used to build the set store link. * - * @param \Smile\Retailer\Api\Data\RetailerInterface $retailer The store + * @param RetailerInterface $retailer The store * - * @return string + * @return array */ - private function getSetStorePostData($retailer) + private function getSetStorePostData($retailer): array { $setUrl = $this->urlBuilder->getUrl('storelocator/store/set'); $postData = ['id' => $retailer->getId()]; diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e1ea53b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [2.0.x] - 2023-04-12 +[2.0.x]: https://github.com/Smile-SA/magento2-module-store-delivery/compare/1.2.x...2.0.x + +Dataset compatibility ES 2.11.x and PHP 8.2 + +- fix Dynamic type declaration +- fix Type hinting +- Replace `Zend_Date` by `DateTime` +- Replace `Zend_Validator` by `DateTime` +- Remove `MutationObserver` support +- fix UI Component Retailer Offer editing +- remove Temando Plugin diff --git a/Model/Carrier.php b/Model/Carrier.php index 558044d..6f80ff1 100644 --- a/Model/Carrier.php +++ b/Model/Carrier.php @@ -14,8 +14,10 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\DataObject; +use Magento\Quote\Model\Quote\Address\RateResult\Method; use Magento\Shipping\Model\Carrier\AbstractCarrier; use Magento\Shipping\Model\Carrier\CarrierInterface; +use Magento\Shipping\Model\Rate\Result; use Magento\Shipping\Model\Rate\ResultFactory; use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory; use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory; @@ -52,12 +54,12 @@ class Carrier extends AbstractCarrier implements CarrierInterface /** * @var ResultFactory */ - protected $rateResultFactory; + protected ResultFactory $rateResultFactory; /** * @var MethodFactory */ - protected $rateMethodFactory; + protected MethodFactory $rateMethodFactory; /** * Carrier constructor @@ -85,7 +87,7 @@ public function __construct( /** * {@inheritdoc} */ - public function getAllowedMethods() + public function getAllowedMethods(): array { return [$this->getCarrierCode() => __($this->getConfigData('name'))]; } @@ -93,16 +95,16 @@ public function getAllowedMethods() /** * {@inheritdoc} */ - public function collectRates(RateRequest $request) + public function collectRates(RateRequest $request): false|Result { if (!$this->getConfigFlag('active')) { return false; } - /** @var \Magento\Shipping\Model\Rate\Result $result */ + /** @var Result $result */ $result = $this->rateResultFactory->create(); - /** @var \Magento\Quote\Model\Quote\Address\RateResult\Method $method */ + /** @var Method $method */ $method = $this->rateMethodFactory->create(); $method->setCarrier($this->getCarrierCode()); diff --git a/Observer/QuoteSubmit.php b/Observer/QuoteSubmit.php index c1ee44b..217aaef 100644 --- a/Observer/QuoteSubmit.php +++ b/Observer/QuoteSubmit.php @@ -12,8 +12,12 @@ */ namespace Smile\StoreDelivery\Observer; +use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; +use Magento\Quote\Api\Data\AddressInterface; +use Magento\Quote\Api\Data\CartInterface; use Magento\Shipping\Model\CarrierFactoryInterface; +use Smile\StoreDelivery\Model\Carrier; /** * Observer to ensure Billing Address has required fields when using StoreDelivery shipping Method. @@ -25,14 +29,14 @@ class QuoteSubmit implements ObserverInterface { /** - * @var \Magento\Shipping\Model\CarrierFactoryInterface + * @var CarrierFactoryInterface */ - private $carrierFactory; + private CarrierFactoryInterface $carrierFactory; /** * QuoteSubmit constructor. * - * @param \Magento\Shipping\Model\CarrierFactoryInterface $carrierFactory Carrier Factory + * @param CarrierFactoryInterface $carrierFactory Carrier Factory */ public function __construct(CarrierFactoryInterface $carrierFactory) { @@ -47,19 +51,19 @@ public function __construct(CarrierFactoryInterface $carrierFactory) * * @event checkout_submit_before * - * @param \Magento\Framework\Event\Observer $observer The observer + * @param Observer $observer The observer */ - public function execute(\Magento\Framework\Event\Observer $observer) + public function execute(Observer $observer): void { - /** @var \Magento\Quote\Api\Data\CartInterface $quote */ + /** @var CartInterface $quote */ $quote = $observer->getQuote(); - /** @var \Magento\Quote\Api\Data\AddressInterface $shippingAddress */ + /** @var AddressInterface $shippingAddress */ $shippingAddress = $quote->getShippingAddress(); if ($shippingAddress) { $shippingMethod = $shippingAddress->getShippingMethod(); if ($shippingMethod) { - $methodCode = \Smile\StoreDelivery\Model\Carrier::METHOD_CODE; + $methodCode = Carrier::METHOD_CODE; $carrier = $this->carrierFactory->getIfActive($methodCode); if ($carrier && $shippingMethod === sprintf('%s_%s', $methodCode, $carrier->getCarrierCode())) { $billingAddress = $quote->getBillingAddress(); diff --git a/Plugin/Checkout/Api/SaveAddressPlugin.php b/Plugin/Checkout/Api/SaveAddressPlugin.php index 76ae949..aa67697 100644 --- a/Plugin/Checkout/Api/SaveAddressPlugin.php +++ b/Plugin/Checkout/Api/SaveAddressPlugin.php @@ -12,6 +12,10 @@ */ namespace Smile\StoreDelivery\Plugin\Checkout\Api; +use Magento\Checkout\Api\Data\ShippingInformationInterface; +use Magento\Checkout\Api\ShippingInformationManagementInterface; +use Magento\Customer\Api\Data\AddressInterfaceFactory; +use Magento\Customer\Model\Session; use Smile\Retailer\Api\RetailerRepositoryInterface; /** @@ -24,29 +28,29 @@ class SaveAddressPlugin { /** - * @var \Magento\Customer\Model\Session + * @var Session */ - private $customerSession; + private Session $customerSession; /** - * @var \Smile\Retailer\Api\RetailerRepositoryInterface + * @var RetailerRepositoryInterface */ - private $retailerRepository; + private RetailerRepositoryInterface $retailerRepository; /** - * @var \Magento\Customer\Api\Data\AddressInterfaceFactory + * @var AddressInterfaceFactory */ - private $addressDataFactory; + private AddressInterfaceFactory $addressDataFactory; /** - * @param RetailerRepositoryInterface $retailerRepository Retailer Repository - * @param \Magento\Customer\Model\Session $customerSession Customer session - * @param \Magento\Customer\Api\Data\AddressInterfaceFactory $addressInterfaceFactory Address Factory + * @param RetailerRepositoryInterface $retailerRepository Retailer Repository + * @param Session $customerSession Customer session + * @param AddressInterfaceFactory $addressInterfaceFactory Address Factory */ public function __construct( RetailerRepositoryInterface $retailerRepository, - \Magento\Customer\Model\Session $customerSession, - \Magento\Customer\Api\Data\AddressInterfaceFactory $addressInterfaceFactory + Session $customerSession, + AddressInterfaceFactory $addressInterfaceFactory ) { $this->retailerRepository = $retailerRepository; $this->customerSession = $customerSession; @@ -57,17 +61,17 @@ public function __construct( * Convert Store Address to Shipping Address * @SuppressWarnings(PHPMD.UnusedFormalParameter) * - * @param \Magento\Checkout\Api\ShippingInformationManagementInterface $subject Shipping Information Management - * @param int $cartId Cart Id - * @param \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation Address Information + * @param ShippingInformationManagementInterface $subject Shipping Information Management + * @param mixed $cartId Cart Id + * @param ShippingInformationInterface $addressInformation Address Information * * @return void */ public function beforeSaveAddressInformation( - \Magento\Checkout\Api\ShippingInformationManagementInterface $subject, - $cartId, - \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation - ) { + ShippingInformationManagementInterface $subject, + mixed $cartId, + ShippingInformationInterface $addressInformation + ): void { $shippingAddress = $addressInformation->getShippingAddress(); $billingAddress = $addressInformation->getBillingAddress(); diff --git a/Plugin/Quote/Api/ShipmentEstimationPlugin.php b/Plugin/Quote/Api/ShipmentEstimationPlugin.php index f0fd712..93a56c5 100644 --- a/Plugin/Quote/Api/ShipmentEstimationPlugin.php +++ b/Plugin/Quote/Api/ShipmentEstimationPlugin.php @@ -12,6 +12,8 @@ */ namespace Smile\StoreDelivery\Plugin\Quote\Api; +use Magento\Quote\Api\Data\AddressInterface; +use Magento\Quote\Api\Data\ShippingMethodInterface; use Magento\Quote\Api\ShipmentEstimationInterface; /** @@ -28,23 +30,23 @@ class ShipmentEstimationPlugin * Ensure StoreDelivery is the only available shipping method for store delivery addresses. * @SuppressWarnings(PHPMD.UnusedFormalParameter) * - * @param \Magento\Quote\Api\ShipmentEstimationInterface $subject Shipment Estimation Interface - * @param \Closure $proceed The estimateByExtendedAddress method - * @param mixed $cartId The cart Id - * @param \Magento\Quote\Api\Data\AddressInterface $address The Shipping Address + * @param ShipmentEstimationInterface $subject Shipment Estimation Interface + * @param \Closure $proceed The estimateByExtendedAddress method + * @param mixed $cartId The cart Id + * @param AddressInterface $address The Shipping Address * * @return mixed */ public function aroundEstimateByExtendedAddress( ShipmentEstimationInterface $subject, \Closure $proceed, - $cartId, - \Magento\Quote\Api\Data\AddressInterface $address - ) { + mixed $cartId, + AddressInterface $address + ): mixed { $shippingMethods = $proceed($cartId, $address); // If shipping address is linked to a retailer, remove all methods except Store Delivery. - /** @var \Magento\Quote\Api\Data\ShippingMethodInterface $shippingMethod */ + /** @var ShippingMethodInterface $shippingMethod */ foreach ($shippingMethods as $key => $shippingMethod) { if (($address->getExtensionAttributes() && $address->getExtensionAttributes()->getRetailerId() && ($shippingMethod->getMethodCode() !== \Smile\StoreDelivery\Model\Carrier::METHOD_CODE)) || diff --git a/Plugin/Quote/Api/ShippingMethodManagementPlugin.php b/Plugin/Quote/Api/ShippingMethodManagementPlugin.php index a2ed4f2..1b9e128 100644 --- a/Plugin/Quote/Api/ShippingMethodManagementPlugin.php +++ b/Plugin/Quote/Api/ShippingMethodManagementPlugin.php @@ -12,6 +12,7 @@ */ namespace Smile\StoreDelivery\Plugin\Quote\Api; +use Magento\Quote\Api\Data\ShippingMethodInterface; use Magento\Quote\Api\ShippingMethodManagementInterface; use Smile\StoreDelivery\Model\Carrier; @@ -28,22 +29,22 @@ class ShippingMethodManagementPlugin * Remove StoreDelivery from available methods when estimating by address Id (existing customer addresses). * @SuppressWarnings(PHPMD.UnusedFormalParameter) * - * @param \Magento\Quote\Api\ShippingMethodManagementInterface $subject Shipping Method Management - * @param \Closure $proceed estimateByAddressId() method - * @param int $cartId The shopping cart ID. - * @param int $addressId The estimate address id + * @param ShippingMethodManagementInterface $subject Shipping Method Management + * @param \Closure $proceed estimateByAddressId() method + * @param mixed $cartId The shopping cart ID. + * @param mixed $addressId The estimate address id * * @return mixed */ public function aroundEstimateByAddressId( ShippingMethodManagementInterface $subject, \Closure $proceed, - $cartId, - $addressId - ) { + mixed $cartId, + mixed $addressId + ): mixed { $shippingMethods = $proceed($cartId, $addressId); - /** @var \Magento\Quote\Api\Data\ShippingMethodInterface $shippingMethod */ + /** @var ShippingMethodInterface $shippingMethod */ foreach ($shippingMethods as $key => $shippingMethod) { if ($shippingMethod->getMethodCode() === Carrier::METHOD_CODE) { unset($shippingMethods[$key]); diff --git a/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php b/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php index b5924bb..6d5c9ce 100644 --- a/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php +++ b/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php @@ -12,6 +12,10 @@ */ namespace Smile\StoreDelivery\Plugin\Quote\Model; +use Magento\Quote\Model\Quote\Address; +use Magento\Quote\Model\Quote\Address\ToOrderAddress; +use Magento\Sales\Api\Data\OrderAddressInterface; + /** * Plugin to copy "retailer_id" field from quote_address to order_address. * Done via a plugin because fieldset.xml does not seem to work. @@ -25,20 +29,20 @@ class ConvertQuoteAddressToOrderAddress { /** - * @param \Magento\Quote\Model\Quote\Address\ToOrderAddress $subject The converter - * @param \Closure $proceed Converter convert() method - * @param \Magento\Quote\Model\Quote\Address $quoteAddress Quote Address - * @param array $data Data + * @param ToOrderAddress $subject The converter + * @param \Closure $proceed Converter convert() method + * @param Address $quoteAddress Quote Address + * @param array $data Data * - * @return \Magento\Sales\Api\Data\OrderAddressInterface Order Address + * @return OrderAddressInterface Order Address * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundConvert( - \Magento\Quote\Model\Quote\Address\ToOrderAddress $subject, + ToOrderAddress $subject, \Closure $proceed, - \Magento\Quote\Model\Quote\Address $quoteAddress, - $data = [] - ) { + Address $quoteAddress, + array $data = [] + ): OrderAddressInterface { $orderAddress = $proceed($quoteAddress, $data); if ($quoteAddress->getRetailerId()) { $orderAddress->setRetailerId($quoteAddress->getRetailerId()); diff --git a/Plugin/Temando/SaveCheckoutFieldsObserverPlugin.php b/Plugin/Temando/SaveCheckoutFieldsObserverPlugin.php deleted file mode 100644 index 2ec4f29..0000000 --- a/Plugin/Temando/SaveCheckoutFieldsObserverPlugin.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright 2018 Smile - * @license Open Software License ("OSL") v. 3.0 - */ -namespace Smile\StoreDelivery\Plugin\Temando; - -/** - * This observer is here to prevent erratic behavior of Temando module. @see https://github.com/magento/magento2/issues/12921 - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - */ -class SaveCheckoutFieldsObserverPlugin -{ - /** - * Better check than what is done in the Temando Observer which is thinking he is the only one adding extension - * attributes to the Quote address. - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @param \Temando\Shipping\Observer\SaveCheckoutFieldsObserver $subject Base Temando Observer - * @param \Closure $proceed execute() method of Temando Observer - * @param \Magento\Framework\Event\Observer $observer Magento Event Observer - */ - public function aroundExecute( - \Temando\Shipping\Observer\SaveCheckoutFieldsObserver $subject, - \Closure $proceed, - \Magento\Framework\Event\Observer $observer - ) { - /** @var \Magento\Quote\Api\Data\AddressInterface|\Magento\Quote\Model\Quote\Address $quoteAddress */ - $quoteAddress = $observer->getData('quote_address'); - if ($quoteAddress->getAddressType() !== \Magento\Quote\Model\Quote\Address::ADDRESS_TYPE_SHIPPING) { - return; - } - - if (!$quoteAddress->getExtensionAttributes()) { - return; - } - - if (!$quoteAddress->getExtensionAttributes()->getCheckoutFields()) { - return; - } - - $proceed($observer); - } -} diff --git a/README.md b/README.md index ca52de4..f35ec3e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This module add the ability to be delivered in store. Store delivery is a shippi The module requires : -- [Store Locator](https://github.com/Smile-SA/magento2-module-store-locator) > 1.2.* +- [Store Locator](https://github.com/Smile-SA/magento2-module-store-locator) > 2.2.* ### How to use diff --git a/Setup/InstallData.php b/Setup/InstallData.php index 28f5dd9..32b2b1f 100644 --- a/Setup/InstallData.php +++ b/Setup/InstallData.php @@ -32,26 +32,26 @@ class InstallData implements InstallDataInterface { /** - * @var \Magento\Sales\Setup\SalesSetupFactory + * @var SalesSetupFactory */ - private $salesSetupFactory; + private SalesSetupFactory $salesSetupFactory; /** - * @var \Magento\Quote\Setup\QuoteSetupFactory + * @var QuoteSetupFactory */ - private $quoteSetupFactory; + private QuoteSetupFactory $quoteSetupFactory; /** - * @var \Magento\Eav\Setup\EavSetupFactory + * @var EavSetupFactory */ - private $eavSetupFactory; + private EavSetupFactory $eavSetupFactory; /** * InstallData constructor. * - * @param \Magento\Sales\Setup\SalesSetupFactory $salesSetupFactory Sales Setup - * @param \Magento\Quote\Setup\QuoteSetupFactory $quoteSetupFactory Quote Setup - * @param \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory EAV Setup Factory. + * @param SalesSetupFactory $salesSetupFactory Sales Setup + * @param QuoteSetupFactory $quoteSetupFactory Quote Setup + * @param EavSetupFactory $eavSetupFactory EAV Setup Factory. */ public function __construct( SalesSetupFactory $salesSetupFactory, @@ -67,7 +67,7 @@ public function __construct( /** * {@inheritdoc} */ - public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) + public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context): void { $setup->startSetup(); @@ -85,7 +85,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface * * @param ModuleDataSetupInterface $setup Data Setup */ - private function addSalesAttributes($setup) + private function addSalesAttributes($setup): void { /** @var \Magento\Sales\Setup\SalesSetup $salesSetup */ $salesSetup = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]); @@ -111,7 +111,7 @@ private function addSalesAttributes($setup) * * @param \Magento\Eav\Setup\EavSetup $eavSetup EAV module Setup */ - private function addShopAttributes($eavSetup) + private function addShopAttributes($eavSetup): void { $entityId = SellerInterface::ENTITY; $attrSetId = RetailerInterface::ATTRIBUTE_SET_RETAILER; diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php index b8efce4..8a8b42a 100644 --- a/Setup/InstallSchema.php +++ b/Setup/InstallSchema.php @@ -12,6 +12,7 @@ */ namespace Smile\StoreDelivery\Setup; +use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Setup\InstallSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; @@ -27,16 +28,16 @@ class InstallSchema implements InstallSchemaInterface { /** - * @var \Magento\Framework\App\ProductMetadataInterface + * @var ProductMetadataInterface */ - private $metadata; + private ProductMetadataInterface $metadata; /** * InstallSchema constructor. * - * @param \Magento\Framework\App\ProductMetadataInterface $metadata Magento metadata + * @param ProductMetadataInterface $metadata Magento metadata */ - public function __construct(\Magento\Framework\App\ProductMetadataInterface $metadata) + public function __construct(ProductMetadataInterface $metadata) { $this->metadata = $metadata; } @@ -44,7 +45,7 @@ public function __construct(\Magento\Framework\App\ProductMetadataInterface $met /** * {@inheritdoc} */ - public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) + public function install(SchemaSetupInterface $setup, ModuleContextInterface $context): void { $setup->startSetup(); diff --git a/composer.json b/composer.json index d09e500..b7f3cac 100644 --- a/composer.json +++ b/composer.json @@ -10,13 +10,14 @@ } ], "require": { - "magento/framework": "*", + "php": "^8.1", + "magento/framework": ">=103.0.4", "magento/module-store": "*", "magento/module-checkout": "*", - "smile/module-store-locator": "~1.3.0 || ~2.0.0" + "smile/module-store-locator": "~2.2.0" }, "require-dev": { - "smile/magento2-smilelab-quality-suite": "^1.0.5" + "smile/magento2-smilelab-quality-suite": "^3.0" }, "license": "OSL-3.0", "authors": [ diff --git a/etc/di.xml b/etc/di.xml index e017e15..5711a8d 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -33,8 +33,5 @@ - - - - + From 549ba0d06e139d80f9c6aeba498e6b02b6b6d5d2 Mon Sep 17 00:00:00 2001 From: livca Date: Mon, 24 Apr 2023 09:59:36 +0200 Subject: [PATCH 02/10] #1220935 - test composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b7f3cac..f2a8936 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "magento/framework": ">=103.0.4", "magento/module-store": "*", "magento/module-checkout": "*", - "smile/module-store-locator": "~2.2.0" + "smile/module-store-locator": "dev-fix-compatibility-2-4-6" }, "require-dev": { "smile/magento2-smilelab-quality-suite": "^3.0" From 384998a2cf463aabc6f50c100ae625953a67ea33 Mon Sep 17 00:00:00 2001 From: livca Date: Mon, 24 Apr 2023 16:16:33 +0200 Subject: [PATCH 03/10] #1220935 - update changelog and restore composer target --- CHANGELOG.md | 9 ++++++--- composer.json | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1ea53b..9996db4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. -## [2.0.x] - 2023-04-12 +## [2.0.x] - 2023-04-24 [2.0.x]: https://github.com/Smile-SA/magento2-module-store-delivery/compare/1.2.x...2.0.x Dataset compatibility ES 2.11.x and PHP 8.2 @@ -10,7 +10,10 @@ Dataset compatibility ES 2.11.x and PHP 8.2 - fix Dynamic type declaration - fix Type hinting - Replace `Zend_Date` by `DateTime` -- Replace `Zend_Validator` by `DateTime` - Remove `MutationObserver` support - fix UI Component Retailer Offer editing -- remove Temando Plugin +- Replace `Zend_Validate` by `Laminas\Validator` +- fix Retailer Grid Column Action +- fix Retailer Grid Mass Actions +- fix some translations +- remove Temando/Shipping Plugin diff --git a/composer.json b/composer.json index f2a8936..b7f3cac 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "magento/framework": ">=103.0.4", "magento/module-store": "*", "magento/module-checkout": "*", - "smile/module-store-locator": "dev-fix-compatibility-2-4-6" + "smile/module-store-locator": "~2.2.0" }, "require-dev": { "smile/magento2-smilelab-quality-suite": "^3.0" From 73569753b03f9e63bc84804f461ed2ace5452afe Mon Sep 17 00:00:00 2001 From: guvra Date: Thu, 25 May 2023 16:48:10 +0200 Subject: [PATCH 04/10] Use updated SmileLab coding standard --- .gitattributes | 8 + .gitignore | 6 + Block/Checkout/LayoutProcessor.php | 143 ++++-------------- Model/Carrier.php | 76 ++-------- Observer/QuoteSubmit.php | 44 +----- Plugin/Checkout/Api/SaveAddressPlugin.php | 51 +------ Plugin/Quote/Api/ShipmentEstimationPlugin.php | 42 ++--- .../Api/ShippingMethodManagementPlugin.php | 27 +--- .../ConvertQuoteAddressToOrderAddress.php | 28 +--- Setup/InstallData.php | 97 +++--------- Setup/InstallSchema.php | 38 +---- composer.json | 33 ++-- etc/adminhtml/system.xml | 14 -- etc/config.xml | 15 -- etc/di.xml | 16 -- etc/events.xml | 16 +- etc/extension_attributes.xml | 16 +- etc/fieldset.xml | 20 +-- etc/frontend/di.xml | 14 -- etc/module.xml | 14 -- phpcs.xml.dist | 27 ++++ phpmd.xml.dist | 10 ++ phpstan.neon.dist | 11 ++ registration.php | 18 +-- .../ui_component/smile_retailer_listing.xml | 16 -- view/frontend/layout/checkout_index_index.xml | 15 -- view/frontend/requirejs-config.js | 14 -- view/frontend/web/css/source/_module.less | 16 -- view/frontend/web/js/model/empty-address.js | 16 -- .../shipping-rate-processor/store-delivery.js | 1 - .../shipping-save-processor/store-delivery.js | 16 -- view/frontend/web/js/model/store-address.js | 16 -- .../view/checkout/shipping/store-delivery.js | 21 +-- .../address-renderer/default.js | 17 --- .../address-renderer/store-delivery.js | 5 - .../view/shipping-address/store-delivery.js | 17 --- 36 files changed, 201 insertions(+), 753 deletions(-) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 phpcs.xml.dist create mode 100644 phpmd.xml.dist create mode 100644 phpstan.neon.dist diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..14e897f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +/.github export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/CHANGELOG.md export-ignore +/phpcs.xml.dist export-ignore +/phpmd.xml.dist export-ignore +/phpstan.neon.dist export-ignore +/README.md export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..437d97f --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.fleet +/.idea +/vendor +/composer.lock +/phpcs.xml +/phpstan.neon diff --git a/Block/Checkout/LayoutProcessor.php b/Block/Checkout/LayoutProcessor.php index 0fbfea2..8250416 100644 --- a/Block/Checkout/LayoutProcessor.php +++ b/Block/Checkout/LayoutProcessor.php @@ -1,15 +1,5 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + namespace Smile\StoreDelivery\Block\Checkout; use Magento\Checkout\Block\Checkout\LayoutProcessorInterface; @@ -30,102 +20,30 @@ /** * Specific JS Layout processor for StoreDelivery. * Inject Map, Geolocation and Stores into checkout UI Components. - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud */ class LayoutProcessor implements LayoutProcessorInterface { - /** - * @var string - */ private string $methodCode = Carrier::METHOD_CODE; - - /** - * @var MapInterface - */ private MapInterface $map; - /** - * @var CollectionFactory - */ - private CollectionFactory $retailerCollectionFactory; - - /** - * @var Data - */ - private Data $storeLocatorHelper; - - /** - * @var AddressFormatter - */ - private AddressFormatter $addressFormatter; - - /** - * @var Schedule - */ - private Schedule $scheduleHelper; - - /** - * @var ScheduleManagement - */ - private ScheduleManagement $scheduleManager; - - /** - * @var CarrierFactoryInterface - */ - private CarrierFactoryInterface $carrierFactory; - - /** - * @var UrlInterface - */ - private UrlInterface $urlBuilder; - - /** - * @var CacheInterface - */ - private CacheInterface $cache; - - /** - * Constructor. - * - * @param MapProviderInterface $mapProvider $mapProvider Map provider. - * @param CollectionFactory $retailerCollectionFactory Retailer collection factory. - * @param Data $storeLocatorHelper Store locator helper. - * @param AddressFormatter $addressFormatter Address formatter tool. - * @param Schedule $scheduleHelper Schedule Helper - * @param ScheduleManagement $scheduleManagement Schedule Management - * @param CarrierFactoryInterface $carrierFactory Carrier Factory - * @param UrlInterface $urlBuilder URL Builder - * @param CacheInterface $cacheInterface Cache Interface - */ public function __construct( - MapProviderInterface $mapProvider, - CollectionFactory $retailerCollectionFactory, - Data $storeLocatorHelper, - AddressFormatter $addressFormatter, - Schedule $scheduleHelper, - ScheduleManagement $scheduleManagement, - CarrierFactoryInterface $carrierFactory, - UrlInterface $urlBuilder, - CacheInterface $cacheInterface + MapProviderInterface $mapProvider, + private CollectionFactory $retailerCollectionFactory, + private Data $storeLocatorHelper, + private AddressFormatter $addressFormatter, + private Schedule $scheduleHelper, + private ScheduleManagement $scheduleManagement, + private CarrierFactoryInterface $carrierFactory, + private UrlInterface $urlBuilder, + private CacheInterface $cache ) { - $this->map = $mapProvider->getMap(); - $this->retailerCollectionFactory = $retailerCollectionFactory; - $this->storeLocatorHelper = $storeLocatorHelper; - $this->addressFormatter = $addressFormatter; - $this->scheduleHelper = $scheduleHelper; - $this->scheduleManager = $scheduleManagement; - $this->carrierFactory = $carrierFactory; - $this->urlBuilder = $urlBuilder; - $this->cache = $cacheInterface; + $this->map = $mapProvider->getMap(); } /** - * {@inheritdoc} + * @inheritdoc */ - public function process($jsLayout): array + public function process($jsLayout) { if ($this->carrierFactory->getIfActive($this->methodCode)) { // @codingStandardsIgnoreStart @@ -136,8 +54,8 @@ public function process($jsLayout): array // @codingStandardsIgnoreEnd $storeDelivery['provider'] = $this->map->getIdentifier(); - $storeDelivery['markers'] = $this->getStores(); - $storeDelivery = array_merge($storeDelivery, $this->map->getConfig()); + $storeDelivery['markers'] = $this->getStores(); + $storeDelivery = array_merge($storeDelivery, $this->map->getConfig()); // @codingStandardsIgnoreStart $jsLayout['components']['checkout']['children']['steps']['children'] @@ -154,7 +72,7 @@ public function process($jsLayout): array // @codingStandardsIgnoreEnd $geocoder['provider'] = $this->map->getIdentifier(); - $geocoder = array_merge($geocoder, $this->map->getConfig()); + $geocoder = array_merge($geocoder, $this->map->getConfig()); // @codingStandardsIgnoreStart $jsLayout['components']['checkout']['children']['steps']['children'] @@ -169,8 +87,6 @@ public function process($jsLayout): array /** * List of markers displayed on the map. - * - * @return array */ private function getStores(): array { @@ -185,22 +101,23 @@ private function getStores(): array $address = $retailer->getExtensionAttributes()->getAddress(); $coords = $address->getCoordinates(); $markerData = [ - 'id' => $retailer->getId(), - 'latitude' => $coords->getLatitude(), - 'longitude' => $coords->getLongitude(), - 'name' => $retailer->getName(), - 'address' => $this->addressFormatter->formatAddress($address, AddressFormatter::FORMAT_ONELINE), - 'url' => $this->storeLocatorHelper->getRetailerUrl($retailer), + 'id' => $retailer->getId(), + 'latitude' => $coords->getLatitude(), + 'longitude' => $coords->getLongitude(), + 'name' => $retailer->getName(), + 'address' => $this->addressFormatter->formatAddress($address, AddressFormatter::FORMAT_ONELINE), + 'url' => $this->storeLocatorHelper->getRetailerUrl($retailer), 'directionUrl' => $this->map->getDirectionUrl($address->getCoordinates()), 'setStoreData' => $this->getSetStorePostData($retailer), - 'addressData' => $address->getData(), + 'addressData' => $address->getData(), ]; + // phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge $markerData['schedule'] = array_merge( $this->scheduleHelper->getConfig(), [ - 'calendar' => $this->scheduleManager->getCalendar($retailer), - 'openingHours' => $this->scheduleManager->getWeekOpeningHours($retailer), + 'calendar' => $this->scheduleManagement->getCalendar($retailer), + 'openingHours' => $this->scheduleManagement->getWeekOpeningHours($retailer), 'specialOpeningHours' => $retailer->getExtensionAttributes()->getSpecialOpeningHours(), ] ); @@ -221,8 +138,6 @@ private function getStores(): array /** * Collection of displayed retailers. - * - * @return Collection */ private function getRetailerCollection(): Collection { @@ -239,12 +154,8 @@ private function getRetailerCollection(): Collection /** * Get the JSON post data used to build the set store link. - * - * @param RetailerInterface $retailer The store - * - * @return array */ - private function getSetStorePostData($retailer): array + private function getSetStorePostData(RetailerInterface $retailer): array { $setUrl = $this->urlBuilder->getUrl('storelocator/store/set'); $postData = ['id' => $retailer->getId()]; diff --git a/Model/Carrier.php b/Model/Carrier.php index 6f80ff1..2dff85d 100644 --- a/Model/Carrier.php +++ b/Model/Carrier.php @@ -1,101 +1,53 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + namespace Smile\StoreDelivery\Model; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\DataObject; +use Magento\Quote\Model\Quote\Address\RateRequest; +use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory; use Magento\Quote\Model\Quote\Address\RateResult\Method; +use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory; use Magento\Shipping\Model\Carrier\AbstractCarrier; use Magento\Shipping\Model\Carrier\CarrierInterface; use Magento\Shipping\Model\Rate\Result; use Magento\Shipping\Model\Rate\ResultFactory; -use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory; -use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory; -use Magento\Quote\Model\Quote\Address\RateRequest; use Psr\Log\LoggerInterface; /** - * Store Delivery Carrier model - * @SuppressWarnings(PHPMD.CamelCasePropertyName) - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud + * Store Delivery Carrier model. */ class Carrier extends AbstractCarrier implements CarrierInterface { - /** - * Constant for method code - */ - const METHOD_CODE = 'smilestoredelivery'; + public const METHOD_CODE = 'smilestoredelivery'; - /** - * @var string - */ + // phpcs:disable SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint protected $_code = self::METHOD_CODE; - - /** - * Whether this carrier has fixed rates calculation - * - * @var boolean - */ protected $_isFixed = true; + // phpcs:enable - /** - * @var ResultFactory - */ - protected ResultFactory $rateResultFactory; - - /** - * @var MethodFactory - */ - protected MethodFactory $rateMethodFactory; - - /** - * Carrier constructor - * - * @param ScopeConfigInterface $scopeConfig Scope Configuration - * @param ErrorFactory $rateErrorFactory Rate error Factory - * @param LoggerInterface $logger Logger - * @param ResultFactory $rateResultFactory Rate result Factory - * @param MethodFactory $rateMethodFactory Rate method Factory - * @param array $data Carrier Data - */ public function __construct( ScopeConfigInterface $scopeConfig, ErrorFactory $rateErrorFactory, LoggerInterface $logger, - ResultFactory $rateResultFactory, - MethodFactory $rateMethodFactory, + protected ResultFactory $rateResultFactory, + protected MethodFactory $rateMethodFactory, array $data = [] ) { - $this->rateResultFactory = $rateResultFactory; - $this->rateMethodFactory = $rateMethodFactory; parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data); } /** - * {@inheritdoc} + * @inheritdoc */ - public function getAllowedMethods(): array + public function getAllowedMethods() { return [$this->getCarrierCode() => __($this->getConfigData('name'))]; } /** - * {@inheritdoc} + * @inheritdoc */ - public function collectRates(RateRequest $request): false|Result + public function collectRates(RateRequest $request) { if (!$this->getConfigFlag('active')) { return false; diff --git a/Observer/QuoteSubmit.php b/Observer/QuoteSubmit.php index 217aaef..66823a5 100644 --- a/Observer/QuoteSubmit.php +++ b/Observer/QuoteSubmit.php @@ -1,15 +1,5 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + namespace Smile\StoreDelivery\Observer; use Magento\Framework\Event\Observer; @@ -21,40 +11,22 @@ /** * Observer to ensure Billing Address has required fields when using StoreDelivery shipping Method. - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud */ class QuoteSubmit implements ObserverInterface { - /** - * @var CarrierFactoryInterface - */ - private CarrierFactoryInterface $carrierFactory; - - /** - * QuoteSubmit constructor. - * - * @param CarrierFactoryInterface $carrierFactory Carrier Factory - */ - public function __construct(CarrierFactoryInterface $carrierFactory) + public function __construct(private CarrierFactoryInterface $carrierFactory) { - $this->carrierFactory = $carrierFactory; } /** - * Set mandatory fields to shipping address from the billing one, if needed. - * - * This can occur when using Store Delivery, since the Shipping Address is set before the Billing. - * In this case, the shipping address may not have the proper value for FirstName, LastName, and Telephone. - * - * @event checkout_submit_before - * - * @param Observer $observer The observer + * @inheritdoc */ - public function execute(Observer $observer): void + public function execute(Observer $observer) { + // Set mandatory fields to shipping address from the billing one, if needed. + // This can occur when using Store Delivery, since the Shipping Address is set before the Billing. + // In this case, the shipping address may not have the proper value for FirstName, LastName, and Telephone. + /** @var CartInterface $quote */ $quote = $observer->getQuote(); diff --git a/Plugin/Checkout/Api/SaveAddressPlugin.php b/Plugin/Checkout/Api/SaveAddressPlugin.php index aa67697..42b0df9 100644 --- a/Plugin/Checkout/Api/SaveAddressPlugin.php +++ b/Plugin/Checkout/Api/SaveAddressPlugin.php @@ -1,71 +1,30 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + namespace Smile\StoreDelivery\Plugin\Checkout\Api; use Magento\Checkout\Api\Data\ShippingInformationInterface; use Magento\Checkout\Api\ShippingInformationManagementInterface; use Magento\Customer\Api\Data\AddressInterfaceFactory; -use Magento\Customer\Model\Session; use Smile\Retailer\Api\RetailerRepositoryInterface; /** - * Plugin to save a Store address as Shipping Address - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud + * Plugin to save a Store address as Shipping Address. */ class SaveAddressPlugin { - /** - * @var Session - */ - private Session $customerSession; - - /** - * @var RetailerRepositoryInterface - */ - private RetailerRepositoryInterface $retailerRepository; - - /** - * @var AddressInterfaceFactory - */ private AddressInterfaceFactory $addressDataFactory; - /** - * @param RetailerRepositoryInterface $retailerRepository Retailer Repository - * @param Session $customerSession Customer session - * @param AddressInterfaceFactory $addressInterfaceFactory Address Factory - */ public function __construct( - RetailerRepositoryInterface $retailerRepository, - Session $customerSession, + private RetailerRepositoryInterface $retailerRepository, AddressInterfaceFactory $addressInterfaceFactory ) { - $this->retailerRepository = $retailerRepository; - $this->customerSession = $customerSession; $this->addressDataFactory = $addressInterfaceFactory; } /** - * Convert Store Address to Shipping Address - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * Convert Store Address to Shipping Address. * - * @param ShippingInformationManagementInterface $subject Shipping Information Management - * @param mixed $cartId Cart Id - * @param ShippingInformationInterface $addressInformation Address Information - * - * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeSaveAddressInformation( ShippingInformationManagementInterface $subject, diff --git a/Plugin/Quote/Api/ShipmentEstimationPlugin.php b/Plugin/Quote/Api/ShipmentEstimationPlugin.php index 93a56c5..376a54e 100644 --- a/Plugin/Quote/Api/ShipmentEstimationPlugin.php +++ b/Plugin/Quote/Api/ShipmentEstimationPlugin.php @@ -1,45 +1,26 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + namespace Smile\StoreDelivery\Plugin\Quote\Api; +use Closure; use Magento\Quote\Api\Data\AddressInterface; use Magento\Quote\Api\Data\ShippingMethodInterface; use Magento\Quote\Api\ShipmentEstimationInterface; +use Smile\StoreDelivery\Model\Carrier; /** - * Shipment Estimation Plugin. - * Allow only Store Delivery - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud + * Shipment Estimation Plugin. Allows only Store Delivery. */ class ShipmentEstimationPlugin { /** * Ensure StoreDelivery is the only available shipping method for store delivery addresses. - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @param ShipmentEstimationInterface $subject Shipment Estimation Interface - * @param \Closure $proceed The estimateByExtendedAddress method - * @param mixed $cartId The cart Id - * @param AddressInterface $address The Shipping Address * - * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundEstimateByExtendedAddress( ShipmentEstimationInterface $subject, - \Closure $proceed, + Closure $proceed, mixed $cartId, AddressInterface $address ): mixed { @@ -48,10 +29,13 @@ public function aroundEstimateByExtendedAddress( // If shipping address is linked to a retailer, remove all methods except Store Delivery. /** @var ShippingMethodInterface $shippingMethod */ foreach ($shippingMethods as $key => $shippingMethod) { - if (($address->getExtensionAttributes() && $address->getExtensionAttributes()->getRetailerId() - && ($shippingMethod->getMethodCode() !== \Smile\StoreDelivery\Model\Carrier::METHOD_CODE)) || - ((!$address->getExtensionAttributes() || (null === $address->getExtensionAttributes()->getRetailerId())) - && ($shippingMethod->getMethodCode() === \Smile\StoreDelivery\Model\Carrier::METHOD_CODE)) + if ( + ($address->getExtensionAttributes() + && $address->getExtensionAttributes()->getRetailerId() + && ($shippingMethod->getMethodCode() !== Carrier::METHOD_CODE)) + || ((!$address->getExtensionAttributes() + || (null === $address->getExtensionAttributes()->getRetailerId())) + && ($shippingMethod->getMethodCode() === Carrier::METHOD_CODE)) ) { unset($shippingMethods[$key]); } diff --git a/Plugin/Quote/Api/ShippingMethodManagementPlugin.php b/Plugin/Quote/Api/ShippingMethodManagementPlugin.php index 1b9e128..a20dd22 100644 --- a/Plugin/Quote/Api/ShippingMethodManagementPlugin.php +++ b/Plugin/Quote/Api/ShippingMethodManagementPlugin.php @@ -1,44 +1,25 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + namespace Smile\StoreDelivery\Plugin\Quote\Api; +use Closure; use Magento\Quote\Api\Data\ShippingMethodInterface; use Magento\Quote\Api\ShippingMethodManagementInterface; use Smile\StoreDelivery\Model\Carrier; /** * Plugin to remove Store Delivery from available carriers for estimation by addressId. - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud */ class ShippingMethodManagementPlugin { /** * Remove StoreDelivery from available methods when estimating by address Id (existing customer addresses). - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @param ShippingMethodManagementInterface $subject Shipping Method Management - * @param \Closure $proceed estimateByAddressId() method - * @param mixed $cartId The shopping cart ID. - * @param mixed $addressId The estimate address id * - * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundEstimateByAddressId( ShippingMethodManagementInterface $subject, - \Closure $proceed, + Closure $proceed, mixed $cartId, mixed $addressId ): mixed { diff --git a/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php b/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php index 6d5c9ce..fc4f23f 100644 --- a/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php +++ b/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php @@ -1,17 +1,8 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + namespace Smile\StoreDelivery\Plugin\Quote\Model; +use Closure; use Magento\Quote\Model\Quote\Address; use Magento\Quote\Model\Quote\Address\ToOrderAddress; use Magento\Sales\Api\Data\OrderAddressInterface; @@ -19,27 +10,20 @@ /** * Plugin to copy "retailer_id" field from quote_address to order_address. * Done via a plugin because fieldset.xml does not seem to work. - * see https://magento.stackexchange.com/questions/124712/magento-2-fieldset-xml-copy-fields-from-quote-to-order - * see https://github.com/magento/magento2/issues/5823 * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud + * @see https://magento.stackexchange.com/questions/124712/magento-2-fieldset-xml-copy-fields-from-quote-to-order + * @see https://github.com/magento/magento2/issues/5823 */ class ConvertQuoteAddressToOrderAddress { /** - * @param ToOrderAddress $subject The converter - * @param \Closure $proceed Converter convert() method - * @param Address $quoteAddress Quote Address - * @param array $data Data + * Copy retailer_id field from quote_address to order_address. * - * @return OrderAddressInterface Order Address * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundConvert( ToOrderAddress $subject, - \Closure $proceed, + Closure $proceed, Address $quoteAddress, array $data = [] ): OrderAddressInterface { diff --git a/Setup/InstallData.php b/Setup/InstallData.php index 32b2b1f..395ef5e 100644 --- a/Setup/InstallData.php +++ b/Setup/InstallData.php @@ -1,73 +1,28 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + namespace Smile\StoreDelivery\Setup; +use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface; +use Magento\Eav\Model\Entity\Attribute\Source\Boolean; +use Magento\Eav\Setup\EavSetup; +use Magento\Framework\DB\Ddl\Table; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; -use Magento\Quote\Setup\QuoteSetupFactory; -use Magento\Sales\Setup\SalesSetupFactory; -use Magento\Eav\Setup\EavSetup; -use Magento\Eav\Setup\EavSetupFactory; +use Magento\Quote\Setup\QuoteSetup; +use Magento\Sales\Setup\SalesSetup; use Smile\Retailer\Api\Data\RetailerInterface; use Smile\Seller\Api\Data\SellerInterface; /** * Smile StoreDelivery Install Data. - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud */ class InstallData implements InstallDataInterface { /** - * @var SalesSetupFactory - */ - private SalesSetupFactory $salesSetupFactory; - - /** - * @var QuoteSetupFactory - */ - private QuoteSetupFactory $quoteSetupFactory; - - /** - * @var EavSetupFactory - */ - private EavSetupFactory $eavSetupFactory; - - /** - * InstallData constructor. - * - * @param SalesSetupFactory $salesSetupFactory Sales Setup - * @param QuoteSetupFactory $quoteSetupFactory Quote Setup - * @param EavSetupFactory $eavSetupFactory EAV Setup Factory. - */ - public function __construct( - SalesSetupFactory $salesSetupFactory, - QuoteSetupFactory $quoteSetupFactory, - EavSetupFactory $eavSetupFactory - ) { - $this->salesSetupFactory = $salesSetupFactory; - $this->quoteSetupFactory = $quoteSetupFactory; - $this->eavSetupFactory = $eavSetupFactory; - } - - - /** - * {@inheritdoc} + * @inheritdoc */ - public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context): void + public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); @@ -81,37 +36,33 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface } /** - * Add retailer_id attribute to sales_order_address and sales_quote_address - * - * @param ModuleDataSetupInterface $setup Data Setup + * Add retailer_id attribute to sales_order_address and sales_quote_address. */ - private function addSalesAttributes($setup): void + private function addSalesAttributes(ModuleDataSetupInterface $setup): void { - /** @var \Magento\Sales\Setup\SalesSetup $salesSetup */ + /** @var SalesSetup $salesSetup */ $salesSetup = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]); - /** @var \Magento\Quote\Setup\QuoteSetup $quoteSetup */ + /** @var QuoteSetup $quoteSetup */ $quoteSetup = $this->quoteSetupFactory->create(['resourceName' => 'quote_setup', 'setup' => $setup]); $quoteSetup->addAttribute( 'quote_address', 'retailer_id', - ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 'visible' => false] + ['type' => Table::TYPE_INTEGER, 'visible' => false] ); $salesSetup->addAttribute( 'order_address', 'retailer_id', - ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 'visible' => false] + ['type' => Table::TYPE_INTEGER, 'visible' => false] ); } /** - * Add allow_store_delivery attribute to Retailer - * - * @param \Magento\Eav\Setup\EavSetup $eavSetup EAV module Setup + * Add allow_store_delivery attribute to Retailer. */ - private function addShopAttributes($eavSetup): void + private function addShopAttributes(EavSetup $eavSetup): void { $entityId = SellerInterface::ENTITY; $attrSetId = RetailerInterface::ATTRIBUTE_SET_RETAILER; @@ -123,14 +74,14 @@ private function addShopAttributes($eavSetup): void SellerInterface::ENTITY, 'allow_store_delivery', [ - 'type' => 'int', - 'label' => 'Allow Store Delivery', - 'input' => 'boolean', - 'required' => true, + 'type' => 'int', + 'label' => 'Allow Store Delivery', + 'input' => 'boolean', + 'required' => true, 'user_defined' => true, - 'sort_order' => 10, - 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, - 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', + 'sort_order' => 10, + 'global' => ScopedAttributeInterface::SCOPE_GLOBAL, + 'source' => Boolean::class, ] ); diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php index 8a8b42a..00d631d 100644 --- a/Setup/InstallSchema.php +++ b/Setup/InstallSchema.php @@ -1,18 +1,9 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + namespace Smile\StoreDelivery\Setup; use Magento\Framework\App\ProductMetadataInterface; +use Magento\Framework\DB\Ddl\Table; use Magento\Framework\Setup\InstallSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; @@ -20,32 +11,17 @@ /** * Smile StoreDelivery Install Schema. * Mandatory for Magento <2.2 to backport a fix on shipping_method field. - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud */ class InstallSchema implements InstallSchemaInterface { - /** - * @var ProductMetadataInterface - */ - private ProductMetadataInterface $metadata; - - /** - * InstallSchema constructor. - * - * @param ProductMetadataInterface $metadata Magento metadata - */ - public function __construct(ProductMetadataInterface $metadata) + public function __construct(private ProductMetadataInterface $metadata) { - $this->metadata = $metadata; } /** - * {@inheritdoc} + * @inheritdoc */ - public function install(SchemaSetupInterface $setup, ModuleContextInterface $context): void + public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); @@ -61,7 +37,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con $setup->getTable('quote_address'), 'shipping_method', [ - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 'type' => Table::TYPE_TEXT, 'length' => 120, ] ); @@ -70,7 +46,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con $setup->getTable('sales_order'), 'shipping_method', [ - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 'type' => Table::TYPE_TEXT, 'length' => 120, ] ); diff --git a/composer.json b/composer.json index b7f3cac..b08ae01 100644 --- a/composer.json +++ b/composer.json @@ -3,37 +3,44 @@ "type": "magento2-module", "description": "Smile Store Delivery", "keywords": ["magento2", "store delivery", "click in store", "delivery in store"], - "repositories": [ + "license": "OSL-3.0", + "authors": [ { - "type": "composer", - "url": "https://repo.magento.com/" + "name": "Romain Ruaud", + "email": "romain.ruaud@smile.fr" } ], "require": { "php": "^8.1", "magento/framework": ">=103.0.4", - "magento/module-store": "*", - "magento/module-checkout": "*", - "smile/module-store-locator": "~2.2.0" + "magento/module-checkout": ">=100.4.4", + "magento/module-store": ">=101.1.4", + "smile/module-store-locator": "^2.0" }, "require-dev": { "smile/magento2-smilelab-quality-suite": "^3.0" }, - "license": "OSL-3.0", - "authors": [ + "repositories": [ { - "name": "Romain Ruaud", - "email": "romain.ruaud@smile.fr" + "type": "composer", + "url": "https://repo.magento.com/" } ], + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "files": [ "registration.php" ], "psr-4": { - "Smile\\StoreDelivery\\" : "" + "Smile\\StoreDelivery\\": "" } }, - "minimum-stability": "dev", - "prefer-stable": true + "config": { + "allow-plugins": { + "magento/composer-dependency-version-audit-plugin": true, + "dealerdirect/phpcodesniffer-composer-installer": true + }, + "sort-packages": true + } } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index d3d25f9..1fee851 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -1,18 +1,4 @@ -
diff --git a/etc/config.xml b/etc/config.xml index 8cd2e5d..57739b1 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,18 +1,4 @@ - @@ -31,4 +17,3 @@ - diff --git a/etc/di.xml b/etc/di.xml index 5711a8d..a7e1dab 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,20 +1,4 @@ - diff --git a/etc/events.xml b/etc/events.xml index 85668b1..14a04f6 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -1,20 +1,6 @@ - - + diff --git a/etc/extension_attributes.xml b/etc/extension_attributes.xml index e8dd2b6..326fbc4 100644 --- a/etc/extension_attributes.xml +++ b/etc/extension_attributes.xml @@ -1,20 +1,6 @@ - - + diff --git a/etc/fieldset.xml b/etc/fieldset.xml index af45c6e..5e71fb0 100644 --- a/etc/fieldset.xml +++ b/etc/fieldset.xml @@ -1,34 +1,20 @@ -
- +
- +
- +
diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index d130f60..4dded44 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -1,18 +1,4 @@ - diff --git a/etc/module.xml b/etc/module.xml index 50d9504..5ef0f0a 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,18 +1,4 @@ - diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..04a793a --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + . + vendor/* + diff --git a/phpmd.xml.dist b/phpmd.xml.dist new file mode 100644 index 0000000..8eadf89 --- /dev/null +++ b/phpmd.xml.dist @@ -0,0 +1,10 @@ + + + + + + vendor/* + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..4e40864 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,11 @@ +parameters: + level: 6 + phpVersion: 80100 + checkMissingIterableValueType: false + paths: + - . + excludePaths: + - 'vendor/*' + +includes: + - %currentWorkingDirectory%/vendor/smile/magento2-smilelab-phpstan/extension.neon diff --git a/registration.php b/registration.php index b8fa37c..aa4311c 100644 --- a/registration.php +++ b/registration.php @@ -1,19 +1,9 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register( + ComponentRegistrar::MODULE, 'Smile_StoreDelivery', __DIR__ ); diff --git a/view/adminhtml/ui_component/smile_retailer_listing.xml b/view/adminhtml/ui_component/smile_retailer_listing.xml index f825268..bb3297a 100644 --- a/view/adminhtml/ui_component/smile_retailer_listing.xml +++ b/view/adminhtml/ui_component/smile_retailer_listing.xml @@ -1,20 +1,4 @@ - diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js index 4f597dc..2bc3c7e 100644 --- a/view/frontend/requirejs-config.js +++ b/view/frontend/requirejs-config.js @@ -1,17 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Smile Elastic Suite to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - var config = { map: { '*': { diff --git a/view/frontend/web/css/source/_module.less b/view/frontend/web/css/source/_module.less index 700bdec..96d6d15 100644 --- a/view/frontend/web/css/source/_module.less +++ b/view/frontend/web/css/source/_module.less @@ -1,18 +1,3 @@ -// /** -// * DISCLAIMER -// * -// * Do not edit or add to this file if you wish to upgrade this module to newer -// * versions in the future. -// * -// * -// * @category Smile -// * @package Smile\StoreDelivery -// * @author Romain Ruaud -// * @copyright 2017 Smile -// * @license Open Software License ("OSL") v. 3.0 -// */ - - // // Store Delivery - Checkout Onepage // _____________________________________________ @@ -357,4 +342,3 @@ body.checkout-index-index { } } } - diff --git a/view/frontend/web/js/model/empty-address.js b/view/frontend/web/js/model/empty-address.js index 56e24df..abe34a1 100644 --- a/view/frontend/web/js/model/empty-address.js +++ b/view/frontend/web/js/model/empty-address.js @@ -1,19 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2016 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ define([], function() { /** diff --git a/view/frontend/web/js/model/shipping-rate-processor/store-delivery.js b/view/frontend/web/js/model/shipping-rate-processor/store-delivery.js index 128d0f4..275031b 100644 --- a/view/frontend/web/js/model/shipping-rate-processor/store-delivery.js +++ b/view/frontend/web/js/model/shipping-rate-processor/store-delivery.js @@ -1,4 +1,3 @@ -/*global define*/ define( [ 'Magento_Checkout/js/model/resource-url-manager', diff --git a/view/frontend/web/js/model/shipping-save-processor/store-delivery.js b/view/frontend/web/js/model/shipping-save-processor/store-delivery.js index 0339228..923ded4 100644 --- a/view/frontend/web/js/model/shipping-save-processor/store-delivery.js +++ b/view/frontend/web/js/model/shipping-save-processor/store-delivery.js @@ -1,19 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2016 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ define( [ 'ko', diff --git a/view/frontend/web/js/model/store-address.js b/view/frontend/web/js/model/store-address.js index e41e3c4..65813ef 100644 --- a/view/frontend/web/js/model/store-address.js +++ b/view/frontend/web/js/model/store-address.js @@ -1,19 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2016 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ define([], function() { /** * @param int retailerId diff --git a/view/frontend/web/js/view/checkout/shipping/store-delivery.js b/view/frontend/web/js/view/checkout/shipping/store-delivery.js index 37cfe41..9a72f39 100644 --- a/view/frontend/web/js/view/checkout/shipping/store-delivery.js +++ b/view/frontend/web/js/view/checkout/shipping/store-delivery.js @@ -1,20 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2016 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ - define([ 'uiComponent', 'jquery', @@ -87,11 +70,11 @@ define([ getMethodTitle: function() { return this.methodTitle; }, - + getCarrierCode: function() { return this.carrierCode; }, - + getCarrierTitle: function() { return this.carrierTitle; }, diff --git a/view/frontend/web/js/view/shipping-address/address-renderer/default.js b/view/frontend/web/js/view/shipping-address/address-renderer/default.js index 0a1e7e6..a664f18 100644 --- a/view/frontend/web/js/view/shipping-address/address-renderer/default.js +++ b/view/frontend/web/js/view/shipping-address/address-renderer/default.js @@ -1,20 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ - define([ 'jquery', 'ko', diff --git a/view/frontend/web/js/view/shipping-address/address-renderer/store-delivery.js b/view/frontend/web/js/view/shipping-address/address-renderer/store-delivery.js index 2573ded..ee4ef4a 100644 --- a/view/frontend/web/js/view/shipping-address/address-renderer/store-delivery.js +++ b/view/frontend/web/js/view/shipping-address/address-renderer/store-delivery.js @@ -1,8 +1,3 @@ -/** - * Copyright © 2013-2017 Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -/*global define*/ define([ 'jquery', 'ko', diff --git a/view/frontend/web/js/view/shipping-address/store-delivery.js b/view/frontend/web/js/view/shipping-address/store-delivery.js index dda0dd2..0b105ea 100644 --- a/view/frontend/web/js/view/shipping-address/store-delivery.js +++ b/view/frontend/web/js/view/shipping-address/store-delivery.js @@ -1,20 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2016 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ - define( [ 'uiComponent', From 29de88e06dd9476807dca332b181e1e3939dfa42 Mon Sep 17 00:00:00 2001 From: livca Date: Thu, 13 Jul 2023 15:19:43 +0200 Subject: [PATCH 05/10] #1220935 - qualitysuite --- Block/Checkout/LayoutProcessor.php | 14 ++- Model/Carrier.php | 7 +- Observer/QuoteSubmit.php | 7 +- Plugin/Checkout/Api/SaveAddressPlugin.php | 12 ++- Plugin/Quote/Api/ShipmentEstimationPlugin.php | 4 + .../Api/ShippingMethodManagementPlugin.php | 2 + .../ConvertQuoteAddressToOrderAddress.php | 2 + Setup/InstallSchema.php | 57 ------------- .../Data/AddStoreDeliveryAttributes.php} | 85 +++++++++++-------- etc/db_schema.xml | 13 +++ etc/module.xml | 2 +- phpstan.neon.dist | 1 + registration.php | 2 + .../checkout/shipping/store-delivery.html | 2 +- .../checkout/shipping/store-list.html | 2 +- .../address-renderer/default.html | 16 ++-- .../address-renderer/store-delivery.html | 14 +-- .../address-renderer/store-delivery.html | 12 +-- 18 files changed, 129 insertions(+), 125 deletions(-) delete mode 100644 Setup/InstallSchema.php rename Setup/{InstallData.php => Patch/Data/AddStoreDeliveryAttributes.php} (53%) create mode 100644 etc/db_schema.xml diff --git a/Block/Checkout/LayoutProcessor.php b/Block/Checkout/LayoutProcessor.php index 8250416..d72df6b 100644 --- a/Block/Checkout/LayoutProcessor.php +++ b/Block/Checkout/LayoutProcessor.php @@ -1,18 +1,23 @@ getExtensionAttributes()->getAddress(); - $coords = $address->getCoordinates(); + /** @var RetailerExtensionInterface $retailerExtensionAttr */ + $retailerExtensionAttr = $retailer->getExtensionAttributes(); + /** @var DataObject|RetailerAddressInterface $address */ + $address = $retailerExtensionAttr->getAddress(); + $coords = $address->getCoordinates(); $markerData = [ 'id' => $retailer->getId(), 'latitude' => $coords->getLatitude(), @@ -118,7 +126,7 @@ private function getStores(): array [ 'calendar' => $this->scheduleManagement->getCalendar($retailer), 'openingHours' => $this->scheduleManagement->getWeekOpeningHours($retailer), - 'specialOpeningHours' => $retailer->getExtensionAttributes()->getSpecialOpeningHours(), + 'specialOpeningHours' => $retailerExtensionAttr->getSpecialOpeningHours(), ] ); diff --git a/Model/Carrier.php b/Model/Carrier.php index 2dff85d..231b37a 100644 --- a/Model/Carrier.php +++ b/Model/Carrier.php @@ -1,8 +1,11 @@ rateResultFactory->create(); /** @var Method $method */ @@ -65,7 +68,7 @@ public function collectRates(RateRequest $request) $method->setMethod($this->getCarrierCode()); $method->setMethodTitle($this->getConfigData('name')); - $amount = $this->getConfigData('price'); + $amount = (float) $this->getConfigData('price'); $price = $this->getFinalPriceWithHandlingFee($amount); diff --git a/Observer/QuoteSubmit.php b/Observer/QuoteSubmit.php index 66823a5..9359f4a 100644 --- a/Observer/QuoteSubmit.php +++ b/Observer/QuoteSubmit.php @@ -1,11 +1,14 @@ getQuote(); /** @var AddressInterface $shippingAddress */ + // @phpstan-ignore-next-line : correct reference to interface $shippingAddress = $quote->getShippingAddress(); if ($shippingAddress) { + // @phpstan-ignore-next-line : correct reference to interface $shippingMethod = $shippingAddress->getShippingMethod(); if ($shippingMethod) { $methodCode = Carrier::METHOD_CODE; diff --git a/Plugin/Checkout/Api/SaveAddressPlugin.php b/Plugin/Checkout/Api/SaveAddressPlugin.php index 42b0df9..9342cf3 100644 --- a/Plugin/Checkout/Api/SaveAddressPlugin.php +++ b/Plugin/Checkout/Api/SaveAddressPlugin.php @@ -1,10 +1,14 @@ getShippingAddress(); $billingAddress = $addressInformation->getBillingAddress(); + // @phpstan-ignore-next-line if ($shippingAddress->getExtensionAttributes() && $shippingAddress->getExtensionAttributes()->getRetailerId()) { + /** @var RetailerInterface $retailer */ + // @phpstan-ignore-next-line $retailer = $this->retailerRepository->get($shippingAddress->getExtensionAttributes()->getRetailerId()); if ($retailer->getId()) { $address = $this->addressDataFactory->create( - ['data' => $retailer->getAddress()->getData()] + ['data' => $retailer->getData('address')->getData()] ); $shippingAddress->importCustomerAddressData($address); $shippingAddress->setCompany($retailer->getName()); - $shippingAddress->setRetailerId((int) $retailer->getId()); + $shippingAddress->setData('retailer_id', (string) $retailer->getId()); // Potentially copy billing fields (if present, this is not the case when customer is not logged in). if (!$shippingAddress->getFirstname()) { diff --git a/Plugin/Quote/Api/ShipmentEstimationPlugin.php b/Plugin/Quote/Api/ShipmentEstimationPlugin.php index 376a54e..74ff7a0 100644 --- a/Plugin/Quote/Api/ShipmentEstimationPlugin.php +++ b/Plugin/Quote/Api/ShipmentEstimationPlugin.php @@ -1,5 +1,7 @@ $shippingMethod) { if ( ($address->getExtensionAttributes() + // @phpstan-ignore-next-line && $address->getExtensionAttributes()->getRetailerId() && ($shippingMethod->getMethodCode() !== Carrier::METHOD_CODE)) || ((!$address->getExtensionAttributes() + // @phpstan-ignore-next-line || (null === $address->getExtensionAttributes()->getRetailerId())) && ($shippingMethod->getMethodCode() === Carrier::METHOD_CODE)) ) { diff --git a/Plugin/Quote/Api/ShippingMethodManagementPlugin.php b/Plugin/Quote/Api/ShippingMethodManagementPlugin.php index a20dd22..e1370a6 100644 --- a/Plugin/Quote/Api/ShippingMethodManagementPlugin.php +++ b/Plugin/Quote/Api/ShippingMethodManagementPlugin.php @@ -1,5 +1,7 @@ startSetup(); - - if (version_compare($this->metadata->getVersion(), '2.2.0', '<')) { - $connection = $setup->getConnection(); - - // Set the "shipping_method" column of quote_address and sales_order tables to 120 chars length. - // This is a fix for a Magento's internal issue. - // @see https://github.com/magento/magento2/issues/6475 - // This has been fixed in Magento 2.2 only, that's why it's backported here for now. - // This setup will have no effect on a Magento > 2.2 and is only needed for < 2.2 instances. - $connection->modifyColumn( - $setup->getTable('quote_address'), - 'shipping_method', - [ - 'type' => Table::TYPE_TEXT, - 'length' => 120, - ] - ); - - $connection->modifyColumn( - $setup->getTable('sales_order'), - 'shipping_method', - [ - 'type' => Table::TYPE_TEXT, - 'length' => 120, - ] - ); - } - - $setup->endSetup(); - } -} diff --git a/Setup/InstallData.php b/Setup/Patch/Data/AddStoreDeliveryAttributes.php similarity index 53% rename from Setup/InstallData.php rename to Setup/Patch/Data/AddStoreDeliveryAttributes.php index 395ef5e..621e2a2 100644 --- a/Setup/InstallData.php +++ b/Setup/Patch/Data/AddStoreDeliveryAttributes.php @@ -1,62 +1,51 @@ startSetup(); - - $this->addSalesAttributes($setup); - - /** @var EavSetup $eavSetup */ - $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); - $this->addShopAttributes($eavSetup); - - $setup->endSetup(); + public function __construct( + private readonly EavSetupFactory $eavSetupFactory, + private readonly ModuleDataSetupInterface $moduleDataSetup + ) { } /** - * Add retailer_id attribute to sales_order_address and sales_quote_address. + * @inheritdoc + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - private function addSalesAttributes(ModuleDataSetupInterface $setup): void + public function apply(): self { - /** @var SalesSetup $salesSetup */ - $salesSetup = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]); + $this->moduleDataSetup->startSetup(); - /** @var QuoteSetup $quoteSetup */ - $quoteSetup = $this->quoteSetupFactory->create(['resourceName' => 'quote_setup', 'setup' => $setup]); + /** @var EavSetup $eavSetup */ + $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]); + $this->addShopAttributes($eavSetup); - $quoteSetup->addAttribute( - 'quote_address', - 'retailer_id', - ['type' => Table::TYPE_INTEGER, 'visible' => false] - ); + $this->moduleDataSetup->endSetup(); - $salesSetup->addAttribute( - 'order_address', - 'retailer_id', - ['type' => Table::TYPE_INTEGER, 'visible' => false] - ); + return $this; } /** @@ -71,7 +60,7 @@ private function addShopAttributes(EavSetup $eavSetup): void $eavSetup->addAttributeGroup($entityId, $attrSetId, $groupId, 200); $eavSetup->addAttribute( - SellerInterface::ENTITY, + SellerInterface::ENTITY_TYPE_CODE, 'allow_store_delivery', [ 'type' => 'int', @@ -87,4 +76,28 @@ private function addShopAttributes(EavSetup $eavSetup): void $eavSetup->addAttributeToGroup($entityId, $attrSetId, $groupId, 'allow_store_delivery', 10); } + + /** + * @inheritdoc + */ + public static function getDependencies(): array + { + return []; + } + + /** + * @inheritdoc + */ + public static function getVersion(): string + { + return '2.0.1'; + } + + /** + * @inheritdoc + */ + public function getAliases(): array + { + return []; + } } diff --git a/etc/db_schema.xml b/etc/db_schema.xml new file mode 100644 index 0000000..570e228 --- /dev/null +++ b/etc/db_schema.xml @@ -0,0 +1,13 @@ + + + + + +
+ + +
+
diff --git a/etc/module.xml b/etc/module.xml index 5ef0f0a..8ff6c3b 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 4e40864..5ba0a4c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,6 +2,7 @@ parameters: level: 6 phpVersion: 80100 checkMissingIterableValueType: false + treatPhpDocTypesAsCertain: false paths: - . excludePaths: diff --git a/registration.php b/registration.php index aa4311c..43538dc 100644 --- a/registration.php +++ b/registration.php @@ -1,5 +1,7 @@ + }"> diff --git a/view/frontend/web/template/checkout/shipping/store-list.html b/view/frontend/web/template/checkout/shipping/store-list.html index e0a89af..0157dd8 100644 --- a/view/frontend/web/template/checkout/shipping/store-list.html +++ b/view/frontend/web/template/checkout/shipping/store-list.html @@ -7,7 +7,7 @@ 'title': $t('Choose this store') }, checked: $parents[1].currentRetailerId - }"/> + }"> diff --git a/view/frontend/web/template/shipping-address/address-renderer/default.html b/view/frontend/web/template/shipping-address/address-renderer/default.html index 58ac774..1d21df0 100644 --- a/view/frontend/web/template/shipping-address/address-renderer/default.html +++ b/view/frontend/web/template/shipping-address/address-renderer/default.html @@ -1,6 +1,6 @@
-
+
@@ -11,18 +11,18 @@ -
-
- ,
-
-
+
+
+ ,
+
+
-
+
-
+
diff --git a/view/frontend/web/template/shipping-address/address-renderer/store-delivery.html b/view/frontend/web/template/shipping-address/address-renderer/store-delivery.html index 0adcdd2..1a030eb 100644 --- a/view/frontend/web/template/shipping-address/address-renderer/store-delivery.html +++ b/view/frontend/web/template/shipping-address/address-renderer/store-delivery.html @@ -7,19 +7,19 @@ -
-
- ,
-
-
+
+
+ ,
+
+
-
+
-
+
diff --git a/view/frontend/web/template/shipping-information/address-renderer/store-delivery.html b/view/frontend/web/template/shipping-information/address-renderer/store-delivery.html index cb2cf79..b5a7a78 100644 --- a/view/frontend/web/template/shipping-information/address-renderer/store-delivery.html +++ b/view/frontend/web/template/shipping-information/address-renderer/store-delivery.html @@ -1,12 +1,12 @@ -
-
-
- ,
-
-
+
+
+
+ ,
+
+
From 558c6c1b50ff5dbbe9c37696f11a59d94b1e9dbe Mon Sep 17 00:00:00 2001 From: livca Date: Fri, 21 Jul 2023 16:16:20 +0200 Subject: [PATCH 06/10] #1220935 - qualitysuite - tiny fix --- Observer/QuoteSubmit.php | 1 + Plugin/Checkout/Api/SaveAddressPlugin.php | 6 +++--- Plugin/Quote/Api/ShipmentEstimationPlugin.php | 2 -- phpcs.xml.dist | 1 - phpstan.neon.dist | 1 - 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Observer/QuoteSubmit.php b/Observer/QuoteSubmit.php index 9359f4a..a6319fa 100644 --- a/Observer/QuoteSubmit.php +++ b/Observer/QuoteSubmit.php @@ -36,6 +36,7 @@ public function execute(Observer $observer) /** @var AddressInterface $shippingAddress */ // @phpstan-ignore-next-line : correct reference to interface $shippingAddress = $quote->getShippingAddress(); + // @phpstan-ignore-next-line if ($shippingAddress) { // @phpstan-ignore-next-line : correct reference to interface $shippingMethod = $shippingAddress->getShippingMethod(); diff --git a/Plugin/Checkout/Api/SaveAddressPlugin.php b/Plugin/Checkout/Api/SaveAddressPlugin.php index 9342cf3..45375ab 100644 --- a/Plugin/Checkout/Api/SaveAddressPlugin.php +++ b/Plugin/Checkout/Api/SaveAddressPlugin.php @@ -39,11 +39,11 @@ public function beforeSaveAddressInformation( $shippingAddress = $addressInformation->getShippingAddress(); $billingAddress = $addressInformation->getBillingAddress(); - // @phpstan-ignore-next-line if ($shippingAddress->getExtensionAttributes() && $shippingAddress->getExtensionAttributes()->getRetailerId()) { /** @var RetailerInterface $retailer */ - // @phpstan-ignore-next-line - $retailer = $this->retailerRepository->get($shippingAddress->getExtensionAttributes()->getRetailerId()); + $retailer = $this->retailerRepository->get( + (int) $shippingAddress->getExtensionAttributes()->getRetailerId() + ); if ($retailer->getId()) { $address = $this->addressDataFactory->create( ['data' => $retailer->getData('address')->getData()] diff --git a/Plugin/Quote/Api/ShipmentEstimationPlugin.php b/Plugin/Quote/Api/ShipmentEstimationPlugin.php index 74ff7a0..2a98201 100644 --- a/Plugin/Quote/Api/ShipmentEstimationPlugin.php +++ b/Plugin/Quote/Api/ShipmentEstimationPlugin.php @@ -33,11 +33,9 @@ public function aroundEstimateByExtendedAddress( foreach ($shippingMethods as $key => $shippingMethod) { if ( ($address->getExtensionAttributes() - // @phpstan-ignore-next-line && $address->getExtensionAttributes()->getRetailerId() && ($shippingMethod->getMethodCode() !== Carrier::METHOD_CODE)) || ((!$address->getExtensionAttributes() - // @phpstan-ignore-next-line || (null === $address->getExtensionAttributes()->getRetailerId())) && ($shippingMethod->getMethodCode() === Carrier::METHOD_CODE)) ) { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 04a793a..dca2bb5 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -19,7 +19,6 @@ - . diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 5ba0a4c..4e40864 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,7 +2,6 @@ parameters: level: 6 phpVersion: 80100 checkMissingIterableValueType: false - treatPhpDocTypesAsCertain: false paths: - . excludePaths: From 5ec47c64a1619d383908b2eef97bbc53e50a3bf0 Mon Sep 17 00:00:00 2001 From: livca Date: Tue, 22 Aug 2023 11:21:01 +0200 Subject: [PATCH 07/10] #1220935 - qualitysuite - fix --- Plugin/Checkout/Api/SaveAddressPlugin.php | 2 ++ Plugin/Quote/Api/ShipmentEstimationPlugin.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Plugin/Checkout/Api/SaveAddressPlugin.php b/Plugin/Checkout/Api/SaveAddressPlugin.php index 45375ab..515f980 100644 --- a/Plugin/Checkout/Api/SaveAddressPlugin.php +++ b/Plugin/Checkout/Api/SaveAddressPlugin.php @@ -39,9 +39,11 @@ public function beforeSaveAddressInformation( $shippingAddress = $addressInformation->getShippingAddress(); $billingAddress = $addressInformation->getBillingAddress(); + // @phpstan-ignore-next-line if ($shippingAddress->getExtensionAttributes() && $shippingAddress->getExtensionAttributes()->getRetailerId()) { /** @var RetailerInterface $retailer */ $retailer = $this->retailerRepository->get( + // @phpstan-ignore-next-line (int) $shippingAddress->getExtensionAttributes()->getRetailerId() ); if ($retailer->getId()) { diff --git a/Plugin/Quote/Api/ShipmentEstimationPlugin.php b/Plugin/Quote/Api/ShipmentEstimationPlugin.php index 2a98201..74ff7a0 100644 --- a/Plugin/Quote/Api/ShipmentEstimationPlugin.php +++ b/Plugin/Quote/Api/ShipmentEstimationPlugin.php @@ -33,9 +33,11 @@ public function aroundEstimateByExtendedAddress( foreach ($shippingMethods as $key => $shippingMethod) { if ( ($address->getExtensionAttributes() + // @phpstan-ignore-next-line && $address->getExtensionAttributes()->getRetailerId() && ($shippingMethod->getMethodCode() !== Carrier::METHOD_CODE)) || ((!$address->getExtensionAttributes() + // @phpstan-ignore-next-line || (null === $address->getExtensionAttributes()->getRetailerId())) && ($shippingMethod->getMethodCode() === Carrier::METHOD_CODE)) ) { From efd2484e12d6a085bb741476bbb4c8dea00fda0c Mon Sep 17 00:00:00 2001 From: livca Date: Tue, 22 Aug 2023 11:41:01 +0200 Subject: [PATCH 08/10] #1220935 - qualitysuite - add db_schema_whitelist --- etc/db_schema_whitelist.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 etc/db_schema_whitelist.json diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json new file mode 100644 index 0000000..48cca0f --- /dev/null +++ b/etc/db_schema_whitelist.json @@ -0,0 +1,12 @@ +{ + "sales_order_address": { + "column": { + "retailer_id": true + } + }, + "quote_address": { + "column": { + "retailer_id": true + } + } +} \ No newline at end of file From 7231b938ad41da44b0ff9e0ec51e985c4589b7f4 Mon Sep 17 00:00:00 2001 From: livca Date: Thu, 21 Sep 2023 14:42:58 +0200 Subject: [PATCH 09/10] #1220935 - changelog --- .codeclimate.yml | 25 ---------- .github/workflows/static-analysis.yaml | 66 ++++++++++++++++++++++++++ .travis.yml | 21 -------- CHANGELOG.md | 18 +++---- README.md | 10 ++-- composer.json | 2 +- 6 files changed, 81 insertions(+), 61 deletions(-) delete mode 100644 .codeclimate.yml create mode 100644 .github/workflows/static-analysis.yaml delete mode 100644 .travis.yml diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index 36bb2fa..0000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -engines: - duplication: - enabled: true - config: - languages: - - javascript - - php - eslint: - enabled: true - fixme: - enabled: true - phan: - enabled: true - config: - file_extensions: php - ignore-undeclared: true -ratings: - paths: - - "**.js" - - "**.php" -exclude_paths: - - src/*/Test - - vendor/* - - Resources/* diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml new file mode 100644 index 0000000..43a1dfc --- /dev/null +++ b/.github/workflows/static-analysis.yaml @@ -0,0 +1,66 @@ +name: 'Static Analysis' + +on: + pull_request: ~ + push: + branches: + - 'master' + +jobs: + static-analysis: + runs-on: 'ubuntu-latest' + + strategy: + matrix: + php-version: + - '8.1' + + steps: + - name: 'Checkout' + uses: 'actions/checkout@v3' + + - name: 'Install PHP' + uses: 'shivammathur/setup-php@v2' + with: + php-version: '${{ matrix.php-version }}' + coverage: 'none' + tools: 'composer:v2' + env: + COMPOSER_AUTH_JSON: | + { + "http-basic": { + "repo.magento.com": { + "username": "${{ secrets.MAGENTO_USERNAME }}", + "password": "${{ secrets.MAGENTO_PASSWORD }}" + } + } + } + + - name: 'Get composer cache directory' + id: 'composer-cache' + run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT' + + - name: 'Cache dependencies' + uses: 'actions/cache@v3' + with: + path: '${{ steps.composer-cache.outputs.dir }}' + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: '${{ runner.os }}-composer-' + + - name: 'Install dependencies' + run: 'composer install --prefer-dist' + + - name: 'Run composer audit' + run: 'composer audit --format=plain' + + - name: 'Run Parallel Lint' + run: 'vendor/bin/parallel-lint --exclude vendor .' + + - name: 'Run PHP CodeSniffer' + run: 'vendor/bin/phpcs --extensions=php,phtml' + + - name: 'Run PHPMD' + run: 'vendor/bin/phpmd . xml phpmd.xml.dist' + + - name: 'Run PHPStan' + run: 'vendor/bin/phpstan analyse' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 52aa001..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: php - -php: -- '5.6' -- '7.0' - -install: [ - "mkdir -p app/etc var", - "echo \"{\\\"http-basic\\\":{\\\"repo.magento.com\\\":{\\\"username\\\":\\\"${MAGENTO_USERNAME}\\\",\\\"password\\\":\\\"${MAGENTO_PASSWORD}\\\"}}}\" > auth.json", - "composer install --prefer-dist" -] - -cache: - directories: - - $HOME/.composer/cache - -script: - - vendor/bin/phpcs --config-set installed_paths vendor/magento/marketplace-eqp/ - - vendor/bin/phpcs --standard=vendor/magento/marketplace-eqp/MEQP2 --ignore=vendor,pub --severity=9 ./ - - vendor/bin/phpcs --standard=vendor/smile/magento2-smilelab-phpcs/phpcs-standards/SmileLab --ignore=vendor,pub --extensions=php ./ - - vendor/bin/phpmd ./ text vendor/smile/magento2-smilelab-phpmd/phpmd-rulesets/rulset.xml --exclude vendor,pub diff --git a/CHANGELOG.md b/CHANGELOG.md index 9996db4..b4d4493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,18 +2,18 @@ All notable changes to this project will be documented in this file. -## [2.0.x] - 2023-04-24 -[2.0.x]: https://github.com/Smile-SA/magento2-module-store-delivery/compare/1.2.x...2.0.x +## [2.0.0] - 2023-09-20 +[2.0.0]: https://github.com/Smile-SA/magento2-module-store-delivery/compare/1.1.10...2.0.0 Dataset compatibility ES 2.11.x and PHP 8.2 -- fix Dynamic type declaration -- fix Type hinting +- Fix Dynamic type declaration +- Fix Type hinting - Replace `Zend_Date` by `DateTime` - Remove `MutationObserver` support -- fix UI Component Retailer Offer editing +- Fix UI Component Retailer Offer editing - Replace `Zend_Validate` by `Laminas\Validator` -- fix Retailer Grid Column Action -- fix Retailer Grid Mass Actions -- fix some translations -- remove Temando/Shipping Plugin +- Fix Retailer Grid Column Action +- Fix Retailer Grid Mass Actions +- Fix some translations +- Remove Temando/Shipping Plugin diff --git a/README.md b/README.md index f35ec3e..f8f0271 100644 --- a/README.md +++ b/README.md @@ -6,21 +6,21 @@ This module add the ability to be delivered in store. Store delivery is a shippi ### Requirements -The module requires : +The module requires: -- [Store Locator](https://github.com/Smile-SA/magento2-module-store-locator) > 2.2.* +- [Store Locator](https://github.com/Smile-SA/magento2-module-store-locator) >= 2.2.* ### How to use -1. Install the module via Composer : +1. Install the module via Composer: ``` composer require smile/module-store-delivery ``` -2. Enable it +2. Enable it: ``` bin/magento module:enable Smile_StoreDelivery ``` -3. Install the module and rebuild the DI cache +3. Install the module and rebuild the DI cache: ``` bin/magento setup:upgrade ``` diff --git a/composer.json b/composer.json index b08ae01..7ac9b09 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "magento/framework": ">=103.0.4", "magento/module-checkout": ">=100.4.4", "magento/module-store": ">=101.1.4", - "smile/module-store-locator": "^2.0" + "smile/module-store-locator": "^2.2" }, "require-dev": { "smile/magento2-smilelab-quality-suite": "^3.0" From 07db7cd057dfd9504610aabe5e66b4ac2f81ee7f Mon Sep 17 00:00:00 2001 From: livca Date: Thu, 21 Sep 2023 14:46:32 +0200 Subject: [PATCH 10/10] #1220935 - changelog --- .github/workflows/static-analysis.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index 43a1dfc..3ebefff 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -62,5 +62,5 @@ jobs: - name: 'Run PHPMD' run: 'vendor/bin/phpmd . xml phpmd.xml.dist' - - name: 'Run PHPStan' - run: 'vendor/bin/phpstan analyse' +# - name: 'Run PHPStan' +# run: 'vendor/bin/phpstan analyse'