Skip to content

Commit

Permalink
Merge pull request #81 from jorgeeurekalabs/main
Browse files Browse the repository at this point in the history
DEVREL-52 DEVREL-40
  • Loading branch information
jorgeeurekalabs authored Jun 26, 2024
2 parents 7d94bbc + 82c3607 commit 82b5f72
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 23 deletions.
16 changes: 15 additions & 1 deletion AbandonedCart/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Data extends AbstractHelper
{
const ACTIVE_CAMPAIGN_ABANDONED_CART_SYNC = "active_campaign/abandoned_cart/sync";
const ABANDONED_CART_NUMBER_OF_ABANDONED_CART = "active_campaign/abandoned_cart/number_of_abandoned_cart";

const ABANDONED_CART_MIN_INACTIVE_TIME = "active_campaign/abandoned_cart/min_inactive_time";
/**
* @param null $scopeCode
* @return bool
Expand Down Expand Up @@ -49,4 +49,18 @@ public function getNumberOfAbandonedCart($scopeCode = null)
$scopeCode
);
}

/**
* @param null $scopeCode
* @return mixed
*/
public function getMinInactiveTime($scopeCode = null)
{
return $this->scopeConfig->getValue(
self::ABANDONED_CART_MIN_INACTIVE_TIME,
ScopeInterface::SCOPE_STORES,
$scopeCode
);
}

}
6 changes: 5 additions & 1 deletion AbandonedCart/Model/AbandonedCartSendData.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,16 @@ public function sendAbandonedCartData($quoteId = null): array
{
$result = [];
$numberOfAbandonedCart = (int)$this->abandonedCartHelper->getNumberOfAbandonedCart();
$minInactiveTime = (int) $this->abandonedCartHelper->getMinInactiveTime();
$abandonedCarts = $this->quoteResourceCollectionFactory->create()
->addFieldToSelect('*')
->addFieldToFilter('ac_synced_date', [
['lt' => new \Zend_Db_Expr('main_table.updated_at')],
['null' => true]
['null' => true]
])
->addFieldToFilter('main_table.updated_at',
['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)')]
)
->addFieldToFilter(
'is_active',
'1'
Expand Down
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.9",
"version": "2.1.10",
"require": {
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
"activecampaign/core": "2.1.*"
Expand Down
8 changes: 7 additions & 1 deletion AbandonedCart/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@
<field id="sync">1</field>
</depends>
</field>
<field id="ac_abandoned_cart_syncing" translate="label comment" type="button" sortOrder="40" showInDefault="1">
<field id="min_inactive_time" translate="label comment" type="text" sortOrder="40" showInDefault="1">
<label>Minimum inactivity time</label>
<comment><![CDATA[Minimum inactivity time in minutes]]></comment>
</field>
<field id="ac_abandoned_cart_syncing" translate="label comment" type="button" sortOrder="50" showInDefault="1">
<frontend_model>ActiveCampaign\AbandonedCart\Block\System\Config\SyncAbandonedCartData</frontend_model>
<label>Sync Abandoned Cart Data</label>
<depends>
<field id="active_campaign/abandoned_cart/sync">1</field>
</depends>
</field>


</group>
</section>
</system>
Expand Down
1 change: 1 addition & 0 deletions AbandonedCart/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<cron_day>*</cron_day>
<cron_month>*</cron_month>
<cron_weekday>*</cron_weekday>
<min_inactive_time>60</min_inactive_time>
</abandoned_cart>
</active_campaign>
</default>
Expand Down
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.9">
<module name="ActiveCampaign_AbandonedCart" setup_version="2.1.10">
<sequence>
<module name="Magento_Product"/>
<module name="Magento_Sales"/>
Expand Down
2 changes: 1 addition & 1 deletion Customer/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public function createGuestCustomer($data, $storeId){
$ecomCustomerData=[];
$data['connectionid'] = $this->coreHelper->getConnectionId($storeId);
$data['externalid'] = $data['email'];
$data['acceptsMarketing'] = (int)$this->subscriberFactory->create()->loadBySubscriberEmail($data['email'],$this->storeManager->getStore()->getWebsiteId())->isSubscribed();
$data['acceptsMarketing'] = (int)$this->subscriberFactory->create()->loadBySubscriberEmail($data['email'],$this->storeManager->getStore($storeId)->getWebsiteId())->isSubscribed();
$ecomCustomerData['ecomCustomer'] = $data;
if (!$acCustomer) {
$result = $this->curl->createContacts(self::METHOD, self::ECOM_CUSTOMER_ENDPOINT, $ecomCustomerData);
Expand Down
2 changes: 1 addition & 1 deletion Customer/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.10",
"version": "2.1.11",
"require": {
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
"activecampaign/core": "2.1.*"
Expand Down
2 changes: 1 addition & 1 deletion Customer/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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_Customer" setup_version="2.1.10">
<module name="ActiveCampaign_Customer" setup_version="2.1.11">
<sequence>
<module name="ActiveCampaign_Core"/>
</sequence>
Expand Down
12 changes: 1 addition & 11 deletions Newsletter/Cron/NewsletterSyncCron.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,8 @@ public function execute(): void
->setOrder('change_status_at', 'desc')
->setPageSize($newsletterSyncNum)
->setCurPage(1);

foreach ($newsletterCollection as $news) {
$acContact=NULL;

try {
$contactData = [
'email' => $news->getSubscriberEmail()
Expand All @@ -147,16 +145,8 @@ public function execute(): void
$result = $this->customer->updateCustomer($this->getCustomer($news->getCustomerId()));
$acContact = $result['ac_contact_id'];
}else{
$orders = $this->orderCollectionFactory->create()->addAttributeToFilter('customer_email', $news->getEmail())->setOrder('entity_id','desc');


if($orders->getSize()>0){
$store = $orders->getFirstItem()->getStoreId();
$this->customer->createGuestCustomer($contactData,$store);
}else{
$acContact = $this->customer->createGuestContact($contactData);
}

$this->customer->createGuestCustomer($contactData,$news->getStoreId());
}

if ($acContact) {
Expand Down
2 changes: 1 addition & 1 deletion Newsletter/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"config": {
"sort-packages": true
},
"version": "1.0.4",
"version": "1.0.5",
"require": {
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
"activecampaign/core": "2.1.*"
Expand Down
2 changes: 1 addition & 1 deletion Newsletter/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?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_Newsletter" setup_version="1.0.4">
<module name="ActiveCampaign_Newsletter" setup_version="1.0.5">
<sequence>
<module name="ActiveCampaign_Core"/>
<module name="ActiveCampaign_Customer"/>
Expand Down
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.1.21",
"version": "2.1.22",
"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.1.21",
"version": "2.1.22",
"license": [
"OSL-3.0"
],
Expand Down

0 comments on commit 82b5f72

Please sign in to comment.