Skip to content

Commit

Permalink
DEVREL-44, DEVREL-47, DEVREL-48
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeeurekalabs committed Mar 18, 2024
1 parent 205cf4f commit 83f0a7f
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 14 deletions.
4 changes: 2 additions & 2 deletions AbandonedCart/Model/AbandonedCartSendData.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,15 @@ private function getQuoteItemsData($entityId, $storeId): array
->getById($quoteItem->getProductId());

$imageUrl = $this->imageHelperFactory->create()
->init($product, 'product_thumbnail_image')->getUrl();
->init($product, 'product_page_image_medium')->getUrl();
$this->appEmulation->stopEnvironmentEmulation();
$quoteItemsData[] = [
"externalid" => $quoteItem->getItemId(),
"name" => $quoteItem->getName(),
"price" => $this->coreHelper->priceToCents($quoteItem->getPriceInclTax()),
"quantity" => $quoteItem->getQty(),
"sku" => $quoteItem->getSku(),
"description" => $quoteItem->getDescription(),
"description" => $product->getDescription(),
"imageUrl" => $imageUrl,
"productUrl" => $product->getProductUrl()
];
Expand Down
59 changes: 59 additions & 0 deletions AbandonedCart/Plugin/Checkout/Controller/Cart/Index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace ActiveCampaign\AbandonedCart\Plugin\Checkout\Controller\Cart;

use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;

