From e67ef40f4d945595a139d516d6f91248b735200d Mon Sep 17 00:00:00 2001 From: Jorge Venzon Date: Tue, 16 Apr 2024 08:47:42 -0300 Subject: [PATCH] Fixed issue when there is no abandoned cart update date. Fixed Bundled Products with Dynamic SKUs enabled. Fixed problem with acceptsMarketing. --- AbandonedCart/Model/AbandonedCartSendData.php | 10 +++++++--- AbandonedCart/composer.json | 2 +- AbandonedCart/etc/module.xml | 2 +- Customer/Model/Customer.php | 11 +++++++---- Customer/composer.json | 2 +- Customer/etc/module.xml | 2 +- Order/Model/OrderData/OrderDataSend.php | 9 ++++----- Order/composer.json | 2 +- Order/etc/module.xml | 2 +- composer.json | 2 +- marketplace-composer.json | 2 +- 11 files changed, 26 insertions(+), 20 deletions(-) diff --git a/AbandonedCart/Model/AbandonedCartSendData.php b/AbandonedCart/Model/AbandonedCartSendData.php index 2c32d77..4949bb1 100644 --- a/AbandonedCart/Model/AbandonedCartSendData.php +++ b/AbandonedCart/Model/AbandonedCartSendData.php @@ -249,7 +249,7 @@ public function sendAbandonedCartData($quoteId = null): array $quote = $this->quoteRepository->get($abandonedCart->getEntityId()); $AcCustomer = NULL; - if ($this->isGuest($quote) || ($abandonedCart->getCustomerId() && !$this->getCustomer($abandonedCart->getCustomerId())->getCustomerId())) { + if ($this->isGuest($quote) || ($abandonedCart->getCustomerId() && !$this->getCustomer($abandonedCart->getCustomerId())->getId())) { $customerEmail = $quote->getBillingAddress()->getEmail(); if (!$customerEmail) { $result['error'] = __('Customer Email does not exist.'); @@ -270,6 +270,10 @@ public function sendAbandonedCartData($quoteId = null): array $abandonedCart->collectTotals(); $quoteItemsData = $this->getQuoteItemsData($abandonedCart->getEntityId(), $abandonedCart->getStoreId()); $abandonedCartRepository = $this->quoteRepository->get($abandonedCart->getId()); + $abandonedUpdateDate = $abandonedCartRepository->getUpdatedAt(); + if(is_null($abandonedUpdateDate)){ + $abandonedUpdateDate = $abandonedCartRepository->getCreatedAt(); + } $timezone = $this->dateTime->getConfigTimezone(\Magento\Store\Model\ScopeInterface::SCOPE_STORES, $abandonedCart->getStoreId()); $abandonedCartData = [ "ecomOrder" => [ @@ -281,9 +285,9 @@ public function sendAbandonedCartData($quoteId = null): array "discountAmount" => $this->coreHelper->priceToCents($abandonedCart->getDiscountAmount()) ], "orderUrl" => $this->urlBuilder->getDirectUrl('checkout/cart'), - "abandonedDate" => $this->dateTime->date(strtotime($abandonedCartRepository->getUpdatedAt()),NULL,$timezone)->format('Y-m-d\TH:i:sP'), + "abandonedDate" => $this->dateTime->date(strtotime($abandonedUpdateDate),NULL,$timezone)->format('Y-m-d\TH:i:sP'), "externalCreatedDate" => $this->dateTime->date(strtotime($abandonedCartRepository->getCreatedAt()),NULL,$timezone)->format('Y-m-d\TH:i:sP'), - "externalUpdatedDate" => $this->dateTime->date(strtotime($abandonedCartRepository->getUpdatedAt()),NULL,$timezone)->format('Y-m-d\TH:i:sP'), + "externalUpdatedDate" => $this->dateTime->date(strtotime($abandonedUpdateDate),NULL,$timezone)->format('Y-m-d\TH:i:sP'), "shippingMethod" => $abandonedCart->getShippingAddress()->getShippingMethod(), "totalPrice" => $this->coreHelper->priceToCents($abandonedCart->getGrandTotal()), "shippingAmount" => $this->coreHelper->priceToCents($abandonedCart->getShippingAmount()), diff --git a/AbandonedCart/composer.json b/AbandonedCart/composer.json index 5525c4c..daefff2 100644 --- a/AbandonedCart/composer.json +++ b/AbandonedCart/composer.json @@ -9,7 +9,7 @@ "config": { "sort-packages": true }, - "version": "2.1.8", + "version": "2.1.9", "require": { "php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2", "activecampaign/core": "2.1.*" diff --git a/AbandonedCart/etc/module.xml b/AbandonedCart/etc/module.xml index 1f79632..48c0079 100644 --- a/AbandonedCart/etc/module.xml +++ b/AbandonedCart/etc/module.xml @@ -6,7 +6,7 @@ */ --> - + diff --git a/Customer/Model/Customer.php b/Customer/Model/Customer.php index dbb4869..be11e98 100644 --- a/Customer/Model/Customer.php +++ b/Customer/Model/Customer.php @@ -169,7 +169,7 @@ public function getEcomCustomerData($customer) $ecomCustomer['connectionid'] = $this->coreHelper->getConnectionId($customer->getStoreId()); $ecomCustomer['externalid'] = $customer->getId(); $ecomCustomer['email'] = $customer->getEmail(); - $ecomCustomerData['acceptsMarketing'] = (int)$this->subscriberFactory->create()->loadByCustomer($customer->getId(),$customer->getWebsiteId())->isSubscribed(); + $ecomCustomer['acceptsMarketing'] = (int)$this->subscriberFactory->create()->loadBySubscriberEmail($customer->getEmail(), $customer->getWebsiteId())->isSubscribed(); $ecomCustomerData['ecomCustomer'] = $ecomCustomer; return $ecomCustomerData; @@ -178,13 +178,16 @@ public function getEcomCustomerData($customer) /** * @param null $billingId * @return string|null - * @throws \Magento\Framework\Exception\LocalizedException */ private function getTelephone($billingId = null) { if ($billingId) { - $address = $this->addressRepository->getById($billingId); - return $address->getTelephone(); + try{ + $address = $this->addressRepository->getById($billingId); + return $address->getTelephone(); + }catch (\Exception $exception){ + + } } return null; } diff --git a/Customer/composer.json b/Customer/composer.json index 6a1ec49..35c354b 100644 --- a/Customer/composer.json +++ b/Customer/composer.json @@ -9,7 +9,7 @@ "config": { "sort-packages": true }, - "version": "2.1.8", + "version": "2.1.9", "require": { "php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2", "activecampaign/core": "2.1.*" diff --git a/Customer/etc/module.xml b/Customer/etc/module.xml index c415bf0..9cad0f7 100644 --- a/Customer/etc/module.xml +++ b/Customer/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/Order/Model/OrderData/OrderDataSend.php b/Order/Model/OrderData/OrderDataSend.php index b888053..efbc32a 100644 --- a/Order/Model/OrderData/OrderDataSend.php +++ b/Order/Model/OrderData/OrderDataSend.php @@ -224,20 +224,19 @@ public function orderDataSend($order): array } $timezone = $this->dateTime->getConfigTimezone(\Magento\Store\Model\ScopeInterface::SCOPE_STORES, $order->getStoreId()); foreach ($order->getAllVisibleItems() as $item) { - $product = $this->_productRepositoryFactory->create() - ->get($item->getSku()); + $imageUrl = $this->imageHelperFactory->create() - ->init($product, 'product_thumbnail_image')->getUrl(); + ->init($item->getProduct(), 'product_thumbnail_image')->getUrl(); $items[] = [ "externalid" => $item->getProductId(), "name" => $item->getName(), "price" => $this->activeCampaignHelper->priceToCents($item->getPrice()), "quantity" => $item->getQtyOrdered(), - "category" => implode(', ', $product->getCategoryIds()), + "category" => implode(', ', $item->getProduct()->getCategoryIds()), "sku" => $item->getSku(), "description" => $item->getDescription(), "imageUrl" => $imageUrl, - "productUrl" => $product->getProductUrl() + "productUrl" => $item->getProduct()->getProductUrl() ]; } $data = [ diff --git a/Order/composer.json b/Order/composer.json index f48f47a..d3585bf 100644 --- a/Order/composer.json +++ b/Order/composer.json @@ -9,7 +9,7 @@ "config": { "sort-packages": true }, - "version": "2.1.4", + "version": "2.1.5", "require": { "php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2", "activecampaign/core": "2.1.*" diff --git a/Order/etc/module.xml b/Order/etc/module.xml index 6db284c..4f601ca 100644 --- a/Order/etc/module.xml +++ b/Order/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/composer.json b/composer.json index 50daeea..c8faac4 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "activecampaign/module-integration", "description": "ActiveCampaign extension for Magento 2.3 and 2.4", "type": "magento2-component", - "version": "2.0.17", + "version": "2.1.20", "license": "OSL-3.0", "require": { "php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2" diff --git a/marketplace-composer.json b/marketplace-composer.json index 4d7e6ab..3f7406d 100644 --- a/marketplace-composer.json +++ b/marketplace-composer.json @@ -2,7 +2,7 @@ "name": "activecampaign/module-integration", "description": "ActiveCampaign extension for Magento 2.3 and 2.4", "type": "metapackage", - "version": "2.0.18", + "version": "2.1.20", "license": [ "OSL-3.0" ],