Skip to content

Commit c28e578

Browse files
issue-10, issue-11, issue-44
1 parent 7edb88c commit c28e578

File tree

13 files changed

+83
-39
lines changed

13 files changed

+83
-39
lines changed

AbandonedCart/Model/AbandonedCartSendData.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ public function sendAbandonedCartData($quoteId = null): array
229229
['lt' => new \Zend_Db_Expr('main_table.updated_at')],
230230
['null' => true]
231231
])
232-
->addFieldToFilter('main_table.updated_at',
233-
['eq' => new \Zend_Db_Expr('IF( ac_synced_date is not null or main_table.updated_at < DATE_SUB(NOW(), INTERVAL '.$minInactiveTime.' minute), main_table.updated_at,-1)')]
234-
)
232+
// ->addFieldToFilter('main_table.updated_at',
233+
// ['eq' => new \Zend_Db_Expr('IF( ac_synced_date is not null or main_table.updated_at < DATE_SUB(NOW(), INTERVAL '.$minInactiveTime.' minute), main_table.updated_at,-1)')]
234+
// )
235235
->addFieldToFilter(
236236
'is_active',
237237
'1'
@@ -372,6 +372,13 @@ private function getQuoteItemsData($entityId, $storeId): array
372372
$imageUrl = $this->imageHelperFactory->create()
373373
->init($product, 'product_page_image_medium')->getUrl();
374374
$this->appEmulation->stopEnvironmentEmulation();
375+
$categories = $product->getCategoryCollection()->addAttributeToSelect('name');
376+
$categoriesName = [];
377+
foreach($categories as $category)
378+
{
379+
$categoriesName[] = $category->getName();
380+
}
381+
$categoriesName = implode(', ', $categoriesName);
375382
$quoteItemsData[] = [
376383
"externalid" => $quoteItem->getItemId(),
377384
"name" => $quoteItem->getName(),
@@ -380,7 +387,8 @@ private function getQuoteItemsData($entityId, $storeId): array
380387
"sku" => $quoteItem->getSku(),
381388
"description" => $product->getDescription(),
382389
"imageUrl" => $imageUrl,
383-
"productUrl" => $product->getProductUrl()
390+
"productUrl" => $product->getProductUrl(),
391+
"category" => $categoriesName
384392
];
385393
}
386394
return $quoteItemsData;