class Index extends AbstractHelper
{
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $cart;

/**
* @var Session
*/
private $customerSession;
/**
* @var UrlInterface
*/
private $urlInterface;

/**
* Index constructor.
* @param Context $context
* @param \Magento\Checkout\Model\Cart $cart
* @param \Magento\Customer\Model\Session $customerSession
*/
public function __construct(
Context $context,
\Magento\Checkout\Model\Cart $cart,
\Magento\Customer\Model\Session $customerSession
) {
parent::__construct($context);
$this->urlInterface = $context->getUrlBuilder();
$this->customerSession = $customerSession;
$this->cart = $cart;
}

/**
* Shopping cart display action
*
* @return \Magento\Framework\View\Result\Page
*/
public function aroundExecute($subject, callable $proceed)
{
if((empty($this->cart->getItems()) || $this->cart->getItems()->count() == 0) && !$this->customerSession->isLoggedIn()){
$this->customerSession->setAfterAuthUrl($this->urlInterface->getCurrentUrl());
$this->customerSession->authenticate();
}else{
$resultPage = $proceed();
return $resultPage;
}


}
}
2 changes: 1 addition & 1 deletion AbandonedCart/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"config": {
"sort-packages": true
},
"version": "2.1.6",
"version": "2.1.7",
"require": {
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
"activecampaign/core": "2.1.*"
Expand Down
5 changes: 4 additions & 1 deletion AbandonedCart/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@
<argument name="resourceModel" xsi:type="string">Magento\Quote\Model\ResourceModel\Quote</argument>
</arguments>
</virtualType>
</config>
<type name="Magento\Checkout\Controller\Cart\Index">
<plugin name="ac_checkout_cart_controller" type="ActiveCampaign\AbandonedCart\Plugin\Checkout\Controller\Cart\Index"/>
</type>
</config>
2 changes: 1 addition & 1 deletion AbandonedCart/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="ActiveCampaign_AbandonedCart" setup_version="2.1.6">
<module name="ActiveCampaign_AbandonedCart" setup_version="2.1.7">
<sequence>
<module name="Magento_Product"/>
<module name="Magento_Sales"/>
Expand Down
11 changes: 8 additions & 3 deletions Core/Helper/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use ActiveCampaign\Core\Helper\Data as ActiveCampaignHelper;
use ActiveCampaign\Core\Logger\Logger;
use ActiveCampaign\SyncLog\Model\SyncLog;
use ActiveCampaign\SyncLog\Helper\Data as SyncLogHelper;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\RequestOptions;
Expand Down Expand Up @@ -45,6 +46,7 @@ class Curl extends AbstractHelper
*/
private $syncLog;

private $syncLogHelper;
/**
* Curl constructor.
* @param Context $context
Expand All @@ -60,14 +62,15 @@ public function __construct(
JsonHelper $jsonHelper,
Logger $logger,
ActiveCampaignHelper $activeCampaignHelper,
SyncLog $syncLog
SyncLog $syncLog,
SyncLogHelper $syncLogHelper
) {
$this->client = $client ?: new Client();
$this->jsonHelper = $jsonHelper;
$this->logger = $logger;
$this->activeCampaignHelper = $activeCampaignHelper;
$this->syncLog = $syncLog;

$this->syncLogHelper = $syncLogHelper;
parent::__construct($context);
}

Expand Down Expand Up @@ -401,7 +404,9 @@ private function sendRequest(
/**
* @todo Replace with repository service contract
*/
$synclog->save();
if(!$this->syncLogHelper->isLogError() || $synclog->getStatus()==0){
$synclog->save();
}
$synclog->unsetData();

return $result;
Expand Down
2 changes: 1 addition & 1 deletion Core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"config": {
"sort-packages": true
},
"version": "2.1.2",
"version": "2.1.3",
"require": {
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2"
},
Expand Down
2 changes: 1 addition & 1 deletion Core/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="ActiveCampaign_Core" setup_version="2.1.2"/>
<module name="ActiveCampaign_Core" setup_version="2.1.3"/>
</config>
45 changes: 45 additions & 0 deletions SyncLog/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace ActiveCampaign\SyncLog\Helper;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Store\Model\ScopeInterface;

class Data extends AbstractHelper
{
const ACTIVE_CAMPAIGN_SYNCLOG_MODE = "active_campaign/synclog/synclog_mode";


/**
* @var \Magento\Framework\App\State *
*/
private $state;

/**
* Data constructor.
* @param Context $context
*/
public function __construct(
Context $context,
\Magento\Framework\App\State $state
)
{
parent::__construct($context);
$this->state = $state;
}

/**
* @param null $scopeCode
* @return bool
*/
public function isLogError($scopeCode = null)
{
return $this->scopeConfig->isSetFlag(
self::ACTIVE_CAMPAIGN_SYNCLOG_MODE,
ScopeInterface::SCOPE_STORES,
$scopeCode
);
}

}
2 changes: 1 addition & 1 deletion SyncLog/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"config": {
"sort-packages": true
},
"version": "2.1.0",
"version": "2.1.1",
"require": {
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
"activecampaign/core": "2.1.*"
Expand Down
4 changes: 4 additions & 0 deletions SyncLog/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<resource>ActiveCampaign_SyncLog::config_activecampaign_synclog</resource>
<group id="synclog" sortOrder="100" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
<label>Sync Log Settings</label>
<field id="synclog_mode" translate="label" type="select" sortOrder="10" showInDefault="1">
<label>Only log errors</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="synclog_delete" translate="label" type="select" sortOrder="10" showInDefault="1">
<label>SyncLog Delete</label>
<comment><![CDATA[Choosing yes will start deleting your past 7 days existing SyncLog stored in database.]]></comment>
Expand Down
1 change: 1 addition & 0 deletions SyncLog/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<active_campaign>
<synclog>
<synclog_delete>0</synclog_delete>
<synclog_mode>1</synclog_mode>
<cron_minute>*</cron_minute>
<cron_hour>*</cron_hour>
<cron_day>*</cron_day>
Expand Down
2 changes: 1 addition & 1 deletion SyncLog/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="ActiveCampaign_SyncLog" setup_version="2.1.0" />
<module name="ActiveCampaign_SyncLog" setup_version="2.1.1" />
</config>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "activecampaign/module-integration",
"description": "ActiveCampaign extension for Magento 2.3 and 2.4",
"type": "magento2-component",
"version": "2.0.16",
"version": "2.0.17",
"license": "OSL-3.0",
"require": {
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2"
Expand Down
2 changes: 1 addition & 1 deletion marketplace-composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "activecampaign/module-integration",
"description": "ActiveCampaign extension for Magento 2.3 and 2.4",
"type": "metapackage",
"version": "2.0.16",
"version": "2.0.17",
"license": [
"OSL-3.0"
],
Expand Down

0 comments on commit 83f0a7f

Please sign in to comment.