idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
39,000
public function sendCampaigns ( ) { if ( $ this -> jobHasAlreadyBeenRun ( 'ddg_automation_campaign' ) ) { $ this -> helper -> log ( 'Skipping ddg_automation_campaign job run' ) ; return ; } $ this -> campaignFactory -> create ( ) -> sendCampaigns ( ) ; }
Send email campaigns .
39,001
public function orderSync ( ) { if ( $ this -> jobHasAlreadyBeenRun ( 'ddg_automation_order_sync' ) ) { $ message = 'Skipping ddg_automation_order_sync job run' ; $ this -> helper -> log ( $ message ) ; return [ 'message' => $ message ] ; } $ orderResult = $ this -> syncOrderFactory -> create ( ) -> sync ( ) ; return $ orderResult ; }
CRON FOR ORDER TRANSACTIONAL DATA .
39,002
public function cleaning ( ) { if ( $ this -> jobHasAlreadyBeenRun ( 'ddg_automation_cleaner' ) ) { $ message = 'Skipping ddg_automation_cleaner job run' ; $ this -> helper -> log ( $ message ) ; return $ message ; } $ tables = [ 'automation' => Schema :: EMAIL_AUTOMATION_TABLE , 'importer' => Schema :: EMAIL_IMPORTER_TABLE , 'campaign' => Schema :: EMAIL_CAMPAIGN_TABLE , ] ; $ message = 'Cleaning cron job result :' ; foreach ( $ tables as $ key => $ table ) { $ result = $ this -> importerResource -> cleanup ( $ table ) ; $ message .= " $result records removed from $key ." ; } $ archivedFolder = $ this -> fileHelper -> getArchiveFolder ( ) ; $ result = $ this -> fileHelper -> deleteDir ( $ archivedFolder ) ; $ message .= ' Deleting archived folder result : ' . $ result ; $ this -> helper -> log ( $ message ) ; return $ message ; }
Cleaning for csv files and connector tables .
39,003
private function jobHasAlreadyBeenRun ( $ jobCode ) { $ currentRunningJob = $ this -> cronCollection -> create ( ) -> addFieldToFilter ( 'job_code' , $ jobCode ) -> addFieldToFilter ( 'status' , 'running' ) -> setPageSize ( 1 ) ; if ( $ currentRunningJob -> getSize ( ) ) { $ jobOfSameTypeAndScheduledAtDateAlreadyExecuted = $ this -> cronCollection -> create ( ) -> addFieldToFilter ( 'job_code' , $ jobCode ) -> addFieldToFilter ( 'scheduled_at' , $ currentRunningJob -> getFirstItem ( ) -> getScheduledAt ( ) ) -> addFieldToFilter ( 'status' , [ 'in' => [ 'success' , 'failed' ] ] ) ; return ( $ jobOfSameTypeAndScheduledAtDateAlreadyExecuted -> getSize ( ) ) ? true : false ; } return false ; }
Check if already ran for same time
39,004
public function syncEmailTemplates ( ) { if ( $ this -> jobHasAlreadyBeenRun ( 'ddg_automation_email_templates' ) ) { $ message = 'Skipping ddg_automation_email_templates job run' ; $ this -> helper -> log ( $ message ) ; return $ message ; } return $ this -> templateFactory -> create ( ) -> sync ( ) ; }
Sync the email templates from dotmailer .
39,005
public function setContactData ( $ customer ) { $ this -> model = $ customer ; $ this -> setReviewCollection ( ) ; parent :: setContactData ( $ customer ) ; return $ this ; }
Set customer data .
39,006
public function setReviewCollection ( ) { $ customerId = $ this -> model -> getId ( ) ; $ collection = $ this -> reviewCollection -> create ( ) -> addCustomerFilter ( $ customerId ) -> setOrder ( 'review_id' , 'DESC' ) ; $ this -> reviewCollection = $ collection ; return $ this ; }
Customer reviews .
39,007
public function getLastReviewDate ( ) { if ( $ this -> reviewCollection -> getSize ( ) ) { $ this -> reviewCollection -> getSelect ( ) -> limit ( 1 ) ; $ createdAt = $ this -> reviewCollection -> getFirstItem ( ) -> getCreatedAt ( ) ; return $ createdAt ; } return '' ; }
Last review date .
39,008
public function getTotalRefund ( ) { $ customerOrders = $ this -> orderCollection -> create ( ) -> addAttributeToFilter ( 'customer_id' , $ this -> model -> getId ( ) ) ; $ totalRefunded = 0 ; foreach ( $ customerOrders as $ order ) { $ refunded = $ order -> getTotalRefunded ( ) ; $ totalRefunded += $ refunded ; } return $ totalRefunded ; }
Total value refunded for the customer .
39,009
public function getCustomerGender ( ) { $ genderId = $ this -> model -> getGender ( ) ; if ( is_numeric ( $ genderId ) ) { $ gender = $ this -> model -> getAttribute ( 'gender' ) -> getSource ( ) -> getOptionText ( $ genderId ) ; return $ gender ; } return '' ; }
customer gender .
39,010
public function getSubscriberStatus ( ) { $ subscriberModel = $ this -> subscriberFactory -> create ( ) -> loadByCustomerId ( $ this -> model -> getId ( ) ) ; if ( $ subscriberModel -> getCustomerId ( ) ) { return $ this -> subscriberStatus [ $ subscriberModel -> getSubscriberStatus ( ) ] ; } return false ; }
Subscriber status for Customer .
39,011
private function getPayload ( $ quote , $ store ) { $ data = [ 'key' => $ quote -> getId ( ) , 'contactIdentifier' => $ quote -> getCustomerEmail ( ) , 'json' => [ 'cartId' => $ quote -> getId ( ) , 'cartUrl' => $ this -> getBasketUrl ( $ quote -> getId ( ) , $ store ) , 'createdDate' => $ this -> dateTime -> date ( \ Zend_Date :: ISO_8601 , $ quote -> getCreatedAt ( ) ) , 'modifiedDate' => $ this -> dateTime -> date ( \ Zend_Date :: ISO_8601 , $ quote -> getUpdatedAt ( ) ) , 'currency' => $ quote -> getQuoteCurrencyCode ( ) , 'subTotal' => round ( $ quote -> getSubtotal ( ) , 2 ) , 'taxAmount' => round ( $ quote -> getShippingAddress ( ) -> getTaxAmount ( ) , 2 ) , 'grandTotal' => round ( $ quote -> getGrandTotal ( ) , 2 ) ] ] ; $ discountTotal = 0 ; $ lineItems = [ ] ; foreach ( $ quote -> getAllVisibleItems ( ) as $ item ) { $ discountTotal += $ item -> getDiscountAmount ( ) ; $ product = $ this -> productRepository -> getById ( $ item -> getProduct ( ) -> getId ( ) , false , $ store -> getId ( ) ) ; $ lineItems [ ] = [ 'sku' => $ item -> getSku ( ) , 'imageUrl' => $ this -> getProductImageUrl ( $ item , $ store ) , 'productUrl' => $ this -> urlFinder -> fetchFor ( $ product ) , 'name' => $ item -> getName ( ) , 'unitPrice' => round ( $ item -> getPrice ( ) , 2 ) , 'quantity' => $ item -> getQty ( ) ] ; } $ data [ 'json' ] [ 'discountAmount' ] = ( float ) $ discountTotal ; $ data [ 'json' ] [ 'lineItems' ] = $ lineItems ; return $ data ; }
Get payload data for API push .
39,012
private function getProductImageUrl ( $ item , $ store ) { $ url = "" ; $ base = $ store -> getBaseUrl ( \ Magento \ Framework \ UrlInterface :: URL_TYPE_MEDIA , true ) . 'catalog/product' ; $ configurableProductImage = $ this -> scopeConfig -> getValue ( 'checkout/cart/configurable_product_image' , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE , $ store -> getId ( ) ) ; if ( $ configurableProductImage === "itself" ) { $ id = $ item -> getProduct ( ) -> getIdBySku ( $ item -> getSku ( ) ) ; $ product = $ this -> productRepository -> getById ( $ id ) ; if ( $ product -> getThumbnail ( ) !== "no_selection" ) { return $ base . $ product -> getThumbnail ( ) ; } } if ( $ item -> getProduct ( ) -> getThumbnail ( ) !== "no_selection" ) { $ url = $ base . $ item -> getProduct ( ) -> getThumbnail ( ) ; } return $ url ; }
Get product image URL . We respect the Configurable Product Image setting in determining which image to retrieve .
39,013
public function getServiceScoreLogo ( ) { $ params = $ this -> getRequest ( ) -> getParams ( ) ; if ( ! isset ( $ params [ 'code' ] ) || ! $ this -> helper -> isCodeValid ( $ params [ 'code' ] ) ) { $ this -> helper -> log ( 'Feefo no valid code is set' ) ; return [ ] ; } $ url = 'http://www.feefo.com/feefo/feefologo.jsp?logon=' ; $ logon = $ this -> helper -> getFeefoLogon ( ) ; $ template = '' ; if ( $ this -> helper -> getFeefoLogoTemplate ( ) ) { $ template = '&template=' . $ this -> helper -> getFeefoLogoTemplate ( ) ; } $ fullUrl = $ url . $ logon . $ template ; $ vendorUrl = 'http://www.feefo.com/feefo/viewvendor.jsp?logon=' . $ logon ; return [ 'vendorUrl' => $ vendorUrl , 'fullUrl' => $ fullUrl ] ; }
Get customer s service score logo and output it .
39,014
private function getQuoteProducts ( ) { $ products = [ ] ; $ params = $ this -> _request -> getParams ( ) ; if ( ! isset ( $ params [ 'quote_id' ] ) || ! isset ( $ params [ 'code' ] ) || ! $ this -> helper -> isCodeValid ( $ params [ 'code' ] ) ) { $ this -> helper -> log ( 'Feefo no quote id or code is set' ) ; return $ products ; } $ quoteId = ( int ) $ params [ 'quote_id' ] ; $ quoteModel = $ this -> quoteFactory -> create ( ) ; $ this -> quoteResource -> load ( $ quoteModel , $ quoteId ) ; if ( ! $ quoteModel -> getId ( ) ) { return $ products ; } $ productCollection = $ this -> review -> getProductCollection ( $ quoteModel ) ; foreach ( $ productCollection as $ product ) { $ products [ $ product -> getSku ( ) ] = $ product -> getName ( ) ; } return $ products ; }
Get quote products to show feefo reviews .
39,015
public function getProductsReview ( $ check = true ) { $ reviews = [ ] ; $ logon = $ this -> helper -> getFeefoLogon ( ) ; $ limit = $ this -> helper -> getFeefoReviewsPerProduct ( ) ; $ products = $ this -> getQuoteProducts ( ) ; foreach ( $ products as $ sku => $ name ) { $ url = 'http://www.feefo.com/feefo/xmlfeed.jsp?logon=' . $ logon . '&limit=' . $ limit . '&vendorref=' . $ sku . '&mode=productonly' ; $ doc = $ this -> domDocument ; $ xsl = $ this -> processor ; if ( $ check ) { $ pathToTemplate = $ this -> getFeefoTemplate ( 'feedback.xsl' ) ; $ doc -> load ( $ pathToTemplate ) ; } else { $ pathToTemplate = $ this -> getFeefoTemplate ( 'feedback-no-th.xsl' ) ; $ doc -> load ( $ pathToTemplate ) ; } $ xsl -> importStyleSheet ( $ doc ) ; $ doc -> loadXML ( file_get_contents ( $ url ) ) ; $ productReview = $ xsl -> transformToXML ( $ doc ) ; if ( strpos ( $ productReview , '<td' ) !== false ) { $ reviews [ $ name ] = $ xsl -> transformToXML ( $ doc ) ; } $ check = false ; } return $ reviews ; }
Get product reviews from feefo .
39,016
private function createMimeFromString ( $ body ) { $ bodyPart = new Part ( $ body ) ; $ bodyPart -> setEncoding ( Mime :: ENCODING_QUOTEDPRINTABLE ) ; $ bodyPart -> setCharset ( SmtpTransportZend2 :: ENCODING ) ; ( $ this -> isHTML ( $ body ) ) ? $ bodyPart -> setType ( Mime :: TYPE_HTML ) : $ bodyPart -> setType ( Mime :: TYPE_TEXT ) ; $ mimeMessage = new \ Zend \ Mime \ Message ( ) ; $ mimeMessage -> addPart ( $ bodyPart ) ; return $ mimeMessage ; }
Create HTML mime message from the string .
39,017
public function setReviewData ( \ Magento \ Review \ Model \ Review $ review ) { $ store = $ this -> storeManager -> getStore ( $ review -> getStoreId ( ) ) ; $ websiteName = $ store -> getWebsite ( ) -> getName ( ) ; $ storeName = $ store -> getName ( ) ; $ this -> setId ( $ review -> getReviewId ( ) ) -> setWebsiteName ( $ websiteName ) -> setStoreName ( $ storeName ) -> setReviewDate ( $ review -> getCreatedAt ( ) ) -> setCustomerId ( $ review -> getCustomerId ( ) ) -> setEmail ( $ review -> getEmail ( ) ) ; return $ this ; }
Set review data .
39,018
public function validate ( $ apiUsername , $ apiPassword ) { if ( $ apiUsername && $ apiPassword ) { $ this -> setApiUsername ( $ apiUsername ) -> setApiPassword ( $ apiPassword ) ; $ accountInfo = $ this -> getAccountInfo ( ) ; if ( isset ( $ accountInfo -> message ) ) { $ message = 'VALIDATION ERROR : ' . $ accountInfo -> message ; $ this -> helper -> debug ( 'validate' , [ $ message ] ) ; return false ; } return $ accountInfo ; } return false ; }
Api validation .
39,019
public function getContactById ( $ id ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CONTACTS . $ id ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET CONTACT INFO ID ' . $ url . ', ' . $ response -> message ; $ this -> helper -> debug ( 'getContactById' , [ $ message ] ) ; } return $ response ; }
Gets a contact by ID . Unsubscribed or suppressed contacts will not be retrieved .
39,020
public function postAddressBookContactsImport ( $ filename , $ addressBookId ) { $ url = $ this -> getApiEndpoint ( ) . "/v2/address-books/{$addressBookId}/contacts/import" ; $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , 'POST' ) ; curl_setopt ( $ ch , CURLOPT_USERPWD , $ this -> getApiUsername ( ) . ':' . $ this -> getApiPassword ( ) ) ; if ( function_exists ( 'curl_file_create' ) ) { $ args [ 'file' ] = curl_file_create ( $ this -> fileHelper -> getFilePathWithFallback ( $ filename ) , 'text/csv' ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ args ) ; } else { curl_setopt ( $ ch , CURLOPT_POSTFIELDS , [ 'file' => '@' . $ this -> fileHelper -> getFilePathWithFallback ( $ filename ) , ] ) ; } curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , [ 'Content-Type: multipart/form-data' , ] ) ; $ result = curl_exec ( $ ch ) ; $ result = json_decode ( $ result ) ; if ( isset ( $ result -> message ) ) { $ message = 'postAddressBookContactsImport' . $ addressBookId . ' file : ' . $ filename . ' ,user : ' . $ this -> getApiUsername ( ) . '. ' . $ result -> message ; $ this -> helper -> debug ( 'postAddressBookContactsImport' , [ $ message ] ) ; } return $ result ; }
Bulk creates or bulk updates contacts . Import format can either be CSV or Excel . Must include one column called Email . Any other columns will attempt to map to your custom data fields . The ID of returned object can be used to query import progress .
39,021
public function postAddressBookContacts ( $ addressBookId , $ apiContact ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_ADDRESS_BOOKS . $ addressBookId . '/contacts' ; $ this -> setUrl ( $ url ) -> setVerb ( 'POST' ) -> buildPostBody ( $ apiContact ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'POST ADDRESS BOOK CONTACTS ' . $ url . ', ' . $ response -> message ; $ this -> helper -> debug ( 'postAddressBookContacts' , [ $ message ] ) ; } return $ response ; }
Adds a contact to a given address book .
39,022
public function deleteAddressBookContact ( $ addressBookId , $ contactId ) { if ( $ addressBookId && $ contactId ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_ADDRESS_BOOKS . $ addressBookId . '/contacts/' . $ contactId ; $ this -> setUrl ( $ url ) -> setVerb ( 'DELETE' ) ; $ this -> execute ( ) ; $ this -> helper -> log ( sprintf ( 'Delete-contact %s from addressbook %s' , $ contactId , $ addressBookId ) ) ; } }
Deletes all contacts from a given address book .
39,023
public function getContactsImportReport ( $ importId ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CONTACTS_IMPORT . $ importId . '/report' ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET CONTACTS IMPORT REPORT . ' . $ url . ' message : ' . $ response -> message ; $ this -> helper -> debug ( 'getContactsImportReport' , [ $ message ] ) ; } return $ response ; }
Gets a report with statistics about what was successfully imported and what was unable to be imported .
39,024
public function getContactByEmail ( $ email ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CONTACTS . $ email ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET CONTACT BY email : ' . $ email . ' ' . $ response -> message ; $ this -> helper -> debug ( 'getContactByEmail' , [ $ message ] ) ; } return $ response ; }
Gets a contact by email address .
39,025
public function getAddressBooks ( ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_ADDRESS_BOOKS ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET ALL ADDRESS BOOKS : ' . $ url . ', ' . $ response -> message ; $ this -> helper -> debug ( 'getAddressBooks' , [ $ message ] ) ; } return $ response ; }
Get all address books .
39,026
public function postAddressBooks ( $ name , $ visibility = 'Public' ) { $ data = [ 'Name' => $ name , 'Visibility' => $ visibility , ] ; $ url = $ this -> getApiEndpoint ( ) . self :: REST_ADDRESS_BOOKS ; $ this -> setUrl ( $ url ) -> setVerb ( 'POST' ) -> buildPostBody ( $ data ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ this -> helper -> debug ( 'postAddressBooks' , $ data ) ; } return $ response ; }
Creates an address book .
39,027
public function getCampaigns ( $ skip = 0 , $ select = 1000 ) { $ url = sprintf ( '%s%s?select=%s&skip=%s' , $ this -> getApiEndpoint ( ) , self :: REST_DATA_FIELDS_CAMPAIGNS , $ select , $ skip ) ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET CAMPAIGNS ' . $ response -> message . ' api user : ' . $ this -> getApiUsername ( ) ; $ this -> helper -> debug ( 'getCampaigns' , [ $ message ] ) ; } return $ response ; }
Get list of all campaigns .
39,028
public function postDataFields ( $ data , $ type = 'String' , $ visibility = 'public' , $ defaultValue = false ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_DATA_FILEDS ; if ( $ type == 'numeric' && ! $ defaultValue ) { $ defaultValue = 0 ; } if ( is_string ( $ data ) ) { $ data = [ 'Name' => $ data , 'Type' => $ type , 'Visibility' => $ visibility , ] ; if ( $ defaultValue ) { $ data [ 'DefaultValue' ] = $ defaultValue ; } } $ this -> setUrl ( $ url ) -> buildPostBody ( $ data ) -> setVerb ( 'POST' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'POST CREATE DATAFIELDS ' . $ response -> message ; $ this -> helper -> debug ( 'postDataFields' , [ $ message ] ) ; $ this -> helper -> debug ( 'postDataFields' , $ data ) ; } return $ response ; }
Creates a data field within the account .
39,029
public function getDataFields ( ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_DATA_FILEDS ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET ALL DATAFIELDS ' . $ response -> message ; $ this -> helper -> debug ( 'getDataFields' , [ $ message ] ) ; } return $ response ; }
Lists the data fields within the account .
39,030
public function updateContact ( $ contactId , $ data ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CONTACTS . $ contactId ; $ this -> setUrl ( $ url ) -> setVerb ( 'PUT' ) -> buildPostBody ( $ data ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'ERROR : UPDATE SINGLE CONTACT : ' . $ url . ' message : ' . $ response -> message ; $ this -> helper -> debug ( 'updateContact' , [ $ message ] ) ; $ this -> helper -> debug ( 'updateContact' , $ data ) ; } return $ response ; }
Updates a contact .
39,031
public function deleteContact ( $ contactId ) { if ( $ contactId ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CONTACTS . $ contactId ; $ this -> setUrl ( $ url ) -> setVerb ( 'DELETE' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = ' url : ' . $ url . ', ' . $ response -> message ; $ this -> helper -> debug ( 'deleteContact' , [ $ message ] ) ; } return $ response ; } }
Deletes a contact .
39,032
public function updateContactDatafieldsByEmail ( $ email , $ dataFields ) { $ apiContact = $ this -> postContacts ( $ email ) ; if ( ! isset ( $ apiContact -> id ) ) { return $ apiContact ; } else { $ contactId = $ apiContact -> id ; } $ data = [ 'Email' => $ email , 'EmailType' => 'Html' , ] ; $ data [ 'DataFields' ] = $ dataFields ; $ url = $ this -> getApiEndpoint ( ) . self :: REST_CONTACTS . $ contactId ; $ this -> setUrl ( $ url ) -> setVerb ( 'PUT' ) -> buildPostBody ( $ data ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'ERROR: UPDATE CONTACT DATAFIELD ' . $ url . ' message : ' . $ response -> message ; $ this -> helper -> debug ( 'updateContactDatafieldsByEmail' , [ $ message ] ) ; $ this -> helper -> debug ( 'updateContactDatafieldsByEmail' , $ data ) ; } return $ response ; }
Update contact datafields by email .
39,033
public function postCampaignsSend ( $ campaignId , $ contacts ) { $ data = [ 'username' => $ this -> getApiUsername ( ) , 'password' => $ this -> getApiPassword ( ) , 'campaignId' => $ campaignId , 'ContactIds' => $ contacts , ] ; $ this -> setUrl ( $ this -> getApiEndpoint ( ) . self :: REST_CAMPAIGN_SEND ) -> setVerb ( 'POST' ) -> buildPostBody ( $ data ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { unset ( $ data [ 'password' ] ) ; $ message = 'SENDING CAMPAIGN ' . $ response -> message ; $ this -> helper -> debug ( 'postCampaignsSend' , [ $ message ] ) ; $ this -> helper -> debug ( 'postCampaignsSend' , $ data ) ; } return $ response ; }
Sends a specified campaign to one or more address books segments or contacts at a specified time . Leave the address book array empty to send to All Contacts .
39,034
public function postContacts ( $ email ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CONTACTS ; $ data = [ 'Email' => $ email , 'EmailType' => 'Html' , ] ; $ this -> setUrl ( $ url ) -> setVerb ( 'POST' ) -> buildPostBody ( $ data ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = $ email . ' , url ' . $ url . ', ' . $ response -> message ; $ this -> helper -> debug ( 'postContacts' , [ $ message ] ) ; } return $ response ; }
Creates a contact .
39,035
public function getContactsSuppressedSinceDate ( $ dateString , $ select = 1000 , $ skip = 0 ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CONTACTS_SUPPRESSED_SINCE . $ dateString . '?select=' . $ select . '&skip=' . $ skip ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET CONTACTS SUPPRESSED SINSE : ' . $ dateString . ' select ' . $ select . ' skip : ' . $ skip . ' response : ' . $ response -> message ; $ this -> helper -> debug ( 'getContactsSuppressedSinceDate' , [ $ message ] ) ; } return $ response ; }
Gets a list of suppressed contacts after a given date along with the reason for suppression .
39,036
public function postContactsTransactionalData ( $ data , $ collectionName = 'Orders' ) { $ order = $ this -> getContactsTransactionalDataByKey ( $ collectionName , $ data [ 'id' ] ) ; if ( ! isset ( $ order -> key ) || isset ( $ order -> message ) && $ order -> message == self :: API_ERROR_TRANS_NOT_EXISTS ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_TRANSACTIONAL_DATA . $ collectionName ; } else { $ url = $ this -> getApiEndpoint ( ) . self :: REST_TRANSACTIONAL_DATA . $ collectionName . '/' . $ order -> key ; } $ apiData = [ 'Key' => $ data [ 'id' ] , 'ContactIdentifier' => $ data [ 'email' ] , 'Json' => json_encode ( $ data ) , ] ; $ this -> setUrl ( $ url ) -> setVerb ( 'POST' ) -> buildPostBody ( $ apiData ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'POST CONTACTS TRANSACTIONAL DATA ' . $ response -> message ; $ this -> helper -> debug ( 'postContactsTransactionalData' , [ $ message ] ) ; $ this -> helper -> debug ( 'postContactsTransactionalData' , $ apiData ) ; } return $ response ; }
Adds a single piece of transactional data to a contact .
39,037
public function getContactsTransactionalDataByKey ( $ name , $ key ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_TRANSACTIONAL_DATA . $ name . '/' . $ key ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; return $ this -> execute ( ) ; }
Gets a piece of transactional data by key .
39,038
public function deleteContactTransactionalData ( $ email , $ collectionName = 'Orders' ) { if ( $ email && $ collectionName ) { $ url = $ this -> getApiEndpoint ( ) . '/v2/contacts/' . $ email . '/transactional-data/' . $ collectionName ; $ this -> setUrl ( $ url ) -> setVerb ( 'DELETE' ) ; return $ this -> execute ( ) ; } }
Deletes all transactional data for a contact .
39,039
public function getAccountInfo ( ) { $ url = self :: REST_ACCOUNT_INFO ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET ACCOUNT INFO for api user : ' . $ this -> getApiUsername ( ) . ' ' . $ response -> message ; $ this -> helper -> debug ( 'getAccountInfo' , [ $ message ] ) ; } return $ response ; }
Gets a summary of information about the current status of the account .
39,040
public function postContactsResubscribe ( $ apiContact ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CONTACTS_RESUBSCRIBE ; $ data = [ 'UnsubscribedContact' => $ apiContact , ] ; $ this -> setUrl ( $ url ) -> setVerb ( 'POST' ) -> buildPostBody ( $ data ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'Resubscribe : ' . $ url . ', message :' . $ response -> message ; $ this -> helper -> debug ( 'postContactsResubscribe' , [ $ message ] ) ; $ this -> helper -> debug ( 'postContactsResubscriber' , $ data ) ; } return $ response ; }
Resubscribes a previously unsubscribed contact .
39,041
public function getCustomFromAddresses ( ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CAMPAIGN_FROM_ADDRESS_LIST ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET CampaignFromAddressList ' . $ response -> message . ' api user : ' . $ this -> getApiUsername ( ) ; $ this -> helper -> debug ( 'getCustomFromAddresses' , [ $ message ] ) ; } return $ response ; }
Gets all custom from addresses which can be used in a campaign .
39,042
public function postCampaign ( $ data ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CREATE_CAMPAIGN ; $ this -> setUrl ( $ url ) -> setVerb ( 'POST' ) -> buildPostBody ( $ data ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = $ response -> message ; $ this -> helper -> debug ( 'postCampaign' , [ $ message ] ) ; } return $ response ; }
Creates a campaign .
39,043
public function postProgramsEnrolments ( $ data ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_PROGRAM_ENROLMENTS ; $ this -> setUrl ( $ url ) -> setVerb ( 'POST' ) -> buildPostBody ( $ data ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'Post programs enrolments : ' . $ response -> message ; $ this -> helper -> debug ( 'postProgramsEnrolments' , [ $ message ] ) ; $ this -> helper -> debug ( 'postProgramsEnrolments' , $ data ) ; } return $ response ; }
Creates an enrolment .
39,044
public function getCampaignSummary ( $ campaignId ) { $ url = $ this -> getApiEndpoint ( ) . '/v2/campaigns/' . $ campaignId . '/summary' ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'Get Campaign Summary ' . $ response -> message . ' ,url : ' . $ url ; $ this -> helper -> debug ( 'title' , [ $ message ] ) ; } return $ response ; }
Gets a summary of reporting information for a specified campaign .
39,045
public function deleteContactsTransactionalData ( $ key , $ collectionName = 'Orders' ) { if ( $ key && $ collectionName ) { $ url = $ this -> getApiEndpoint ( ) . '/v2/contacts/transactional-data/' . $ collectionName . '/' . $ key ; $ this -> setUrl ( $ url ) -> setVerb ( 'DELETE' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ this -> helper -> debug ( 'deleteContactsTransactionalData' , [ 'DELETE CONTACTS TRANSACTIONAL DATA : ' . $ url . ' ' . $ response -> message ] ) ; } return $ response ; } }
Deletes a piece of transactional data by key .
39,046
public function postCampaignAttachments ( $ campaignId , $ data ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CREATE_CAMPAIGN . "/$campaignId/attachments" ; $ this -> setUrl ( $ url ) -> setVerb ( 'POST' ) -> buildPostBody ( $ data ) ; $ result = $ this -> execute ( ) ; if ( isset ( $ result -> message ) ) { $ this -> helper -> debug ( 'postCampaignAttachments' , [ ' CAMPAIGN ATTACHMENT ' . $ result -> message ] ) ; } return $ result ; }
Adds a document to a campaign as an attachment .
39,047
public function getContactAddressBooks ( $ contactId ) { $ url = $ this -> getApiEndpoint ( ) . '/v2/contacts/' . $ contactId . '/address-books' ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET CONTACTS ADDRESS BOOKS contact: ' . $ contactId . $ response -> message ; $ this -> helper -> debug ( 'getContactAddressBooks' , [ $ message ] ) ; } return $ response ; }
Get contact address books .
39,048
public function getApiTemplateList ( ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_TEMPLATES ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET API CONTACT LIST ' . $ response -> message ; $ this -> helper -> debug ( 'getApiTemplateList' , [ $ message ] ) ; } return $ response ; }
Gets list of all templates .
39,049
public function getContactsTransactionalDataImportByImportId ( $ importId ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_TRANSACTIONAL_DATA_IMPORT . $ importId ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'GET CONTACTS TRANSACTIONAL DATA IMPORT BY IMPORT ID ' . $ response -> message ; $ this -> helper -> debug ( 'getContactsTransactionalDataImportByImportId' , [ $ message ] ) ; } return $ response ; }
Gets the import status of a previously started transactional import .
39,050
public function getContactImportReportFaults ( $ id ) { $ this -> isNotJson = true ; $ url = $ this -> getApiEndpoint ( ) . self :: REST_CONTACTS_IMPORT . $ id . '/report-faults' ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( json_decode ( $ response ) ) { if ( isset ( $ response -> message ) ) { $ message = 'GET CONTACT IMPORT REPORT FAULTS: ' . $ response -> message ; $ this -> helper -> log ( $ message ) ; } return false ; } return $ response ; }
Get contact import report faults .
39,051
public function getSendStatus ( $ id ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_CAMPAIGN_SEND . '/' . $ id ; $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) && ! in_array ( $ response -> message , $ this -> exludeMessages ) ) { $ message = 'GETS THE SEND STATUS USING SEND ID: ' . $ response -> message ; $ this -> helper -> log ( $ message ) ; } return $ response ; }
Gets the send status using send ID .
39,052
public function sendApiTransactionalEmail ( $ content ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_SEND_TRANSACTIONAL_EMAIL ; $ this -> setUrl ( $ url ) -> setVerb ( 'POST' ) -> buildPostBody ( $ content ) ; $ this -> execute ( ) ; }
Sends a transactional email .
39,053
public function getEmailStats ( $ date , $ endDate = null , $ aggregatedBy = null ) { $ url = $ this -> getApiEndpoint ( ) . '/v2/email/stats/since-date/' . $ date ; if ( $ endDate && $ aggregatedBy ) { $ url .= '?endDate=' . $ endDate . '&aggregatedBy=' . $ aggregatedBy ; } $ response = $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ this -> helper -> log ( 'GET EMAIL STATS : ' . $ response -> message ) ; } return $ response ; }
Gets transactional email reporting statistics for a specified time period .
39,054
public function getPreferencesForContact ( $ contactId ) { $ url = $ this -> getApiEndpoint ( ) . "/v2/contact/" . $ contactId . "/preferences" ; $ response = $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ this -> helper -> log ( 'GET PREFERENCES FOR CONTACT: ' . $ response -> message ) ; } return $ response ; }
Gets all preferences that a given contact is opted into
39,055
public function setPreferencesForContact ( $ contactId , $ preferences ) { $ url = $ this -> getApiEndpoint ( ) . "/v2/contact/" . $ contactId . "/preferences" ; $ this -> setUrl ( $ url ) -> setVerb ( 'PUT' ) -> buildPostBody ( $ preferences ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ this -> helper -> log ( 'SET PREFERENCES FOR CONTACT: ' . $ response -> message ) ; } return $ response ; }
Opts in a given contact to preferences or opts out a given contact from preferences
39,056
public function getPreferences ( ) { $ url = $ this -> getApiEndpoint ( ) . "/v2/preferences" ; $ response = $ this -> setUrl ( $ url ) -> setVerb ( 'GET' ) -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ this -> helper -> log ( 'GET PREFERENCES: ' . $ response -> message ) ; } return $ response ; }
Gets the preferences as a tree structure
39,057
public function sync ( ) { $ this -> start = microtime ( true ) ; $ websites = $ this -> helper -> getWebsites ( ) ; foreach ( $ websites as $ website ) { $ addresbook = $ this -> helper -> getGuestAddressBook ( $ website ) ; $ guestSyncEnabled = $ this -> helper -> isGuestSyncEnabled ( $ website ) ; $ apiEnabled = $ this -> helper -> isEnabled ( $ website ) ; if ( $ addresbook && $ guestSyncEnabled && $ apiEnabled ) { $ this -> exportGuestPerWebsite ( $ website ) ; } } if ( $ this -> countGuests ) { $ this -> helper -> log ( '----------- Guest sync ----------- : ' . gmdate ( 'H:i:s' , microtime ( true ) - $ this -> start ) . ', Total synced = ' . $ this -> countGuests ) ; } }
GUEST SYNC .
39,058
public function exportGuestPerWebsite ( $ website ) { $ onlySubscribers = $ this -> helper -> isOnlySubscribersForContactSync ( $ website -> getWebsiteId ( ) ) ; $ contact = $ this -> contactFactory -> create ( ) ; $ guests = ( $ onlySubscribers ) ? $ contact -> getGuests ( $ website , true ) : $ contact -> getGuests ( $ website ) ; if ( $ guests -> getSize ( ) ) { $ guestFilename = strtolower ( $ website -> getCode ( ) . '_guest_' . date ( 'd_m_Y_His' ) . '.csv' ) ; $ this -> helper -> log ( 'Guest file: ' . $ guestFilename ) ; $ storeName = $ this -> helper -> getMappedStoreName ( $ website ) ; $ this -> file -> outputCSV ( $ this -> file -> getFilePath ( $ guestFilename ) , [ 'Email' , 'emailType' , $ storeName ] ) ; foreach ( $ guests as $ guest ) { $ this -> outputCsvToFile ( $ guest , $ website , $ guestFilename ) ; } if ( $ this -> countGuests ) { $ this -> importerFactory -> create ( ) -> registerQueue ( \ Dotdigitalgroup \ Email \ Model \ Importer :: IMPORT_TYPE_GUEST , '' , \ Dotdigitalgroup \ Email \ Model \ Importer :: MODE_BULK , $ website -> getId ( ) , $ guestFilename ) ; } } }
Export guests for a website .
39,059
public function toOptionArray ( ) { $ options = [ ] ; $ excluded = [ 'created_at' , 'created_in' , 'dob' , 'dotmailer_contact_id' , 'email' , 'firstname' , 'lastname' , 'gender' , 'group_id' , 'password_hash' , 'prefix' , 'rp_token' , 'rp_token_create_at' , 'website_id' , ] ; $ attributes = $ this -> customerFactory -> create ( ) -> getAttributes ( ) ; foreach ( $ attributes as $ attribute ) { if ( $ attribute -> getFrontendLabel ( ) ) { $ code = $ attribute -> getAttributeCode ( ) ; $ label = $ this -> escaper -> escapeQuote ( $ attribute -> getFrontendLabel ( ) ) ; if ( ! in_array ( $ code , $ excluded ) ) { $ options [ ] = [ 'value' => $ attribute -> getAttributeCode ( ) , 'label' => $ label , ] ; } } } return $ options ; }
Customer custom attributes .
39,060
public function syncByStore ( $ storeId , $ websiteId , $ limit , $ importType ) { $ products = $ this -> exporter -> exportCatalog ( $ storeId , $ limit ) ; $ success = $ this -> importerFactory -> create ( ) -> registerQueue ( $ importType , $ products , \ Dotdigitalgroup \ Email \ Model \ Importer :: MODE_BULK , $ websiteId ) ; if ( $ success ) { return $ products ; } else { $ pid = implode ( "," , array_keys ( $ products ) ) ; $ msg = "Failed to register with IMPORTER. Type(Catalog) / Scope(Bulk) / Store($storeId) / Product Ids($pid)" ; $ this -> helper -> log ( $ msg ) ; } return [ ] ; }
Sync by store
39,061
public function process ( $ collection , $ type , $ websiteId ) { $ this -> ruleType = $ type ; $ emailRules = $ this -> getActiveRuleForWebsite ( $ type , $ websiteId ) ; if ( empty ( $ emailRules ) ) { return $ collection ; } $ condition = $ this -> serializer -> unserialize ( $ emailRules -> getConditions ( ) ) ; if ( empty ( $ condition ) ) { return $ collection ; } $ combination = $ emailRules -> getCombination ( ) ; $ collection = $ this -> rulesResource -> joinTablesOnCollectionByType ( $ collection , $ type ) ; if ( $ combination == self :: COMBINATION_TYPE_ALL ) { $ collection = $ this -> processAndCombination ( $ collection , $ condition ) ; } if ( $ combination == self :: COMBINATION_TYPE_ANY ) { $ collection = $ this -> processOrCombination ( $ collection , $ condition ) ; } return $ collection ; }
Process rule on collection .
39,062
public function processAndCombination ( $ collection , $ conditions ) { foreach ( $ conditions as $ condition ) { $ attribute = $ condition [ 'attribute' ] ; $ cond = $ condition [ 'conditions' ] ; $ value = $ condition [ 'cvalue' ] ; if ( $ value == '' || $ value == null ) { continue ; } if ( in_array ( $ attribute , $ this -> used ) ) { continue ; } $ this -> used [ ] = $ attribute ; if ( $ this -> ruleType == self :: REVIEW && isset ( $ this -> attributeMapForQuote [ $ attribute ] ) ) { $ attribute = $ this -> attributeMapForOrder [ $ attribute ] ; } elseif ( $ this -> ruleType == self :: ABANDONED && isset ( $ this -> attributeMapForOrder [ $ attribute ] ) ) { $ attribute = $ this -> attributeMapForQuote [ $ attribute ] ; } else { $ this -> productAttribute [ ] = $ condition ; continue ; } $ collection = $ this -> processProcessAndCombinationCondition ( $ collection , $ cond , $ value , $ attribute ) ; } return $ this -> processProductAttributes ( $ collection ) ; }
Process And combination on collection .
39,063
public function processOrCombination ( $ collection , $ conditions ) { $ fieldsConditions = [ ] ; $ multiFieldsConditions = [ ] ; foreach ( $ conditions as $ condition ) { $ attribute = $ condition [ 'attribute' ] ; $ cond = $ condition [ 'conditions' ] ; $ value = $ condition [ 'cvalue' ] ; if ( $ value == '' or $ value == null ) { continue ; } if ( $ this -> ruleType == self :: REVIEW && isset ( $ this -> attributeMapForQuote [ $ attribute ] ) ) { $ attribute = $ this -> attributeMapForOrder [ $ attribute ] ; } elseif ( $ this -> ruleType == self :: ABANDONED && isset ( $ this -> attributeMapForOrder [ $ attribute ] ) ) { $ attribute = $ this -> attributeMapForQuote [ $ attribute ] ; } else { $ this -> productAttribute [ ] = $ condition ; continue ; } if ( $ cond == 'null' ) { if ( $ value == '1' ) { if ( isset ( $ fieldsConditions [ $ attribute ] ) ) { $ multiFieldsConditions [ $ attribute ] [ ] = [ 'notnull' => true ] ; continue ; } $ fieldsConditions [ $ attribute ] = [ 'notnull' => true ] ; } elseif ( $ value == '0' ) { if ( isset ( $ fieldsConditions [ $ attribute ] ) ) { $ multiFieldsConditions [ $ attribute ] [ ] = [ $ cond => true ] ; continue ; } $ fieldsConditions [ $ attribute ] = [ $ cond => true ] ; } } else { if ( $ cond == 'like' or $ cond == 'nlike' ) { $ value = '%' . $ value . '%' ; } if ( isset ( $ fieldsConditions [ $ attribute ] ) ) { $ multiFieldsConditions [ $ attribute ] [ ] = [ $ this -> conditionMap [ $ cond ] => $ value ] ; continue ; } $ fieldsConditions [ $ attribute ] = [ $ this -> conditionMap [ $ cond ] => $ value ] ; } } if ( ! empty ( $ fieldsConditions ) ) { $ column = $ cond = [ ] ; foreach ( $ fieldsConditions as $ key => $ fieldsCondition ) { $ column [ ] = ( string ) $ key ; $ cond [ ] = $ fieldsCondition ; if ( ! empty ( $ multiFieldsConditions [ $ key ] ) ) { foreach ( $ multiFieldsConditions [ $ key ] as $ multiFieldsCondition ) { $ column [ ] = ( string ) $ key ; $ cond [ ] = $ multiFieldsCondition ; } } } $ collection -> addFieldToFilter ( $ column , $ cond ) ; } return $ this -> processProductAttributes ( $ collection ) ; }
process Or combination on collection .
39,064
public function _evaluate ( $ varOne , $ op , $ varTwo ) { switch ( $ op ) { case 'eq' : return $ varOne == $ varTwo ; case 'neq' : return $ varOne != $ varTwo ; case 'gteq' : return $ varOne >= $ varTwo ; case 'lteq' : return $ varOne <= $ varTwo ; case 'gt' : return $ varOne > $ varTwo ; case 'lt' : return $ varOne < $ varTwo ; } return false ; }
Evaluate two values against condition .
39,065
public function setItem ( $ item ) { $ this -> items [ ] = $ item -> expose ( ) ; $ this -> totalWishlistValue += $ item -> getTotalValueOfProduct ( ) ; }
Set wishlist item .
39,066
public function setUpdatedAt ( $ date ) { $ date = $ this -> localeDate -> date ( $ date ) -> format ( \ Zend_Date :: ISO_8601 ) ; $ this -> updatedAt = $ date ; return $ this ; }
Set wishlist date .
39,067
public function getInputTypeOptions ( $ type ) { switch ( $ type ) { case 'numeric' : return $ this -> optionsForNumericType ( ) ; case 'select' : return $ this -> toOptionArray ( ) ; case 'string' : return $ this -> optionsForStringType ( ) ; } return $ this -> optionsForStringType ( ) ; }
Get condition options according to type .
39,068
private function optionsForNumericType ( ) { $ options = $ this -> toOptionArray ( ) ; $ options [ ] = [ 'value' => 'gteq' , 'label' => __ ( 'equals or greater than' ) , ] ; $ options [ ] = [ 'value' => 'lteq' , 'label' => __ ( 'equals or less then' ) , ] ; $ options [ ] = [ 'value' => 'gt' , 'label' => __ ( 'greater than' ) ] ; $ options [ ] = [ 'value' => 'lt' , 'label' => __ ( 'less than' ) ] ; return $ options ; }
Condition options for numeric type .
39,069
public function updateAbandonedCartDatafields ( $ email , $ websiteId , $ quoteId , $ parentStoreName ) { $ website = $ this -> storeManager -> getWebsite ( $ websiteId ) ; $ quoteModel = $ this -> magentoQuoteFactory -> create ( ) -> loadByIdWithoutStore ( $ quoteId ) ; $ items = $ quoteModel -> getAllItems ( ) ; $ nominatedAbandonedCartItem = $ this -> ddgQuoteFactory -> create ( ) -> getMostExpensiveItems ( $ items ) ; if ( $ lastQuoteId = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID ) ) { $ data [ ] = [ 'Key' => $ lastQuoteId , 'Value' => $ quoteId , ] ; } if ( $ abandonedProductName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME ) ) { $ data [ ] = [ 'Key' => $ abandonedProductName , 'Value' => $ nominatedAbandonedCartItem -> getName ( ) , ] ; } if ( $ storeName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME ) ) { $ data [ ] = [ 'Key' => $ storeName , 'Value' => $ parentStoreName , ] ; } if ( $ websiteName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME ) ) { $ data [ ] = [ 'Key' => $ websiteName , 'Value' => $ website -> getName ( ) , ] ; } if ( ! empty ( $ data ) ) { $ client = $ this -> helper -> getWebsiteApiClient ( $ website ) ; $ client -> updateContactDatafieldsByEmail ( $ email , $ data ) ; } }
Update abandoned cart data fields .
39,070
public function getValueElementType ( $ attribute ) { switch ( $ attribute ) { case 'method' : case 'shipping_method' : case 'country_id' : case 'region_id' : case 'customer_group_id' : return 'select' ; default : $ attribute = $ this -> configFactory -> getAttribute ( 'catalog_product' , $ attribute ) ; if ( $ attribute -> usesSource ( ) ) { return 'select' ; } } return 'text' ; }
Get element type .
39,071
public function getValueSelectOptions ( $ attribute , $ isEmpty = false ) { $ options = [ ] ; if ( $ isEmpty ) { $ options = $ this -> yesno -> toOptionArray ( ) ; return $ options ; } switch ( $ attribute ) { case 'country_id' : $ options = $ this -> country -> toOptionArray ( ) ; break ; case 'region_id' : $ options = $ this -> allregion -> toOptionArray ( ) ; break ; case 'shipping_method' : $ options = $ this -> allShippingMethods -> toOptionArray ( ) ; break ; case 'method' : $ options = $ this -> allPaymentMethods -> toOptionArray ( ) ; break ; case 'customer_group_id' : $ options = $ this -> sourceGroup -> toOptionArray ( ) ; break ; default : $ attribute = $ this -> configFactory -> getAttribute ( 'catalog_product' , $ attribute ) ; if ( $ attribute -> usesSource ( ) ) { $ options = $ attribute -> getSource ( ) -> getAllOptions ( ) ; } } return $ options ; }
Get options array .
39,072
public function sync ( ) { $ response = [ 'success' => true , 'message' => 'Done.' ] ; $ this -> searchWebsiteAccounts ( ) ; foreach ( $ this -> accounts as $ account ) { $ orders = $ account -> getOrders ( ) ; $ ordersForSingleSync = $ account -> getOrdersForSingleSync ( ) ; $ numOrders = count ( $ orders ) ; $ numOrdersForSingleSync = count ( $ ordersForSingleSync ) ; $ website = $ account -> getWebsites ( ) ; $ this -> countOrders += $ numOrders ; $ this -> countOrders += $ numOrdersForSingleSync ; if ( $ numOrders ) { $ this -> helper -> log ( '--------- Order sync ---------- : ' . $ numOrders ) ; $ this -> importerFactory -> create ( ) -> registerQueue ( \ Dotdigitalgroup \ Email \ Model \ Importer :: IMPORT_TYPE_ORDERS , $ orders , \ Dotdigitalgroup \ Email \ Model \ Importer :: MODE_BULK , $ website [ 0 ] ) ; } if ( $ numOrdersForSingleSync ) { $ this -> createSingleImports ( $ ordersForSingleSync , $ website ) ; } $ this -> orderResource -> setImported ( $ this -> orderIds ) ; unset ( $ this -> accounts [ $ account -> getApiUsername ( ) ] ) ; } if ( ! empty ( $ this -> guests ) ) { $ orderEmails = array_keys ( $ this -> guests ) ; $ guestsEmailFound = $ this -> contactCollectionFactory -> create ( ) -> addFieldToFilter ( 'email' , [ 'in' => $ orderEmails ] ) -> getColumnValues ( 'email' ) ; foreach ( $ guestsEmailFound as $ email ) { unset ( $ this -> guests [ strtolower ( $ email ) ] ) ; } $ this -> contactResource -> insertGuests ( $ this -> guests ) ; $ this -> contactResource -> updateContactsAsGuests ( $ guestsEmailFound ) ; } if ( $ this -> countOrders ) { $ response [ 'message' ] = 'Orders updated ' . $ this -> countOrders ; } return $ response ; }
Initial sync the transactional data .
39,073
public function searchWebsiteAccounts ( ) { $ websites = $ this -> helper -> getWebsites ( ) ; foreach ( $ websites as $ website ) { $ apiEnabled = $ this -> helper -> isEnabled ( $ website ) ; $ storeIds = $ website -> getStoreIds ( ) ; if ( $ apiEnabled && $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED , $ website ) && ! empty ( $ storeIds ) ) { $ this -> apiUsername = $ this -> helper -> getApiUsername ( $ website ) ; $ this -> apiPassword = $ this -> helper -> getApiPassword ( $ website ) ; $ limit = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT , $ website ) ; if ( ! isset ( $ this -> accounts [ $ this -> apiUsername ] ) ) { $ account = $ this -> accountFactory -> create ( ) ; $ account -> setApiUsername ( $ this -> apiUsername ) ; $ account -> setApiPassword ( $ this -> apiPassword ) ; $ this -> accounts [ $ this -> apiUsername ] = $ account ; } $ pendingOrders = $ this -> getPendingConnectorOrders ( $ website , $ limit ) ; if ( ! empty ( $ pendingOrders ) ) { $ this -> accounts [ $ this -> apiUsername ] -> setOrders ( $ pendingOrders ) ; } $ this -> accounts [ $ this -> apiUsername ] -> setWebsites ( $ website -> getId ( ) ) ; $ modifiedOrders = $ this -> getModifiedOrders ( $ website , $ limit ) ; if ( ! empty ( $ modifiedOrders ) ) { $ this -> accounts [ $ this -> apiUsername ] -> setOrdersForSingleSync ( $ modifiedOrders ) ; } } } }
Search the configuration data per website .
39,074
public function filterBySubscribedStatus ( $ collection , $ emailColumn = 'customer_email' ) { $ originalCollection = clone $ collection ; $ emails = $ originalCollection -> getColumnValues ( $ emailColumn ) ; if ( ! empty ( $ emails ) ) { $ subscriberCollectionFactory = $ this -> subscriberCollectionFactory -> create ( ) ; $ onlySubscribedEmails = $ subscriberCollectionFactory -> addFieldToFilter ( 'subscriber_email' , [ 'in' => $ emails ] ) -> addFieldToFilter ( 'subscriber_status' , \ Magento \ Newsletter \ Model \ Subscriber :: STATUS_SUBSCRIBED ) -> getColumnValues ( 'subscriber_email' ) ; $ collection -> addFieldToFilter ( $ emailColumn , [ 'in' => $ onlySubscribedEmails ] ) ; } return $ collection ; }
Add filter to collection for subscribers with subscribed status .
39,075
public function getContactDatafields ( ) { $ contactDataFields = $ this -> contactDatafields ; $ extraDataFields = $ this -> getExtraDataFields ( ) ; if ( ! empty ( $ extraDataFields ) ) { $ contactDataFields = array_merge ( $ extraDataFields , $ contactDataFields ) ; } return $ contactDataFields ; }
Get contact datafields .
39,076
public function setDatafield ( $ name , $ value , $ type = 'string' , $ visibility = 'private' ) { $ this -> datafields [ ] = [ 'name' => $ name , 'value' => $ value , 'type' => $ type , 'visibility' => $ visibility , ] ; return $ this -> datafields ; }
Set a single datafield .
39,077
private function _getApiClient ( ) { if ( empty ( $ this -> client ) ) { $ website = $ this -> getCustomer ( ) -> getStore ( ) -> getWebsite ( ) ; $ client = $ this -> helper -> getWebsiteApiClient ( $ website ) ; $ this -> client = $ client ; } return $ this -> client ; }
Get api client .
39,078
public function getAdditionalBooksToShow ( ) { $ additionalBooksToShow = [ ] ; $ processedAddressBooks = [ ] ; $ additionalFromConfig = $ this -> helper -> getAddressBookIdsToShow ( $ this -> getCustomer ( ) -> getStore ( ) -> getWebsite ( ) ) ; $ contactFromTable = $ this -> getContactFromTable ( ) ; if ( ! empty ( $ additionalFromConfig ) && $ contactFromTable -> getContactId ( ) ) { $ contact = $ this -> getConnectorContact ( ) ; if ( isset ( $ contact -> id ) && $ contact -> status !== 'PendingOptIn' ) { $ addressBooks = $ this -> _getApiClient ( ) -> getContactAddressBooks ( $ contact -> id ) ; if ( is_array ( $ addressBooks ) ) { foreach ( $ addressBooks as $ addressBook ) { $ processedAddressBooks [ $ addressBook -> id ] = $ addressBook -> name ; } } } } return $ this -> getProcessedAdditionalBooks ( $ additionalFromConfig , $ processedAddressBooks , $ additionalBooksToShow ) ; }
Getter for additional books . Fully processed .
39,079
public function getDataFieldsToShow ( ) { $ datafieldsToShow = [ ] ; $ website = $ this -> getCustomer ( ) -> getStore ( ) -> getWebsite ( ) ; $ dataFieldsFromConfig = $ this -> _getWebsiteConfigFromHelper ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_FIELDS , $ website ) ; if ( empty ( $ dataFieldsFromConfig ) ) { return $ datafieldsToShow ; } $ processedContactDataFields = [ ] ; $ processedConnectorDataFields = [ ] ; $ contactFromTable = $ this -> getContactFromTable ( ) ; $ dataFieldsFromConfig = explode ( ',' , $ dataFieldsFromConfig ) ; if ( $ contactFromTable -> getContactId ( ) ) { $ contact = $ this -> getConnectorContact ( ) ; if ( isset ( $ contact -> id ) ) { $ contactDataFields = $ contact -> dataFields ; foreach ( $ contactDataFields as $ contactDataField ) { $ processedContactDataFields [ $ contactDataField -> key ] = $ contactDataField -> value ; } } } return $ this -> getProcessedDataFieldsToShow ( $ processedConnectorDataFields , $ dataFieldsFromConfig , $ processedContactDataFields , $ datafieldsToShow ) ; }
Getter for datafields to show . Fully processed .
39,080
public function canShowAnything ( ) { if ( ! $ this -> isCustomerSubscriber ( ) || ! $ this -> helper -> isEnabled ( $ this -> getCustomer ( ) -> getWebsiteId ( ) ) ) { return false ; } $ showPreferences = $ this -> getCanShowPreferences ( ) ; $ books = $ this -> getAdditionalBooksToShow ( ) ; $ fields = $ this -> getDataFieldsToShow ( ) ; if ( $ books || $ fields || $ showPreferences ) { if ( ! empty ( $ books ) || ! empty ( $ fields ) || $ showPreferences ) { return true ; } } return false ; }
Find out if anything is true .
39,081
public function getConnectorContact ( ) { if ( ! isset ( $ this -> contactFromAccount ) ) { $ contact = $ this -> _getApiClient ( ) -> getContactByEmail ( $ this -> getCustomer ( ) -> getEmail ( ) ) ; if ( isset ( $ contact -> id ) ) { $ this -> contactFromAccount = $ contact ; $ this -> customerSession -> setConnectorContactId ( $ contact -> id ) ; } } return $ this -> contactFromAccount ; }
Get connector contact .
39,082
protected function deleteFromAccount ( $ key ) { $ apiEnabled = $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_API_ENABLED ) ; $ catalogEnabled = $ this -> helper -> isCatalogSyncEnabled ( ) ; if ( $ apiEnabled && $ catalogEnabled ) { $ scope = $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_CATALOG_VALUES ) ; if ( $ scope == 1 ) { $ this -> importerFactory -> create ( ) -> registerQueue ( 'Catalog_Default' , [ $ key ] , \ Dotdigitalgroup \ Email \ Model \ Importer :: MODE_SINGLE_DELETE , \ Magento \ Store \ Model \ Store :: DEFAULT_STORE_ID ) ; } if ( $ scope == 2 ) { $ stores = $ this -> storeManager -> getStores ( ) ; foreach ( $ stores as $ store ) { $ websiteCode = $ store -> getWebsite ( ) -> getCode ( ) ; $ storeCode = $ store -> getCode ( ) ; $ this -> importerFactory -> create ( ) -> registerQueue ( 'Catalog_' . $ websiteCode . '_' . $ storeCode , [ $ key ] , \ Dotdigitalgroup \ Email \ Model \ Importer :: MODE_SINGLE_DELETE , $ store -> getWebsite ( ) -> getId ( ) ) ; } } } }
Delete piece of transactional data by key .
39,083
public function execute ( \ Magento \ Framework \ Event \ Observer $ observer ) { $ subscriber = $ observer -> getEvent ( ) -> getSubscriber ( ) ; $ this -> isSubscriberNew = $ subscriber -> isObjectNew ( ) ; $ email = $ subscriber -> getEmail ( ) ; $ storeId = $ subscriber -> getStoreId ( ) ; $ subscriberStatus = $ subscriber -> getSubscriberStatus ( ) ; $ websiteId = $ this -> storeManager -> getStore ( $ subscriber -> getStoreId ( ) ) -> getWebsiteId ( ) ; if ( ! $ this -> helper -> isEnabled ( $ websiteId ) ) { return $ this ; } try { $ contactEmail = $ this -> contactFactory -> create ( ) -> loadByCustomerEmail ( $ email , $ websiteId ) ; $ contactEmail -> setStoreId ( $ storeId ) -> setSubscriberStatus ( $ subscriberStatus ) ; if ( $ subscriberStatus == \ Magento \ Newsletter \ Model \ Subscriber :: STATUS_SUBSCRIBED ) { $ contactEmail -> setSubscriberImported ( null ) -> setIsSubscriber ( '1' ) ; if ( $ contactEmail -> getSuppressed ( ) ) { $ this -> importerFactory -> registerQueue ( \ Dotdigitalgroup \ Email \ Model \ Importer :: IMPORT_TYPE_SUBSCRIBER_RESUBSCRIBED , [ 'email' => $ email ] , \ Dotdigitalgroup \ Email \ Model \ Importer :: MODE_SUBSCRIBER_RESUBSCRIBED , $ websiteId ) ; $ contactEmail -> setSubscriberImported ( 1 ) -> setSuppressed ( null ) ; } $ this -> contactResource -> save ( $ contactEmail ) ; } else { if ( $ contactEmail -> getSuppressed ( ) ) { return $ this ; } $ contactEmail -> setSubscriberImported ( 1 ) -> setIsSubscriber ( null ) ; $ this -> contactResource -> save ( $ contactEmail ) ; if ( $ subscriberStatus == \ Magento \ Newsletter \ Model \ Subscriber :: STATUS_UNCONFIRMED || $ subscriberStatus == \ Magento \ Newsletter \ Model \ Subscriber :: STATUS_NOT_ACTIVE ) { return $ this ; } $ this -> importerFactory -> registerQueue ( \ Dotdigitalgroup \ Email \ Model \ Importer :: IMPORT_TYPE_SUBSCRIBER_UPDATE , [ 'email' => $ email , 'id' => $ contactEmail -> getId ( ) ] , \ Dotdigitalgroup \ Email \ Model \ Importer :: MODE_SUBSCRIBER_UPDATE , $ websiteId ) ; } $ emailReg = $ this -> registry -> registry ( $ email . '_subscriber_save' ) ; if ( $ emailReg ) { return $ this ; } $ this -> registry -> unregister ( $ email . '_subscriber_save' ) ; $ this -> registry -> register ( $ email . '_subscriber_save' , $ email ) ; $ this -> addSubscriberToAutomation ( $ email , $ subscriber , $ websiteId ) ; } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } return $ this ; }
Change contact subscription status .
39,084
private function addSubscriberToAutomation ( $ email , $ subscriber , $ websiteId ) { $ storeId = $ subscriber -> getStoreId ( ) ; $ store = $ this -> storeManager -> getStore ( $ storeId ) ; $ programId = $ this -> helper -> getWebsiteConfig ( 'connector_automation/visitor_automation/subscriber_automation' , $ websiteId ) ; if ( ! $ programId || ! $ this -> isSubscriberNew ) { return ; } $ automation = $ this -> automationFactory -> create ( ) -> setEmail ( $ email ) -> setAutomationType ( \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: AUTOMATION_TYPE_NEW_SUBSCRIBER ) -> setEnrolmentStatus ( \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: AUTOMATION_STATUS_PENDING ) -> setTypeId ( $ subscriber -> getId ( ) ) -> setWebsiteId ( $ websiteId ) -> setStoreName ( $ store -> getName ( ) ) -> setProgramId ( $ programId ) ; $ this -> automationResource -> save ( $ automation ) ; }
Register subscriber to automation .
39,085
public function getProductsToExportByStore ( $ store , $ limit ) { $ connectorCollection = $ this ; $ connectorCollection -> addFieldToFilter ( [ 'imported' , 'modified' ] , [ [ 'null' => 'true' ] , [ 'eq' => '1' ] ] ) ; $ connectorCollection -> getSelect ( ) -> limit ( $ limit ) ; $ connectorCollection -> setOrder ( 'product_id' , 'asc' ) ; if ( $ connectorCollection -> getSize ( ) ) { $ productIds = $ connectorCollection -> getColumnValues ( 'product_id' ) ; $ productCollection = $ this -> productCollection -> create ( ) -> addAttributeToSelect ( '*' ) -> addAttributeToFilter ( 'entity_id' , [ 'in' => $ productIds ] ) -> addUrlRewrite ( ) ; if ( ! empty ( $ store ) ) { $ productCollection -> addStoreFilter ( $ store ) ; } if ( $ visibility = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_CATALOG_VISIBILITY ) ) { $ visibility = explode ( ',' , $ visibility ) ; $ visibility = array_filter ( $ visibility ) ; $ productCollection -> addAttributeToFilter ( 'visibility' , [ 'in' => $ visibility ] ) ; } if ( $ type = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_CATALOG_TYPE ) ) { $ type = explode ( ',' , $ type ) ; $ productCollection -> addAttributeToFilter ( 'type_id' , [ 'in' => $ type ] ) ; } $ productCollection -> addWebsiteNamesToResult ( ) -> addCategoryIds ( ) -> addOptionsToResult ( ) ; $ productCollection -> clear ( ) ; return $ productCollection ; } return [ ] ; }
Get product collection to export .
39,086
public function getEscapedFontFamilyForCoupon ( ) { $ rawFont = $ this -> helper -> getWebsiteConfig ( Config :: XML_PATH_CONNECTOR_DYNAMIC_COUPON_FONT ) ; return $ this -> getSanitisedFont ( $ rawFont ) ; }
Coupon Font from config .
39,087
public function getDynamicStyles ( ) { $ rawDocFont = $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_DOC_FONT ) ; return [ 'nameStyle' => explode ( ',' , $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_NAME_STYLE ) ) , 'priceStyle' => explode ( ',' , $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_PRICE_STYLE ) ) , 'linkStyle' => explode ( ',' , $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_LINK_STYLE ) ) , 'otherStyle' => explode ( ',' , $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_OTHER_STYLE ) ) , 'nameColor' => $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_NAME_COLOR ) , 'fontSize' => $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_NAME_FONT_SIZE ) , 'priceColor' => $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_PRICE_COLOR ) , 'priceFontSize' => $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_PRICE_FONT_SIZE ) , 'urlColor' => $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_LINK_COLOR ) , 'urlFontSize' => $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_LINK_FONT_SIZE ) , 'otherColor' => $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_OTHER_COLOR ) , 'otherFontSize' => $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_OTHER_FONT_SIZE ) , 'docFont' => $ this -> getSanitisedFont ( $ rawDocFont ) , 'docBackgroundColor' => $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_DOC_BG_COLOR ) , 'dynamicStyling' => $ this -> helper -> getConfigValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_STYLING ) , ] ; }
Dynamic styles from config .
39,088
private function processFailedRequest ( ) { $ url = $ this -> _url -> getCurrentUrl ( ) ; $ storeId = $ this -> storeManager -> getStore ( ) -> getId ( ) ; $ failedAuth = $ this -> failedAuthFactory -> create ( ) ; $ this -> failedAuthResource -> load ( $ failedAuth , $ storeId , 'store_id' ) ; $ numOfFails = $ failedAuth -> getFailuresNum ( ) ; $ lastAttemptDate = $ failedAuth -> getLastAttemptDate ( ) ; if ( ! $ failedAuth -> getId ( ) ) { $ failedAuth -> setFirstAttemptDate ( time ( ) ) ; } if ( $ numOfFails == \ Dotdigitalgroup \ Email \ Model \ FailedAuth :: NUMBER_MAX_FAILS_LIMIT ) { if ( $ failedAuth -> isLocked ( ) ) { $ this -> helper -> log ( sprintf ( 'Resource locked time : %s ,store : %s' , $ lastAttemptDate , $ storeId ) ) ; return ; } else { $ numOfFails = 0 ; $ failedAuth -> setFirstAttemptDate ( time ( ) ) ; } } try { $ failedAuth -> setFailuresNum ( ++ $ numOfFails ) -> setStoreId ( $ storeId ) -> setUrl ( $ url ) -> setLastAttemptDate ( time ( ) ) ; $ this -> failedAuthResource -> save ( $ failedAuth ) ; } catch ( \ Exception $ e ) { $ this -> helper -> log ( $ e ) ; } }
Register the failed attempt and set a lock with a 5min window if more then 5 request failed .
39,089
public function execute ( ) { try { $ adminUser = $ this -> _auth -> getUser ( ) ; if ( $ adminUser -> getRefreshToken ( ) ) { $ adminUser -> setRefreshToken ( '' ) -> save ( ) ; } $ this -> messageManager -> addSuccessMessage ( 'Successfully disconnected' ) ; } catch ( \ Exception $ e ) { $ this -> messageManager -> addErrorMessage ( $ e -> getMessage ( ) ) ; } $ this -> _redirect ( 'adminhtml/system_config/edit' , [ 'section' => 'connector_developer_settings' ] ) ; }
Disconnect and remote the refresh token .
39,090
public function _construct ( ) { $ this -> _init ( \ Magento \ Cron \ Model \ Schedule :: class , \ Magento \ Cron \ Model \ ResourceModel \ Schedule :: class ) ; }
Initialize resource collection
39,091
public function getAllSentOrders ( $ storeIds , $ limit ) { $ collection = $ this -> addFieldToFilter ( 'email_imported' , 1 ) -> addFieldToFilter ( 'store_id' , [ 'in' => $ storeIds ] ) ; $ collection -> getSelect ( ) -> limit ( $ limit ) ; return $ collection -> load ( ) ; }
Get all sent orders .
39,092
public function getSalesCollectionForReviews ( $ orderStatusFromConfig , $ created , $ website , $ campaignOrderIds = [ ] ) { $ storeIds = $ website -> getStoreIds ( ) ; $ collection = $ this -> orderCollection -> create ( ) -> addFieldToFilter ( 'main_table.status' , $ orderStatusFromConfig ) -> addFieldToFilter ( 'main_table.created_at' , $ created ) -> addFieldToFilter ( 'main_table.store_id' , [ 'in' => $ storeIds ] ) ; if ( ! empty ( $ campaignOrderIds ) ) { $ collection -> addFieldToFilter ( 'main_table.increment_id' , [ 'nin' => $ campaignOrderIds ] ) ; } if ( $ this -> helper -> isOnlySubscribersForReview ( $ website -> getWebsiteId ( ) ) ) { $ collection = $ this -> subscriberFilterer -> filterBySubscribedStatus ( $ collection ) ; } return $ collection ; }
Get sales collection for review .
39,093
public function getCustomerLastQuoteId ( \ Magento \ Customer \ Model \ Customer $ customer , $ storeIds ) { $ collection = $ this -> quoteCollection -> create ( ) -> addFieldToFilter ( 'customer_id' , $ customer -> getId ( ) ) -> addFieldToFilter ( 'store_id' , [ 'in' => $ storeIds ] ) -> setPageSize ( 1 ) -> setOrder ( 'entity_id' ) ; if ( $ collection -> getSize ( ) ) { return $ collection -> getFirstItem ( ) ; } return false ; }
Get customer last quote id .
39,094
public function getStoreQuotes ( $ storeId , $ updated , $ guest = false ) { $ salesCollection = $ this -> getStoreQuotesForGuestsAndCustomers ( $ storeId , $ updated ) ; if ( $ guest ) { $ salesCollection -> addFieldToFilter ( 'main_table.customer_id' , [ 'null' => true ] ) ; } else { $ salesCollection -> addFieldToFilter ( 'main_table.customer_id' , [ 'notnull' => true ] ) ; } return $ salesCollection ; }
Get store quotes for either guests or customers excluding inactive and empty .
39,095
public function getStoreQuotesForGuestsAndCustomers ( $ storeId , $ updated ) { $ salesCollection = $ this -> quoteCollection -> create ( ) ; $ salesCollection -> addFieldToFilter ( 'is_active' , 1 ) -> addFieldToFilter ( 'items_count' , [ 'gt' => 0 ] ) -> addFieldToFilter ( 'customer_email' , [ 'neq' => '' ] ) -> addFieldToFilter ( 'main_table.store_id' , $ storeId ) -> addFieldToFilter ( 'main_table.updated_at' , $ updated ) ; if ( $ this -> helper -> isOnlySubscribersForAC ( $ storeId ) ) { $ salesCollection = $ this -> subscriberFilterer -> filterBySubscribedStatus ( $ salesCollection ) ; } return $ salesCollection ; }
Get store quotes for both guests and customers excluding inactive and empty .
39,096
public function checkInSales ( $ emails ) { $ collection = $ this -> orderCollection -> create ( ) -> addFieldToFilter ( 'customer_email' , [ 'in' => $ emails ] ) ; return $ collection -> getColumnValues ( 'customer_email' ) ; }
Check emails exist in sales order table .
39,097
public function isEnabled ( $ storeId ) { return $ this -> scopeConfig -> isSetFlag ( self :: XML_PATH_DDG_TRANSACTIONAL_ENABLED , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE , $ storeId ) ; }
Is transactional email enabled .
39,098
public function getSmtpHost ( $ storeId ) { return $ this -> scopeConfig -> getValue ( self :: XML_PATH_DDG_TRANSACTIONAL_HOST , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE , $ storeId ) ; }
Get transactional email host .
39,099
private function getSmtpUsername ( $ storeId = null ) { return $ this -> scopeConfig -> getValue ( self :: XML_PATH_DDG_TRANSACTIONAL_USERNAME , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE , $ storeId ) ; }
Get smtp username .