AbandonedCart/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"config": {
1010
"sort-packages": true
1111
},
12-
"version": "2.1.12",
12+
"version": "2.1.13",
1313
"require": {
1414
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
1515
"activecampaign/core": "2.1.*"

AbandonedCart/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="ActiveCampaign_AbandonedCart" setup_version="2.1.12">
9+
<module name="ActiveCampaign_AbandonedCart" setup_version="2.1.13">
1010
<sequence>
1111
<module name="Magento_Product"/>
1212
<module name="Magento_Sales"/>

Order/Model/OrderData/OrderDataSend.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,20 @@ public function orderDataSend($order): array
227227

228228
$imageUrl = $this->imageHelperFactory->create()
229229
->init($item->getProduct(), 'product_thumbnail_image')->getUrl();
230+
$categories = $item->getProduct()->getCategoryCollection()->addAttributeToSelect('name');
231+
$categoriesName = [];
232+
foreach($categories as $category)
233+
{
234+
$categoriesName[] = $category->getName();
235+
}
236+
$categoriesName = implode(', ', $categoriesName);
237+
230238
$items[] = [
231239
"externalid" => $item->getProductId(),
232240
"name" => $item->getName(),
233241
"price" => $this->activeCampaignHelper->priceToCents($item->getPrice()),
234242
"quantity" => $item->getQtyOrdered(),
235-
"category" => implode(', ', $item->getProduct()->getCategoryIds()),
243+
"category" => $categoriesName,
236244
"sku" => $item->getSku(),
237245
"description" => $item->getDescription(),
238246
"imageUrl" => $imageUrl,

Order/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"config": {
1010
"sort-packages": true
1111
},
12-
"version": "2.1.7",
12+
"version": "2.1.8",
1313
"require": {
1414
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
1515
"activecampaign/core": "2.1.*"

Order/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="ActiveCampaign_Order" setup_version="2.1.7">
3+
<module name="ActiveCampaign_Order" setup_version="2.1.8">
44
<sequence>
55
<module name="ActiveCampaign_Core" />
66
<module name="ActiveCampaign_Customer"/>

SyncLog/Cron/DeleteSyncLog.php

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,32 @@
88
use Magento\Framework\Stdlib\DateTime\DateTime;
99
use Magento\Framework\App\Config\ScopeConfigInterface;
1010
use Magento\Store\Model\ScopeInterface;
11-
11+
use ActiveCampaign\SyncLog\Helper\Data;
1212
class DeleteSyncLog
1313
{
1414

1515
const SYNCLOG_TABLE = "sync_log";
16-
const XML_PATH_ACTIVE_CAMPAIGN_SYNCLOG_ENABLE = "active_campaign/synclog/synclog_delete";
1716

18-
/**
19-
* @var ScopeConfigInterface
20-
*/
21-
protected $scopeConfig;
17+
18+
2219

2320
/** @var ResourceConnection */
2421
private $connection;
2522

2623
/** @var DateTime */
2724
private $dateTime;
2825

26+
private $helper;
27+
2928
public function __construct(
30-
ScopeConfigInterface $scopeConfig,
3129
ResourceConnection $connection,
32-
DateTime $dateTime
30+
DateTime $dateTime,
31+
Data $helper
3332
)
3433
{
35-
$this->scopeConfig = $scopeConfig;
3634
$this->connection = $connection;
3735
$this->dateTime = $dateTime;
36+
$this->helper = $helper;
3837
}
3938

4039
/**
@@ -44,27 +43,18 @@ public function __construct(
4443
*/
4544
public function execute()
4645
{
47-
if($this->isDeletingEnabled()) {
46+
47+
if($this->helper->isDeletingEnabled()) {
4848
$connection = $this->connection->getConnection();
4949
$tableName = $connection->getTableName(self::SYNCLOG_TABLE);
50-
$currentDate = $this->dateTime->gmtDate("Y-m-d", strtotime('-7 days'));
50+
$currentDate = $this->dateTime->gmtDate("Y-m-d", strtotime('-'.$this->helper->removeAfterDays().' days'));
5151
$whereConditions = [
52-
$connection->quoteInto("creation_date < ?", $currentDate)
52+
$connection->quoteInto("Date(creation_date) <= ?", $currentDate)
5353
];
54+
5455
$connection->delete($tableName, $whereConditions);
5556
}
5657
}
5758

58-
/**
59-
* @param null $scopeCode
60-
* @return bool
61-
*/
62-
public function isDeletingEnabled($scopeCode = null): bool
63-
{
64-
return $this->scopeConfig->isSetFlag(
65-
self::XML_PATH_ACTIVE_CAMPAIGN_SYNCLOG_ENABLE,
66-
ScopeInterface::SCOPE_STORES,
67-
$scopeCode
68-
);
69-
}
59+
7060
}

SyncLog/Helper/Data.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
class Data extends AbstractHelper
1010
{
1111
const ACTIVE_CAMPAIGN_SYNCLOG_MODE = "active_campaign/synclog/synclog_mode";
12-
13-
12+
const ACTIVE_CAMPAIGN_REMOVE_AFTER_DAYS = "active_campaign/synclog/remove_after_days";
13+
const XML_PATH_ACTIVE_CAMPAIGN_SYNCLOG_ENABLE = "active_campaign/synclog/synclog_delete";
1414
/**
1515
* @var \Magento\Framework\App\State *
1616
*/
@@ -29,6 +29,13 @@ public function __construct(
2929
$this->state = $state;
3030
}
3131

32+
public function removeAfterDays($scopeCode = null){
33+
return $this->scopeConfig->getValue(
34+
self::ACTIVE_CAMPAIGN_REMOVE_AFTER_DAYS,
35+
ScopeInterface::SCOPE_STORES,
36+
$scopeCode
37+
);
38+
}
3239
/**
3340
* @param null $scopeCode
3441
* @return bool
@@ -42,4 +49,16 @@ public function isLogError($scopeCode = null)
4249
);
4350
}
4451

52+
/**
53+
* @param null $scopeCode
54+
* @return bool
55+
*/
56+
public function isDeletingEnabled($scopeCode = null): bool
57+
{
58+
return $this->scopeConfig->isSetFlag(
59+
self::XML_PATH_ACTIVE_CAMPAIGN_SYNCLOG_ENABLE,
60+
ScopeInterface::SCOPE_STORES,
61+
$scopeCode
62+
);
63+
}
4564
}

SyncLog/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"config": {
1010
"sort-packages": true
1111
},
12-
"version": "2.1.2",
12+
"version": "2.1.3",
1313
"require": {
1414
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
1515
"activecampaign/core": "2.1.*"

SyncLog/etc/adminhtml/system.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@
1818
</field>
1919
<field id="synclog_delete" translate="label" type="select" sortOrder="10" showInDefault="1">
2020
<label>SyncLog Delete</label>
21-
<comment><![CDATA[Choosing yes will start deleting your past 7 days existing SyncLog stored in database.]]></comment>
21+
<comment><![CDATA[Choosing yes will start deleting existing SyncLog stored in database.]]></comment>
2222
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
2323
</field>
24+
<field id="remove_after_days" type="text" sortOrder="19" showInDefault="1">
25+
<label>Delete after (days)</label>
26+
<depends>
27+
<field id="synclog_delete">1</field>
28+
</depends>
29+
</field>
2430
<field id="cron_minute" translate="label comment" type="text" sortOrder="20" showInDefault="1">
2531
<label>Cron Minute</label>
2632
<comment><![CDATA[0-59 Allowed value. Set * for every minute.]]></comment>

0 commit comments

Comments
 (0)