From c857c8e1d18aa2f08f0831d27e03c030939486f5 Mon Sep 17 00:00:00 2001 From: Arjen Miedema Date: Mon, 28 Feb 2022 15:06:34 +0100 Subject: [PATCH 1/8] Ensure shipping cost is always a float When calculating the shipping costs, the given value from the JSON request can also be a string, this will cause an error since the return type is set to be a float. To ensure this will not give any issues, the shipping costs variable is casted to a float in all cases. --- Service/Order/Shipping/CalculatePrice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Service/Order/Shipping/CalculatePrice.php b/Service/Order/Shipping/CalculatePrice.php index 516b412..e009f89 100644 --- a/Service/Order/Shipping/CalculatePrice.php +++ b/Service/Order/Shipping/CalculatePrice.php @@ -53,7 +53,7 @@ public function __construct( public function execute(Quote $quote, array $orderData, StoreInterface $store): float { $taxCalculation = $this->configProvider->getNeedsTaxCalulcation('shipping', (int)$store->getId()); - $shippingPriceCal = $orderData['price']['shipping']; + $shippingPriceCal = (float) $orderData['price']['shipping']; if (empty($taxCalculation)) { $shippingAddress = $quote->getShippingAddress(); From 70ba74606857406c86ac0aee7b5f9da372e6e040 Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Thu, 3 Mar 2022 12:49:16 +0100 Subject: [PATCH 2/8] Add order subroles for ACL --- Controller/Adminhtml/Order/Delete.php | 4 ++-- Controller/Adminhtml/Order/Import.php | 2 +- Controller/Adminhtml/Order/Index.php | 2 +- Controller/Adminhtml/Order/Simulate.php | 2 +- etc/acl.xml | 10 ++++++++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Controller/Adminhtml/Order/Delete.php b/Controller/Adminhtml/Order/Delete.php index c885bdc..c2ed5e7 100755 --- a/Controller/Adminhtml/Order/Delete.php +++ b/Controller/Adminhtml/Order/Delete.php @@ -17,11 +17,11 @@ */ class Delete extends Action { - + /** * Authorization level */ - const ADMIN_RESOURCE = 'Magmodules_Channable::general_orders'; + const ADMIN_RESOURCE = 'Magmodules_Channable::order_delete'; /** * @var ChannableOrderRepository diff --git a/Controller/Adminhtml/Order/Import.php b/Controller/Adminhtml/Order/Import.php index e8c39c5..7c938d1 100755 --- a/Controller/Adminhtml/Order/Import.php +++ b/Controller/Adminhtml/Order/Import.php @@ -28,7 +28,7 @@ class Import extends Action /** * Authorization level */ - const ADMIN_RESOURCE = 'Magmodules_Channable::general_orders'; + const ADMIN_RESOURCE = 'Magmodules_Channable::order_import'; /** * @var OrderImportService diff --git a/Controller/Adminhtml/Order/Index.php b/Controller/Adminhtml/Order/Index.php index 4738b58..6435b97 100644 --- a/Controller/Adminhtml/Order/Index.php +++ b/Controller/Adminhtml/Order/Index.php @@ -21,7 +21,7 @@ class Index extends Action /** * Authorization level */ - const ADMIN_RESOURCE = 'Magmodules_Channable::general_orders'; + const ADMIN_RESOURCE = 'Magmodules_Channable::order_view'; /** * @var PageFactory diff --git a/Controller/Adminhtml/Order/Simulate.php b/Controller/Adminhtml/Order/Simulate.php index 10d258b..c474675 100644 --- a/Controller/Adminhtml/Order/Simulate.php +++ b/Controller/Adminhtml/Order/Simulate.php @@ -24,7 +24,7 @@ class Simulate extends Action /** * Authorization level */ - const ADMIN_RESOURCE = 'Magmodules_Channable::general_orders'; + const ADMIN_RESOURCE = 'Magmodules_Channable::order_simulate'; /** * @var ImportSimulator diff --git a/etc/acl.xml b/etc/acl.xml index 1d9dfa3..a0c9224 100755 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -10,7 +10,11 @@ - + + + + + @@ -19,7 +23,9 @@ - + + + From d23a0746c9512743ff228b3f223f5bbeba36699f Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Thu, 3 Mar 2022 12:49:54 +0100 Subject: [PATCH 3/8] Add missing component to date fields in order grid --- .../ui_component/channable_order_grid.xml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/view/adminhtml/ui_component/channable_order_grid.xml b/view/adminhtml/ui_component/channable_order_grid.xml index 602c494..cfef99d 100755 --- a/view/adminhtml/ui_component/channable_order_grid.xml +++ b/view/adminhtml/ui_component/channable_order_grid.xml @@ -194,16 +194,22 @@ false - + - text + dateRange + date desc - + - text + dateRange + date desc From bf7aaac64d9d122e99aeeeccf9fc78a0201d393a Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Thu, 3 Mar 2022 12:50:36 +0100 Subject: [PATCH 4/8] Add package weight to shipping rate request --- Service/Order/Shipping/GetMethod.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Service/Order/Shipping/GetMethod.php b/Service/Order/Shipping/GetMethod.php index 6a0fccc..8667e33 100644 --- a/Service/Order/Shipping/GetMethod.php +++ b/Service/Order/Shipping/GetMethod.php @@ -85,6 +85,9 @@ public function execute(Quote $quote, StoreInterface $store, int $itemCount, flo $request->setLimitCarrier(''); $request->setBaseSubtotalInclTax($total); $request->setFreeShipping($shippingPriceCal <= 0); + if (!empty($quote->getShippingAddress()->getWeight())) { + $request->setPackageWeight($quote->getShippingAddress()->getWeight()); + } $shipping = $this->shippingFactory->create(); $result = $shipping->collectRates($request)->getResult(); From f2af012d1d806e6509ef895cc7861ed95e51e769 Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Thu, 3 Mar 2022 12:51:11 +0100 Subject: [PATCH 5/8] Set reserved order id on cart --- Service/Order/Import.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Service/Order/Import.php b/Service/Order/Import.php index 733e3aa..cd9ae0c 100755 --- a/Service/Order/Import.php +++ b/Service/Order/Import.php @@ -219,6 +219,11 @@ public function execute(ChannableOrderData $orderData): OrderInterface $quote->setTotals($totals); $quote->collectTotals(); $quote->setTotalsCollectedFlag(false)->collectTotals(); + + if ($customIncrementId = $this->getCustomIncrementId->execute($orderData, $store)) { + $quote->setReservedOrderId($customIncrementId); + } + $quote->save(); if ($lvbOrder && $this->configProvider->disableStockMovementForLvbOrders((int)$store->getId())) { @@ -236,10 +241,6 @@ public function execute(ChannableOrderData $orderData): OrderInterface } $store->setCurrentCurrencyCode($store->getBaseCurrencyCode()); - if ($customIncrementId = $this->getCustomIncrementId->execute($orderData, $store)) { - $order->setIncrementId($customIncrementId); - } - if ($shippingDescription = $this->getShippingDescription->execute($order, $orderData)) { $order->setShippingDescription($shippingDescription); } From 8bc4b78aa6a46a4a49b117e3d25893afbb5ab461 Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Thu, 3 Mar 2022 12:53:04 +0100 Subject: [PATCH 6/8] Version bump --- composer.json | 2 +- etc/config.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index deacd79..601382a 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magmodules/magento2-channable", "description": "Channable integration for Magento 2", "type": "magento2-module", - "version": "1.6.1", + "version": "1.6.2", "license": "BSD-2-Clause", "homepage": "https://github.com/magmodules/magento2-channable", "require": { diff --git a/etc/config.xml b/etc/config.xml index 9e9ff91..959ca53 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -12,7 +12,7 @@ 0 250 - v1.6.1 + v1.6.2 name From 5247a3fe7ded4601141880dac1280b4516e6fff4 Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Thu, 3 Mar 2022 13:06:04 +0100 Subject: [PATCH 7/8] Make Logger component compatible with Monolog 2.0 --- Logger/ChannableHandler.php | 4 +--- Logger/ChannableLogger.php | 4 +--- Logger/DebugLogger.php | 14 +++++++------- Logger/ErrorLogger.php | 16 +++++++--------- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/Logger/ChannableHandler.php b/Logger/ChannableHandler.php index f97b607..f03fd36 100644 --- a/Logger/ChannableHandler.php +++ b/Logger/ChannableHandler.php @@ -10,9 +10,7 @@ use Magento\Framework\Logger\Handler\Base; /** - * Class ChannableHandler - * - * @package Magmodules\Channable\Logger + * @deprecated */ class ChannableHandler extends Base { diff --git a/Logger/ChannableLogger.php b/Logger/ChannableLogger.php index 41bbace..ef10087 100644 --- a/Logger/ChannableLogger.php +++ b/Logger/ChannableLogger.php @@ -9,9 +9,7 @@ use Monolog\Logger; /** - * Class ChannableLogger - * - * @package Magmodules\Channable\Logger + * @deprecated */ class ChannableLogger extends Logger { diff --git a/Logger/DebugLogger.php b/Logger/DebugLogger.php index bd43233..2d1f5a0 100644 --- a/Logger/DebugLogger.php +++ b/Logger/DebugLogger.php @@ -24,10 +24,10 @@ class DebugLogger extends Logger /** * DebugLogger constructor. * - * @param Json $json + * @param Json $json * @param string $name - * @param array $handlers - * @param array $processors + * @param array $handlers + * @param array $processors */ public function __construct( Json $json, @@ -40,17 +40,17 @@ public function __construct( } /** - * Add debug data to kiyoh Log + * Add debug data to Channable log * * @param string $type - * @param mixed $data + * @param mixed $data */ public function addLog(string $type, $data): void { if (is_array($data) || is_object($data)) { - $this->addDebug($type . ': ' . $this->json->serialize($data)); + $this->addRecord(static::INFO, $type . ': ' . $this->json->serialize($data)); } else { - $this->addDebug($type . ': ' . $data); + $this->addRecord(static::INFO, $type . ': ' . $data); } } } diff --git a/Logger/ErrorLogger.php b/Logger/ErrorLogger.php index 9041e2e..ecdf10d 100644 --- a/Logger/ErrorLogger.php +++ b/Logger/ErrorLogger.php @@ -12,7 +12,6 @@ /** * ErrorLogger logger class - * */ class ErrorLogger extends Logger { @@ -25,10 +24,10 @@ class ErrorLogger extends Logger /** * ErrorLogger constructor. * - * @param Json $json + * @param Json $json * @param string $name - * @param array $handlers - * @param array $processors + * @param array $handlers + * @param array $processors */ public function __construct( Json $json, @@ -41,18 +40,17 @@ public function __construct( } /** - * Add error data to kiyoh Log + * Add error data to Channable log * * @param string $type - * @param mixed $data - * + * @param mixed $data */ public function addLog($type, $data): void { if (is_array($data) || is_object($data)) { - $this->addError($type . ': ' . $this->json->serialize($data)); + $this->addRecord(static::ERROR, $type . ': ' . $this->json->serialize($data)); } else { - $this->addEmergency($type . ': ' . $data); + $this->addRecord(static::ERROR, $type . ': ' . $data); } } } From 60536e867dd92dc3fcd84556fb94024604757964 Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Thu, 3 Mar 2022 13:07:07 +0100 Subject: [PATCH 8/8] Refactor filtering on status for product feed export --- Helper/Source.php | 11 +---------- Model/Collection/Products.php | 4 ++-- 2 files changed, 3 insertions(+), 12 deletions(-) mode change 100644 => 100755 Helper/Source.php mode change 100644 => 100755 Model/Collection/Products.php diff --git a/Helper/Source.php b/Helper/Source.php old mode 100644 new mode 100755 index 9c9709c..5004755 --- a/Helper/Source.php +++ b/Helper/Source.php @@ -418,17 +418,8 @@ public function getProductFilters($type) if ($visibilityFilter) { $visibility = $this->getStoreValue(self::XPATH_VISIBILITY_OPTIONS); $filters['visibility'] = explode(',', $visibility); - $filters['visibility_parents'] = $filters['visibility']; } else { - $filters['visibility'] = [ - Visibility::VISIBILITY_IN_CATALOG, - Visibility::VISIBILITY_IN_SEARCH, - Visibility::VISIBILITY_BOTH, - ]; - $filters['visibility_parents'] = $filters['visibility']; - if (!empty($filters['relations'])) { - array_push($filters['visibility'], Visibility::VISIBILITY_NOT_VISIBLE); - } + $filters['visibility'] = []; } $filters['limit'] = preg_replace('/\D/', '', $this->getStoreValue(self::XPATH_LIMIT)); diff --git a/Model/Collection/Products.php b/Model/Collection/Products.php old mode 100644 new mode 100755 index 4fa5c85..7ce6941 --- a/Model/Collection/Products.php +++ b/Model/Collection/Products.php @@ -404,8 +404,8 @@ public function getParents($parentRelations, $config) } } - if (!empty($filters['visibility_parent'])) { - $collection->addAttributeToFilter('visibility', ['in' => $filters['visibility_parent']]); + if (!empty($filters['visibility'])) { + $collection->addAttributeToFilter('visibility', ['in' => $filters['visibility']]); } if (!empty($config['inventory']['attributes'])) {