Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Commit

Permalink
- added check on enable disable on single event
Browse files Browse the repository at this point in the history
- added check on collect anonymous events
- added programmable export events cron
  • Loading branch information
ildelux committed Dec 12, 2018
1 parent ac40f66 commit 3b2897b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 11 deletions.
14 changes: 12 additions & 2 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Data extends AbstractHelper
const CONTACTLAB_HUB_MIN_MINUTES_FROM_LAST_UPDATE = 'contactlab_hub/abandoned_cart/min_minutes_from_last_update';
const CONTACTLAB_HUB_MAX_MINUTES_FROM_LAST_UPDATE = 'contactlab_hub/abandoned_cart/max_minutes_from_last_update';
const CONTACTLAB_HUB_CRON_EVENT_LIMIT = 'contactlab_hub/cron_events/limit';
const CONTACTLAB_HUB_CRON_EVENT_DELETE = 'contactlab_hub/cron_events/delete';
const CONTACTLAB_HUB_CRON_PREVIOUS_CUSTOMERS_ENABLED = 'contactlab_hub/cron_previous_customers/enabled';
const CONTACTLAB_HUB_CRON_PREVIOUS_CUSTOMERS_EXPORT_ORDERS = 'contactlab_hub/cron_previous_customers/export_orders';
const CONTACTLAB_HUB_CRON_PREVIOUS_CUSTOMERS_PREVIOUS_DATE = 'contactlab_hub/cron_previous_customers/previous_date';
Expand All @@ -47,6 +48,7 @@ class Data extends AbstractHelper
const CONTACTLAB_HUB_EXCHANGE_RATES_EXCHANGE_RATE = 'contactlab_hub/exchange_rates/exchange_rate';
const CONTACTLAB_HUB_CUSTOMER_EXTRA_PROPERTIES_EXTERNAL_ID = 'contactlab_hub/customer_extra_properties/external_id';
const CONTACTLAB_HUB_CUSTOMER_EXTRA_PROPERTIES_ATTRIBUTE_MAP = 'contactlab_hub/customer_extra_properties/attribute_map';
const CONTACTLAB_HUB_CAN_SEND_ANONIMOUS_EVENTS = 'contactlab_hub/behavior/send_anonymous';
const CONTACTLAB_HUB_DISABLE_SENDING_SUBSCRIPTION_EMAIL = 'contactlab_hub/behavior/disable_sending_subscription_email';
const CONTACTLAB_HUB_DISABLE_SENDING_NEW_CUSTOMER_EMAIL = 'contactlab_hub/behavior/disable_sending_new_customer_email';
const CONTACTLAB_HUB_JS_TRACKING_ENABLED = 'contactlab_hub/js_tracking/enabled';
Expand Down Expand Up @@ -317,9 +319,17 @@ protected function _saveConfig($path, $value, $scopeId)
return $this;
}

public function getMonthsToClean()
public function getMonthsToClean($storeId = null)
{
return 1;
return (int)$this->scopeConfig->getValue(self::CONTACTLAB_HUB_CRON_EVENT_DELETE,
ScopeInterface::SCOPE_STORE, $storeId);
}


public function canSendAnonymousEvents($storeId = null)
{
return (bool)$this->scopeConfig->getValue(self::CONTACTLAB_HUB_CAN_SEND_ANONIMOUS_EVENTS,
ScopeInterface::SCOPE_STORE, $storeId);
}

public function isDiabledSendingSubscriptionEmail($storeId = null)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

},
"type": "magento2-module",
"version": "1.2.5",
"version": "1.3.0",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
44 changes: 38 additions & 6 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,47 @@
</field>
</group>

<group id="cron_events" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Cron Export Events Settings</label>
<field id="limit" translate="label comment" type="select" sortOrder="30" showInDefault="1"
<group id="cron_events" translate="label" type="text" sortOrder="10" showInDefault="1"
showInWebsite="0" showInStore="0">
<label>Cron Export Events</label>
<field id="limit" translate="label comment" type="select" sortOrder="20" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Limit Events to export</label>
<source_model>Contactlab\Hub\Model\Config\Source\Limit</source_model>
<source_model>Contactlab\Hub\Model\Config\Source\Cron\Limit</source_model>
<validate>validate-not-negative-number validate-digits validate-is-min-of-range</validate>
</field>
<field id="frequency" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Frequency</label>
<source_model>Contactlab\Hub\Model\Config\Source\Cron\Frequency</source_model>
<backend_model>Contactlab\Hub\Model\Config\Cron\Events</backend_model>
</field>
<field id="time" translate="label comment" sortOrder="40" type="time" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Start Time</label>
<depends>
<field id="frequency" separator="|">D|W|M</field>
</depends>
</field>
<field id="repeat_minutes" translate="label comment" type="select" sortOrder="40" showInDefault="1"
showInWebsite="0" showInStore="0">
<label>Repeats</label>
<source_model>Contactlab\Hub\Model\Config\Source\Cron\Minutes</source_model>
<depends>
<field id="frequency">I</field>
</depends>
</field>
<field id="repeat_hours" translate="label comment" type="select" sortOrder="50" showInDefault="1"
showInWebsite="0" showInStore="0">
<label>Repeats</label>
<source_model>Contactlab\Hub\Model\Config\Source\Cron\Hours</source_model>
<depends>
<field id="frequency">H</field>
</depends>
</field>
<field id="delete" translate="label comment" type="select" sortOrder="60" showInDefault="1"
showInWebsite="0" showInStore="0">
<label>Delete Exported Events Older Then X Months</label>
<source_model>Contactlab\Hub\Model\Config\Source\Cron\Months</source_model>
</field>
</group>

<group id="cron_previous_customers" translate="label" type="text" sortOrder="10" showInDefault="1"
Expand All @@ -323,7 +355,7 @@
<field id="limit" translate="label comment" type="select" sortOrder="30" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Limit Customers to export</label>
<source_model>Contactlab\Hub\Model\Config\Source\Limit</source_model>
<source_model>Contactlab\Hub\Model\Config\Source\Cron\Limit</source_model>
<validate>validate-not-negative-number validate-digits validate-is-min-of-range</validate>
</field>
<field id="reset" translate="label comment" type="button" sortOrder="90" showInDefault="1"
Expand Down
2 changes: 1 addition & 1 deletion etc/crontab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="contactlab_hub">
<job name="contactlab_hub_export_event" instance="Contactlab\Hub\Cron\ExportEvent" method="execute">
<schedule>* * * * *</schedule>
<config_path>crontab/contactlab_hub/jobs/contactlab_hub_export_event/schedule/cron_expr</config_path>
</job>
<job name="contactlab_hub_previous_customer" instance="Contactlab\Hub\Cron\PreviousCustomer" method="execute">
<schedule>*/5 * * * *</schedule>
Expand Down
2 changes: 1 addition & 1 deletion 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="Contactlab_Hub" setup_version="1.2.3">
<module name="Contactlab_Hub" setup_version="1.3.0">
<sequence>
<module name="Contactlab_Core"/>
</sequence>
Expand Down

0 comments on commit 3b2897b

Please sign in to comment.