Add filter for JobManager intervals

This commit is contained in:
gleemand 2021-09-14 17:00:44 +03:00 committed by GitHub
parent 6b095b4271
commit 9bf1c88f4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -1,10 +1,10 @@
# Custom filters
## Usage
## Usage
If you want to modify data, sent between CRM and CMS you can use custom filters.
To use filters you should define a new class in `<prestashop-root>/modules/retailcrm/custom/hooks`. Filename and classname must match the filter name.
Filter class should implement interface *RetailcrmFilterInterface*. In filter class you must define *filter()* function, which will take initial `$object` and return customized `$object`.
Filter class should implement interface *RetailcrmFilterInterface*. In filter class you must define *filter()* function, which will take initial `$object` and return customized `$object`.
## Example
@ -25,7 +25,7 @@ class RetailcrmFilterSaveCustomerAddress implements RetailcrmFilterInterface
* @var array $dataCrm CRM address data
* @var Address $object CMS Address object
*/
$dataCrm = $parameters['dataCrm'];
if (isset($dataCrm['dni'])) {
@ -57,3 +57,5 @@ There are list of available filters:
* *RetailcrmFilterSaveCustomerAddress* - built customer address object, which will be saved to CMS
* *RetailcrmFilterSaveCorporateCustomer* - built corporate customer object, which will be saved to CMS
* *RetailcrmFilterSaveCorporateCustomerAddress* - built corporate customer address object, which will be saved to CMS
* *RetailcrmFilterJobManagerIntervals* - array with jobs as keys and intervals as values

View File

@ -707,12 +707,17 @@ class RetailcrmTools
*/
public static function startJobManager()
{
RetailcrmJobManager::startJobs(array(
$intervals = array(
'RetailcrmClearLogsEvent' => new \DateInterval('P1D'),
'RetailcrmIcmlEvent' => new \DateInterval('PT4H'),
'RetailcrmInventoriesEvent' => new \DateInterval('PT15M'),
'RetailcrmSyncEvent' => new \DateInterval('PT7M'),
'RetailcrmAbandonedCartsEvent' => new \DateInterval('PT1M')
);
RetailcrmJobManager::startJobs(self::filter(
'RetailcrmFilterJobManagerIntervals',
$intervals
));
}