idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
38,900 | public function getAbandonedCartLimit ( ) { $ cartLimit = $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ABANDONED_CART_LIMIT ) ; return $ cartLimit ; } | Get the abandoned cart limit . |
38,901 | public function getWebsiteSalesDataFields ( $ website ) { $ subscriberDataFileds = [ 'website_name' => '' , 'store_name' => '' , 'number_of_orders' => '' , 'average_order_value' => '' , 'total_spend' => '' , 'last_order_date' => '' , 'last_increment_id' => '' , 'most_pur_category' => '' , 'most_pur_brand' => '' , 'most_freq_pur_day' => '' , 'most_freq_pur_mon' => '' , 'first_category_pur' => '' , 'last_category_pur' => '' , 'first_brand_pur' => '' , 'last_brand_pur' => '' ] ; $ store = $ website -> getDefaultStore ( ) ; $ mappedData = $ this -> scopeConfig -> getValue ( 'connector_data_mapping/customer_data' , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE , $ store -> getId ( ) ) ; $ mappedData = array_intersect_key ( $ mappedData , $ subscriberDataFileds ) ; foreach ( $ mappedData as $ key => $ value ) { if ( ! $ value ) { unset ( $ mappedData [ $ key ] ) ; } } return $ mappedData ; } | Get website datafields for subscriber |
38,902 | public function validateDateRange ( $ dateFrom , $ dateTo ) { if ( ! $ this -> validateDate ( $ dateFrom ) || ! $ this -> validateDate ( $ dateTo ) ) { return 'From or To date is not a valid date.' ; } if ( strtotime ( $ dateFrom ) > strtotime ( $ dateTo ) ) { return 'To Date cannot be earlier then From Date.' ; } return false ; } | Validate date range |
38,903 | public function getDateDifference ( $ created ) { $ now = $ this -> datetime -> gmtDate ( ) ; return strtotime ( $ now ) - strtotime ( $ created ) ; } | Get difference between dates |
38,904 | public function getBrandAttributeByWebsiteId ( $ websiteId ) { return $ this -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_BRAND_ATTRIBUTE , $ websiteId ) ; } | Get brand attribute selected from config by website id |
38,905 | public function createDatafield ( $ website , $ datafield , $ type , $ visibility = 'Private' , $ default = 'String' ) { $ client = $ this -> getWebsiteApiClient ( $ website ) ; switch ( $ type ) { case 'Numeric' : $ default = ( int ) $ default ; break ; case 'Date' : $ default = $ this -> datetime -> date ( \ Zend_Date :: ISO_8601 , $ default ) ; break ; case 'Boolean' : $ default = ( bool ) $ default ; break ; default : $ default = ( string ) $ default ; } $ response = $ client -> postDataFields ( $ datafield , $ type , $ visibility , $ default ) ; return $ response ; } | Create data fields in account by type . |
38,906 | public function getCanShowAdditionalSubscriptions ( $ website ) { return $ this -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_CAN_CHANGE_BOOKS , $ website ) ; } | Can show additional books? |
38,907 | public function getCanShowDataFields ( $ website ) { return $ this -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_CAN_SHOW_FIELDS , $ website ) ; } | Can show data fields? |
38,908 | public function getAddressBookIdsToShow ( $ website ) { $ bookIds = $ this -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_BOOKS , $ website ) ; if ( empty ( $ bookIds ) ) { return [ ] ; } $ additionalFromConfig = explode ( ',' , $ bookIds ) ; if ( $ additionalFromConfig [ 0 ] == '0' ) { unset ( $ additionalFromConfig [ 0 ] ) ; } return $ additionalFromConfig ; } | Address book ids to display |
38,909 | public function getLoadedProductCollection ( ) { $ params = $ this -> getRequest ( ) -> getParams ( ) ; if ( ! isset ( $ params [ 'order_id' ] ) || ! isset ( $ params [ 'code' ] ) || ! $ this -> helper -> isCodeValid ( $ params [ 'code' ] ) ) { $ this -> helper -> log ( 'Product recommendation for this order not found or invalid code' ) ; return [ ] ; } $ orderId = ( int ) $ this -> getRequest ( ) -> getParam ( 'order_id' ) ; $ mode = $ this -> getRequest ( ) -> getActionName ( ) ; $ orderModel = $ this -> orderFactory -> create ( ) ; $ this -> orderResource -> load ( $ orderModel , $ orderId ) ; $ limit = $ this -> recommendedHelper -> getDisplayLimitByMode ( $ mode ) ; $ orderItems = $ orderModel -> getAllItems ( ) ; $ numItems = count ( $ orderItems ) ; if ( $ numItems == 0 || ! $ limit ) { return [ ] ; } elseif ( $ numItems > $ limit ) { $ maxPerChild = 1 ; } else { $ maxPerChild = number_format ( $ limit / $ numItems ) ; } $ this -> helper -> log ( 'DYNAMIC PRODUCTS : limit ' . $ limit . ' products : ' . $ numItems . ', max per child : ' . $ maxPerChild ) ; $ productsToDisplayCounter = 0 ; $ productsToDisplay = $ this -> recommendedHelper -> getProductsToDisplay ( $ orderItems , $ mode , $ productsToDisplayCounter , $ limit , $ maxPerChild ) ; if ( $ productsToDisplayCounter < $ limit ) { $ productsToDisplay = $ this -> recommendedHelper -> fillProductsToDisplay ( $ productsToDisplay , $ productsToDisplayCounter , $ limit ) ; } $ this -> helper -> log ( 'loaded product to display ' . count ( $ productsToDisplay ) ) ; return $ productsToDisplay ; } | Get the products to display for recommendation . |
38,910 | private function getWebsiteStoreId ( $ customer , $ defaultStoreId = null ) { if ( $ customer -> getWebsiteId ( ) != 0 && empty ( $ defaultStoreId ) ) { $ storeIds = $ this -> storeManager -> getWebsite ( $ customer -> getWebsiteId ( ) ) -> getStoreIds ( ) ; $ defaultStoreId = reset ( $ storeIds ) ; } return $ defaultStoreId ; } | Get either first store ID from a set website or the provided as default |
38,911 | public function getLoadedProductCollection ( ) { $ params = $ this -> getRequest ( ) -> getParams ( ) ; if ( ! isset ( $ params [ 'code' ] ) || ! $ this -> helper -> isCodeValid ( $ params [ 'code' ] ) ) { $ this -> helper -> log ( 'Most viewed no valid code is set' ) ; return [ ] ; } $ productsToDisplay = [ ] ; $ mode = $ this -> getRequest ( ) -> getActionName ( ) ; $ limit = $ this -> recommnededHelper -> getDisplayLimitByMode ( $ mode ) ; $ from = $ this -> recommnededHelper -> getTimeFromConfig ( $ mode ) ; $ to = $ this -> _localeDate -> date ( ) -> format ( \ Zend_Date :: ISO_8601 ) ; $ catId = $ this -> getRequest ( ) -> getParam ( 'category_id' ) ; $ catName = $ this -> getRequest ( ) -> getParam ( 'category_name' ) ; $ reportProductCollection = $ this -> catalog -> getMostViewedProductCollection ( $ from , $ to , $ limit , $ catId , $ catName ) ; $ productIds = $ reportProductCollection -> getColumnValues ( 'entity_id' ) ; $ productCollection = $ this -> catalog -> getProductCollectionFromIds ( $ productIds ) ; foreach ( $ productCollection as $ _product ) { if ( $ _product -> isSalable ( ) ) { $ productsToDisplay [ ] = $ _product ; } } return $ productsToDisplay ; } | Get product collection . |
38,912 | public function saveApiCreds ( $ apiUser , $ apiPass ) { $ this -> helper -> saveConfigData ( Config :: XML_PATH_CONNECTOR_API_ENABLED , '1' , 'default' , 0 ) ; $ this -> helper -> saveConfigData ( Config :: XML_PATH_CONNECTOR_API_USERNAME , $ apiUser , 'default' , 0 ) ; $ this -> helper -> saveConfigData ( Config :: XML_PATH_CONNECTOR_API_PASSWORD , $ this -> helper -> encryptor -> encrypt ( $ apiPass ) , 'default' , 0 ) ; $ this -> config -> reinit ( ) ; return true ; } | Save api credentioals . |
38,913 | public function setupDataFields ( $ username , $ password ) { $ error = false ; $ apiModel = false ; if ( $ this -> helper -> isEnabled ( ) ) { $ apiModel = $ this -> helper -> getWebsiteApiClient ( 0 , $ username , $ password ) ; } if ( ! $ apiModel ) { $ error = true ; $ this -> helper -> log ( 'setupDataFields client is not enabled' ) ; } else { $ accountInfo = $ apiModel -> getAccountInfo ( ) ; if ( isset ( $ accountInfo -> message ) ) { $ this -> helper -> log ( 'setupDataFields ' . $ accountInfo -> message ) ; $ error = true ; } else { $ dataFields = $ this -> dataField -> getContactDatafields ( ) ; foreach ( $ dataFields as $ key => $ dataField ) { $ apiModel -> postDataFields ( $ dataField ) ; $ this -> helper -> saveConfigData ( 'connector_data_mapping/customer_data/' . $ key , strtoupper ( $ dataField [ 'name' ] ) , 'default' , 0 ) ; $ this -> helper -> log ( 'setupDataFields successfully connected : ' . $ dataField [ 'name' ] ) ; } } } return $ error == true ? false : true ; } | Setup data fields . |
38,914 | public function createAddressBooks ( $ username , $ password ) { $ addressBooks = [ [ 'name' => 'Magento_Customers' , 'visibility' => 'Private' ] , [ 'name' => 'Magento_Subscribers' , 'visibility' => 'Private' ] , [ 'name' => 'Magento_Guests' , 'visibility' => 'Private' ] , ] ; $ client = false ; if ( $ this -> helper -> isEnabled ( ) ) { $ client = $ this -> helper -> getWebsiteApiClient ( 0 , $ username , $ password ) ; } if ( ! $ client ) { $ error = true ; $ this -> helper -> log ( 'createAddressBooks client is not enabled' ) ; } else { $ error = $ this -> validateAccountAndCreateAddressbooks ( $ client , $ addressBooks ) ; } return $ error == true ? false : true ; } | Create certain address books . |
38,915 | public function mapAddressBook ( $ name , $ id ) { $ addressBookMap = [ 'Magento_Customers' => Config :: XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID , 'Magento_Subscribers' => Config :: XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID , 'Magento_Guests' => Config :: XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID , ] ; $ this -> helper -> saveConfigData ( $ addressBookMap [ $ name ] , $ id , 'default' , 0 ) ; $ this -> helper -> log ( 'successfully connected address book : ' . $ name ) ; } | Map the successfully created address book |
38,916 | public function enableSyncForTrial ( ) { $ this -> helper -> saveConfigData ( Config :: XML_PATH_CONNECTOR_SYNC_CUSTOMER_ENABLED , '1' , 'default' , 0 ) ; $ this -> helper -> saveConfigData ( Config :: XML_PATH_CONNECTOR_SYNC_GUEST_ENABLED , '1' , 'default' , 0 ) ; $ this -> helper -> saveConfigData ( Config :: XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED , '1' , 'default' , 0 ) ; $ this -> helper -> saveConfigData ( Config :: XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED , '1' , 'default' , 0 ) ; $ this -> config -> reinit ( ) ; return true ; } | Enable certain syncs for newly created trial account . |
38,917 | private function processGeneralSubscription ( ) { $ customerId = $ this -> customerSession -> getCustomerId ( ) ; if ( $ customerId === null ) { $ this -> messageManager -> addError ( __ ( 'Something went wrong while saving your subscription.' ) ) ; } else { try { $ customer = $ this -> customerRepository -> getById ( $ customerId ) ; $ storeId = $ this -> helper -> storeManager -> getStore ( ) -> getId ( ) ; $ customer -> setStoreId ( $ storeId ) ; $ isSubscribedState = $ customer -> getExtensionAttributes ( ) -> getIsSubscribed ( ) ; $ isSubscribedParam = ( boolean ) $ this -> getRequest ( ) -> getParam ( 'is_subscribed' , false ) ; if ( $ isSubscribedParam !== $ isSubscribedState ) { $ this -> customerRepository -> save ( $ customer ) ; if ( $ isSubscribedParam ) { $ subscribeModel = $ this -> subscriberFactory -> create ( ) -> subscribeCustomerById ( $ customerId ) ; $ subscribeStatus = $ subscribeModel -> getStatus ( ) ; if ( $ subscribeStatus == Subscriber :: STATUS_SUBSCRIBED ) { $ this -> messageManager -> addSuccess ( __ ( 'We have saved your subscription.' ) ) ; } else { $ this -> messageManager -> addSuccess ( __ ( 'A confirmation request has been sent.' ) ) ; } } else { $ this -> subscriberFactory -> create ( ) -> unsubscribeCustomerById ( $ customerId ) ; $ this -> messageManager -> addSuccess ( __ ( 'We have removed your newsletter subscription.' ) ) ; } } else { $ this -> messageManager -> addSuccess ( __ ( 'We have updated your subscription.' ) ) ; } } catch ( \ Exception $ e ) { $ this -> messageManager -> addError ( __ ( 'Something went wrong while saving your subscription.' ) ) ; } } } | Process general subscription |
38,918 | private function moveFile ( $ sourceFolder , $ destFolder , $ filename ) { $ sourceFilepath = $ sourceFolder . DIRECTORY_SEPARATOR . $ filename ; $ destFilepath = $ destFolder . DIRECTORY_SEPARATOR . $ filename ; rename ( $ sourceFilepath , $ destFilepath ) ; } | Moves the output file from one folder to the next . |
38,919 | public function outputForceQuotesCSV ( $ filepath , $ csv ) { $ fqCsv = $ this -> arrayToCsv ( $ csv , chr ( 9 ) , '"' , true , false ) ; $ fp = fopen ( $ filepath , 'a' ) ; if ( fwrite ( $ fp , $ fqCsv ) == 0 ) { throw new \ Exception ( 'Problem writing CSV file' ) ; } fclose ( $ fp ) ; } | Output an array to the output file FORCING Quotes around all fields . |
38,920 | private function arrayToCsv ( array & $ fields , $ delimiter , $ enclosure , $ encloseAll = false , $ nullToMysqlNull = false ) { $ delimiterEsc = preg_quote ( $ delimiter , '/' ) ; $ enclosureEsc = preg_quote ( $ enclosure , '/' ) ; $ output = [ ] ; foreach ( $ fields as $ field ) { if ( $ field === null && $ nullToMysqlNull ) { $ output [ ] = 'NULL' ; continue ; } if ( $ encloseAll || preg_match ( "/(?:$delimiterEsc|$enclosureEsc|\s)/" , $ field ) ) { $ output [ ] = $ enclosure . str_replace ( $ enclosure , $ enclosure . $ enclosure , $ field ) . $ enclosure ; } else { $ output [ ] = $ field ; } } return implode ( $ delimiter , $ output ) . "\n" ; } | Convert array into the csv . |
38,921 | public function deleteDir ( $ path ) { if ( strpos ( $ path , $ this -> directoryList -> getPath ( 'var' ) ) === false ) { return sprintf ( "Failed to delete directory - '%s'" , $ path ) ; } $ classFunc = [ __CLASS__ , __FUNCTION__ ] ; return is_file ( $ path ) ? @ unlink ( $ path ) : array_map ( $ classFunc , glob ( $ path . '/*' ) ) == @ rmdir ( $ path ) ; } | Delete file or directory . |
38,922 | public function getLogFileContent ( $ filename = 'connector' ) { switch ( $ filename ) { case "connector" : $ filename = 'connector.log' ; break ; case "system" : $ filename = 'system.log' ; break ; case "exception" : $ filename = 'exception.log' ; break ; case "debug" : $ filename = 'debug.log' ; break ; default : return "Log file is not valid. Log file name is " . $ filename ; } $ pathLogfile = $ this -> directoryList -> getPath ( 'log' ) . DIRECTORY_SEPARATOR . $ filename ; $ lengthBefore = 500000 ; try { $ contents = '' ; $ handle = fopen ( $ pathLogfile , 'r' ) ; fseek ( $ handle , - $ lengthBefore , SEEK_END ) ; if ( ! $ handle ) { return "Log file is not readable or does not exist at this moment. File path is " . $ pathLogfile ; } if ( filesize ( $ pathLogfile ) > 0 ) { $ contents = fread ( $ handle , filesize ( $ pathLogfile ) ) ; if ( $ contents === false ) { return "Log file is not readable or does not exist at this moment. File path is " . $ pathLogfile ; } fclose ( $ handle ) ; } return $ contents ; } catch ( \ Exception $ e ) { return $ e -> getMessage ( ) . $ pathLogfile ; } } | Get log file content . |
38,923 | public function getFilePathWithFallback ( $ filename ) { $ emailPath = $ this -> getOutputFolder ( ) . DIRECTORY_SEPARATOR . $ filename ; $ archivePath = $ this -> getArchiveFolder ( ) . DIRECTORY_SEPARATOR . $ filename ; return is_file ( $ emailPath ) ? $ emailPath : $ archivePath ; } | Return the full file path with checking in archive as fallback . |
38,924 | public function isFilePathExistWithFallback ( $ filename ) { $ emailPath = $ this -> getOutputFolder ( ) . DIRECTORY_SEPARATOR . $ filename ; $ archivePath = $ this -> getArchiveFolder ( ) . DIRECTORY_SEPARATOR . $ filename ; return is_file ( $ emailPath ) ? true : ( is_file ( $ archivePath ) ? true : false ) ; } | Check if file exist in email or archive folder |
38,925 | public function getInputType ( $ attribute ) { switch ( $ attribute ) { case 'subtotal' : case 'grand_total' : case 'items_qty' : return 'numeric' ; 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 ) ; return $ this -> processAttribute ( $ attribute ) ; } } | Default options . |
38,926 | public function toOptionArray ( ) { $ defaultOptions = $ this -> defaultOptions ( ) ; $ productCondition = $ this -> productFactory ; $ productAttributes = $ productCondition -> loadAttributeOptions ( ) -> getAttributeOption ( ) ; $ pAttributes = [ ] ; foreach ( $ productAttributes as $ code => $ label ) { if ( strpos ( $ code , 'quote_item_' ) === false ) { $ pAttributes [ $ code ] = $ label ; } } $ options = array_merge ( $ defaultOptions , $ pAttributes ) ; return $ options ; } | Attribute options array . |
38,927 | public function massResend ( $ ids ) { try { $ conn = $ this -> getConnection ( ) ; $ num = $ conn -> update ( $ this -> getTable ( Schema :: EMAIL_IMPORTER_TABLE ) , [ 'import_status' => 0 ] , [ 'id IN(?)' => $ ids ] ) ; return $ num ; } catch ( \ Exception $ e ) { return $ e -> getMessage ( ) ; } } | Reset importer items . |
38,928 | public function cleanup ( $ tableName ) { try { $ interval = $ this -> dateIntervalFactory -> create ( [ 'interval_spec' => 'P30D' ] ) ; $ date = $ this -> localeDate -> date ( ) -> sub ( $ interval ) -> format ( 'Y-m-d H:i:s' ) ; $ conn = $ this -> getConnection ( ) ; $ num = $ conn -> delete ( $ this -> getTable ( $ tableName ) , [ 'created_at < ?' => $ date ] ) ; return $ num ; } catch ( \ Exception $ e ) { return $ e -> getMessage ( ) ; } } | Delete completed records older then 30 days from provided table . |
38,929 | public function getExpiredEmailCampaignsByStoreIds ( $ storeIds ) { $ time = new \ DateTime ( 'now' , new \ DateTimezone ( 'UTC' ) ) ; $ interval = $ this -> dateIntervalFactory -> create ( [ 'interval_spec' => sprintf ( 'PT%sH' , 2 ) ] ) ; $ time -> sub ( $ interval ) ; $ campaignCollection = $ this -> addFieldToFilter ( 'campaign_id' , [ 'notnull' => true ] ) -> addFieldToFilter ( 'send_status' , \ Dotdigitalgroup \ Email \ Model \ Campaign :: PROCESSING ) -> addFieldToFilter ( 'store_id' , [ 'in' => $ storeIds ] ) -> addFieldToFilter ( 'send_id' , [ 'notnull' => true ] ) -> addFieldToFilter ( 'updated_at' , [ 'lt' => $ time -> format ( 'Y-m-d H:i:s' ) ] ) ; return $ campaignCollection ; } | Get expired campaigns by store ids |
38,930 | public function getNumberOfCampaignsForContactByInterval ( $ email , $ updated ) { return $ this -> addFieldToFilter ( 'email' , $ email ) -> addFieldToFilter ( 'event_name' , 'Lost Basket' ) -> addFieldToFilter ( 'sent_at' , $ updated ) -> count ( ) ; } | Get number of campaigns for contact by interval . |
38,931 | public function filterByGeneratedByDotmailer ( $ collection , $ column ) { $ field = $ column -> getFilterIndex ( ) ? $ column -> getFilterIndex ( ) : $ column -> getIndex ( ) ; $ value = $ column -> getFilter ( ) -> getValue ( ) ; if ( $ value == 'null' ) { $ collection -> addFieldToFilter ( $ field , [ 'null' => true ] ) ; } else { $ collection -> addFieldToFilter ( $ field , [ 'notnull' => true ] ) ; } } | Callback action for cart price rule coupon grid . |
38,932 | public function getAutomationStatusType ( ) { $ automationOrderStatusCollection = $ this -> addFieldToFilter ( 'enrolment_status' , \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: AUTOMATION_STATUS_PENDING ) ; $ automationOrderStatusCollection -> addFieldToFilter ( 'automation_type' , [ 'like' => '%' . \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: ORDER_STATUS_AUTOMATION . '%' ] ) -> getSelect ( ) -> group ( 'automation_type' ) ; return $ automationOrderStatusCollection -> getColumnValues ( 'automation_type' ) ; } | Get automation status type |
38,933 | public function getCollectionByType ( $ type , $ limit ) { $ collection = $ this -> addFieldToFilter ( 'enrolment_status' , [ 'in' => [ \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: AUTOMATION_STATUS_PENDING , \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: CONTACT_STATUS_CONFIRMED ] ] ) -> addFieldToFilter ( 'automation_type' , $ type ) ; $ collection -> getSelect ( ) -> limit ( $ limit ) ; return $ collection ; } | Get collection by type . |
38,934 | public function getContactsToImportForWebsite ( $ websiteId , $ pageSize = 100 ) { $ collection = $ this -> addFieldToFilter ( 'website_id' , $ websiteId ) -> addFieldToFilter ( 'email_imported' , [ 'null' => true ] ) -> addFieldToFilter ( 'customer_id' , [ 'neq' => '0' ] ) ; $ collection -> getSelect ( ) -> limit ( $ pageSize ) ; return $ collection ; } | Get all customer contacts not imported for a website . |
38,935 | public function getMissingContacts ( $ websiteId , $ pageSize = 100 ) { $ collection = $ this -> addFieldToFilter ( 'contact_id' , [ 'null' => true ] ) -> addFieldToFilter ( 'suppressed' , [ 'null' => true ] ) -> addFieldToFilter ( 'website_id' , $ websiteId ) ; $ collection -> getSelect ( ) -> limit ( $ pageSize ) ; return $ collection -> load ( ) ; } | Get missing contacts . |
38,936 | public function getNumberSubscribers ( $ websiteId = 0 ) { return $ this -> addFieldToFilter ( 'subscriber_status' , \ Dotdigitalgroup \ Email \ Model \ Newsletter \ Subscriber :: STATUS_SUBSCRIBED ) -> addFieldToFilter ( 'website_id' , $ websiteId ) -> getSize ( ) ; } | Get number of subscribers . |
38,937 | public function getSubscriberDataByEmails ( $ emails ) { $ subscriberFactory = $ this -> subscriberFactory -> create ( ) ; $ subscribersData = $ subscriberFactory -> getCollection ( ) -> addFieldToFilter ( 'subscriber_email' , [ 'in' => $ emails ] ) -> addFieldToSelect ( [ 'subscriber_email' , 'store_id' ] ) ; return $ subscribersData -> toArray ( ) ; } | Get subscribers data by emails |
38,938 | public function getContactsToImportByWebsite ( $ websiteId , $ syncLimit , $ onlySubscriber = false ) { $ collection = $ this -> addFieldToSelect ( '*' ) -> addFieldToFilter ( 'customer_id' , [ 'neq' => '0' ] ) -> addFieldToFilter ( 'email_imported' , [ 'null' => true ] ) -> addFieldToFilter ( 'website_id' , $ websiteId ) -> setPageSize ( $ syncLimit ) ; if ( $ onlySubscriber ) { $ collection -> addFieldToFilter ( 'is_subscriber' , 1 ) -> addFieldToFilter ( 'subscriber_status' , \ Magento \ Newsletter \ Model \ Subscriber :: STATUS_SUBSCRIBED ) ; } return $ collection ; } | Get contacts to import by website |
38,939 | public function setContacts ( $ contacts ) { if ( ! empty ( $ this -> contacts ) ) { $ this -> contacts += $ contacts ; } else { $ this -> contacts [ ] = $ contacts ; } } | Set contacts . |
38,940 | public function getFirstCategoryPur ( ) { $ firstOrderId = $ this -> model -> getFirstOrderId ( ) ; $ order = $ this -> orderFactory -> create ( ) ; $ this -> orderResource -> load ( $ order , $ firstOrderId ) ; $ categoryIds = $ this -> getCategoriesFromOrderItems ( $ order -> getAllItems ( ) ) ; return $ this -> getCategoryNames ( $ categoryIds ) ; } | Get first purchased category . |
38,941 | public function getLastCategoryPur ( ) { $ lastOrderId = $ this -> model -> getLastOrderId ( ) ; $ order = $ this -> orderFactory -> create ( ) ; $ this -> orderResource -> load ( $ order , $ lastOrderId ) ; $ categoryIds = $ this -> getCategoriesFromOrderItems ( $ order -> getAllItems ( ) ) ; return $ this -> getCategoryNames ( $ categoryIds ) ; } | Get last purchased category . |
38,942 | public function getMostPurCategory ( ) { $ categories = '' ; $ productId = $ this -> model -> getProductIdForMostSoldProduct ( ) ; if ( $ productId ) { $ product = $ this -> getProduct ( $ productId ) ; if ( $ product -> getId ( ) ) { $ categoryIds = $ product -> getCategoryIds ( ) ; if ( count ( $ categoryIds ) ) { $ categories = $ this -> getCategoryNames ( $ categoryIds ) ; } } } return $ categories ; } | Get most purchased category . |
38,943 | public function getMostViewedProductCollection ( $ from , $ to , $ limit , $ catId , $ catName ) { $ reportProductCollection = $ this -> reportProductCollection -> create ( ) -> addViewsCount ( $ from , $ to ) -> setPageSize ( $ limit ) ; if ( $ catId ) { $ category = $ this -> categoryFactory -> create ( ) ; $ this -> categoryResource -> load ( $ category , $ catId ) ; if ( $ category -> getId ( ) ) { $ reportProductCollection -> getSelect ( ) -> joinLeft ( [ 'ccpi' => $ this -> getTable ( 'catalog_category_product_index' ) ] , 'e.entity_id = ccpi.product_id' , [ 'category_id' ] ) -> where ( 'ccpi.category_id =?' , $ catId ) ; } else { $ this -> helper -> log ( 'Most viewed. Category id ' . $ catId . ' is invalid. It does not exist.' ) ; } } if ( $ catName ) { $ category = $ this -> categoryFactory -> create ( ) -> loadByAttribute ( 'name' , $ catName ) ; if ( $ category -> getId ( ) ) { $ reportProductCollection -> getSelect ( ) -> joinLeft ( [ 'ccpi' => $ this -> getTable ( 'catalog_category_product_index' ) ] , 'e.entity_id = ccpi.product_id' , [ 'category_id' ] ) -> where ( 'ccpi.category_id =?' , $ category -> getId ( ) ) ; } else { $ this -> helper -> log ( 'Most viewed. Category name ' . $ catName . ' is invalid. It does not exist.' ) ; } } return $ reportProductCollection ; } | Get most viewed product collection . |
38,944 | public function getRecentlyViewed ( $ customerId , $ limit ) { $ attributes = $ this -> config -> getProductAttributes ( ) ; $ this -> productIndexcollection -> addAttributeToSelect ( $ attributes ) ; $ this -> productIndexcollection -> setCustomerId ( $ customerId ) ; $ this -> productIndexcollection -> addUrlRewrite ( ) -> setPageSize ( $ limit ) -> setCurPage ( 1 ) ; $ collection = $ this -> productIndexcollection -> addPriceData ( ) -> addIndexFilter ( ) -> setAddedAtOrder ( ) -> setVisibility ( $ this -> productVisibility -> getVisibleInSiteIds ( ) ) ; return $ collection -> getColumnValues ( 'product_id' ) ; } | Get recently viewed . |
38,945 | public function getProductCollectionFromIds ( $ ids , $ limit = false ) { $ productCollection = [ ] ; if ( ! empty ( $ ids ) ) { $ productCollection = $ this -> productFactory -> create ( ) -> getCollection ( ) -> addIdFilter ( $ ids ) -> addAttributeToSelect ( [ 'product_url' , 'name' , 'store_id' , 'small_image' , 'price' ] ) ; if ( $ limit ) { $ productCollection -> getSelect ( ) -> limit ( $ limit ) ; } } return $ productCollection ; } | Get product collection from ids . |
38,946 | public function getProductsCollectionBySku ( $ productsSku , $ limit = false ) { $ productCollection = [ ] ; if ( ! empty ( $ productsSku ) ) { $ productCollection = $ this -> productFactory -> create ( ) -> getCollection ( ) -> addAttributeToSelect ( [ 'product_url' , 'name' , 'store_id' , 'small_image' , 'price' , 'visibility' ] ) -> addFieldToFilter ( 'sku' , [ 'in' => $ productsSku ] ) ; if ( $ limit ) { $ productCollection -> getSelect ( ) -> limit ( $ limit ) ; } } return $ productCollection ; } | Get product collection from sku . |
38,947 | public function getBestsellerCollection ( $ from , $ to , $ limit , $ storeId ) { $ reportProductCollection = $ this -> productSoldFactory -> create ( ) -> addOrderedQty ( $ from , $ to ) -> setOrder ( 'ordered_qty' , 'desc' ) -> setStoreIds ( [ $ storeId ] ) -> setPageSize ( $ limit ) ; $ productsSku = $ reportProductCollection -> getColumnValues ( 'order_items_sku' ) ; return $ this -> getProductsCollectionBySku ( $ productsSku ) ; } | Get bestseller collection . |
38,948 | public function resetCatalog ( $ from = null , $ to = null ) { $ conn = $ this -> getConnection ( ) ; if ( $ from && $ to ) { $ where = [ 'created_at >= ?' => $ from . ' 00:00:00' , 'created_at <= ?' => $ to . ' 23:59:59' , 'imported is ?' => new \ Zend_Db_Expr ( 'not null' ) ] ; } else { $ where = $ conn -> quoteInto ( 'imported is ?' , new \ Zend_Db_Expr ( 'not null' ) ) ; } $ num = $ conn -> update ( $ this -> getTable ( Schema :: EMAIL_CATALOG_TABLE ) , [ 'imported' => new \ Zend_Db_Expr ( 'null' ) , 'modified' => new \ Zend_Db_Expr ( 'null' ) , ] , $ where ) ; return $ num ; } | Reset for re - import . |
38,949 | public function setImportedByIds ( $ ids ) { try { $ coreResource = $ this -> getConnection ( ) ; $ tableName = $ this -> getTable ( Schema :: EMAIL_CATALOG_TABLE ) ; $ coreResource -> update ( $ tableName , [ 'modified' => new \ Zend_Db_Expr ( 'null' ) , 'imported' => '1' , 'updated_at' => gmdate ( 'Y-m-d H:i:s' ) , ] , [ "product_id IN (?)" => $ ids ] ) ; } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } } | Set imported and modified in bulk query . |
38,950 | public function removeOrphanProducts ( ) { $ write = $ this -> getConnection ( ) ; $ catalogTable = $ this -> getTable ( Schema :: EMAIL_CATALOG_TABLE ) ; $ select = $ write -> select ( ) ; $ select -> reset ( ) -> from ( [ 'c' => $ catalogTable ] , [ 'c.product_id' ] ) -> joinLeft ( [ 'e' => $ this -> getTable ( 'catalog_product_entity' ) , ] , 'c.product_id = e.entity_id' ) -> where ( 'e.entity_id is NULL' ) ; $ deleteSql = $ select -> deleteFromSelect ( 'c' ) ; $ write -> query ( $ deleteSql ) ; } | Remove product with product id set and no product |
38,951 | public function setModified ( $ ids ) { $ write = $ this -> getConnection ( ) ; $ tableName = $ this -> getTable ( Schema :: EMAIL_CATALOG_TABLE ) ; $ write -> update ( $ tableName , [ 'modified' => 1 ] , [ $ write -> quoteInto ( "product_id IN (?)" , $ ids ) , $ write -> quoteInto ( "imported = ?" , 1 ) ] ) ; } | Set modified if already imported |
38,952 | public function getAvailableSyncs ( $ concreteName = true ) { return array_map ( function ( $ class ) use ( $ concreteName ) { $ classBasename = substr ( get_class ( $ class ) , strrpos ( get_class ( $ class ) , '\\' ) + 1 ) ; return $ concreteName ? str_replace ( 'Factory' , '' , $ classBasename ) : $ classBasename ; } , get_object_vars ( $ this ) ) ; } | Get names of available sync objects |
38,953 | public function getAddressBooks ( ) { $ website = $ this -> helper -> getWebsite ( ) ; $ client = $ this -> helper -> getWebsiteApiClient ( $ website ) ; $ savedAddressBooks = $ this -> registry -> registry ( 'addressbooks' ) ; if ( $ savedAddressBooks ) { $ addressBooks = $ savedAddressBooks ; } else { $ addressBooks = $ client -> getAddressBooks ( ) ; $ this -> registry -> unregister ( 'addressbooks' ) ; $ this -> registry -> register ( 'addressbooks' , $ addressBooks ) ; } return $ addressBooks ; } | Get address books . |
38,954 | public function toOptionArray ( ) { if ( ! ( $ collection = $ this -> coreRegistry -> registry ( 'config_system_email_template' ) ) ) { $ collection = $ this -> templatesFactory -> create ( ) ; $ collection -> load ( ) ; $ this -> coreRegistry -> register ( 'config_system_email_template' , $ collection ) ; } return $ this -> emailConfig -> getAvailableTemplates ( ) ; } | Generate list of email templates |
38,955 | private function encryptAllRefreshTokens ( ) { $ userCollection = $ this -> userCollectionFactory -> create ( ) -> addFieldToFilter ( 'refresh_token' , [ 'notnull' => true ] ) ; foreach ( $ userCollection as $ user ) { $ this -> encryptAndSaveRefreshToken ( $ user ) ; } } | Encrypt all tokens |
38,956 | private function encryptAndSaveRefreshToken ( $ user ) { $ user -> setRefreshToken ( $ this -> helper -> encryptor -> encrypt ( $ user -> getRefreshToken ( ) ) ) ; $ this -> userResource -> save ( $ user ) ; } | Encrypt token and save |
38,957 | private function encryptAllPasswords ( ) { $ websites = $ this -> helper -> getWebsites ( true ) ; $ paths = [ Config :: XML_PATH_CONNECTOR_API_PASSWORD , Transactional :: XML_PATH_DDG_TRANSACTIONAL_PASSWORD ] ; foreach ( $ websites as $ website ) { if ( $ website -> getId ( ) > 0 ) { $ scope = ScopeInterface :: SCOPE_WEBSITES ; } else { $ scope = ScopeConfigInterface :: SCOPE_TYPE_DEFAULT ; } foreach ( $ paths as $ path ) { $ this -> encryptAndSavePassword ( $ path , $ scope , $ website -> getId ( ) ) ; } } } | Encrypt passwords and save for all websites |
38,958 | private function encryptAndSavePassword ( $ path , $ scope , $ id ) { $ configCollection = $ this -> configCollectionFactory -> create ( ) -> addFieldToFilter ( 'scope' , $ scope ) -> addFieldToFilter ( 'scope_id' , $ id ) -> addFieldToFilter ( 'path' , $ path ) -> setPageSize ( 1 ) ; if ( $ configCollection -> getSize ( ) ) { $ value = $ configCollection -> getFirstItem ( ) -> getValue ( ) ; if ( $ value ) { $ this -> helper -> saveConfigData ( $ path , $ this -> helper -> encryptor -> encrypt ( $ value ) , $ scope , $ id ) ; } } } | Encrypt already saved passwords |
38,959 | public function deleteTemplateByCode ( $ templatecode ) { $ template = $ this -> loadByTemplateByCode ( $ templatecode ) ; if ( $ template -> getId ( ) ) { $ template -> delete ( ) ; } } | Delete email_template . |
38,960 | public function sync ( ) { $ result = [ 'store' => 'Stores : ' , 'message' => 'Done.' ] ; $ lastWebsiteId = '0' ; foreach ( $ this -> storeManager -> getStores ( true ) as $ store ) { $ storeId = $ store -> getId ( ) ; if ( ! $ this -> helper -> isStoreEnabled ( $ storeId ) ) { continue ; } $ websiteId = $ store -> getWebsiteId ( ) ; if ( $ websiteId != $ lastWebsiteId ) { $ this -> processedCampaigns = [ ] ; $ lastWebsiteId = $ websiteId ; } foreach ( $ this -> templateConfigIdToDotmailerConfigPath as $ configTemplateId => $ dotConfigPath ) { $ campaignId = $ this -> getConfigValue ( $ dotConfigPath , $ storeId ) ; $ configPath = $ this -> templateConfigMapping [ $ configTemplateId ] ; $ emailTemplateId = $ this -> getConfigValue ( $ configPath , $ storeId ) ; if ( $ campaignId && $ emailTemplateId && ! in_array ( $ campaignId , $ this -> processedCampaigns ) ) { $ this -> syncEmailTemplate ( $ campaignId , $ emailTemplateId , $ store ) ; $ result [ 'store' ] .= ', ' . $ store -> getCode ( ) ; $ this -> processedCampaigns [ $ campaignId ] = $ campaignId ; } } } return $ result ; } | Template sync . |
38,961 | public function sync ( ) { $ result = [ 'success' => true , 'message' => '' ] ; $ this -> start = microtime ( true ) ; foreach ( $ this -> helper -> getWebsites ( ) as $ website ) { $ apiEnabled = $ this -> helper -> isEnabled ( $ website ) ; $ customerSyncEnabled = $ this -> helper -> isCustomerSyncEnabled ( $ website ) ; $ customerAddressBook = $ this -> helper -> getCustomerAddressBook ( $ website ) ; if ( $ apiEnabled && $ customerSyncEnabled && $ customerAddressBook ) { $ contactsUpdated = $ this -> exportCustomersForWebsite ( $ website ) ; if ( $ contactsUpdated ) { $ result [ 'message' ] .= $ website -> getName ( ) . ', updated contacts ' . $ contactsUpdated ; } } } if ( $ this -> countCustomers ) { $ message = '----------- Customer sync ----------- : ' . gmdate ( 'H:i:s' , microtime ( true ) - $ this -> start ) . ', Total contacts = ' . $ this -> countCustomers ; $ this -> helper -> log ( $ message ) ; $ message .= $ result [ 'message' ] ; $ result [ 'message' ] = $ message ; } return $ result ; } | Contact sync . |
38,962 | public function execute ( ) { $ email = $ this -> getRequest ( ) -> getParam ( 'email' ) ; if ( $ email && $ quote = $ this -> checkoutSession -> getQuote ( ) ) { if ( ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { return null ; } if ( $ quote -> hasItems ( ) ) { try { $ quote -> setCustomerEmail ( $ email ) ; $ this -> quoteResource -> save ( $ quote ) ; } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } } } } | Easy email capture for Newsletter and Checkout . |
38,963 | public function toOptionArray ( ) { $ fields = [ ] ; $ fields [ ] = [ 'value' => 0 , 'label' => '-- Please Select --' ] ; $ apiEnabled = $ this -> helper -> isEnabled ( $ this -> helper -> getWebsite ( ) ) ; if ( $ apiEnabled ) { $ savedAddressbooks = $ this -> registry -> registry ( 'addressbooks' ) ; if ( $ savedAddressbooks ) { $ addressBooks = $ savedAddressbooks ; } else { $ client = $ this -> helper -> getWebsiteApiClient ( $ this -> helper -> getWebsite ( ) ) ; $ addressBooks = $ client -> getAddressBooks ( ) ; if ( $ addressBooks ) { $ this -> registry -> unregister ( 'addressbooks' ) ; $ this -> registry -> register ( 'addressbooks' , $ addressBooks ) ; } } foreach ( $ addressBooks as $ book ) { if ( isset ( $ book -> id ) ) { $ fields [ ] = [ 'value' => ( string ) $ book -> id , 'label' => ( string ) $ book -> name , ] ; } } } return $ fields ; } | Retrieve list of options . |
38,964 | public function toOptionArray ( ) { $ result = $ row = [ ] ; $ i = 0 ; foreach ( $ this -> times as $ one ) { if ( $ i == 0 ) { $ row = [ 'value' => $ one , 'label' => $ one . __ ( ' Hour' ) , ] ; } else { $ row = [ 'value' => $ one , 'label' => $ one . __ ( ' Hours' ) , ] ; } $ result [ ] = $ row ; ++ $ i ; } return $ result ; } | Send to campain options hours . |
38,965 | private function checkStatusForPendingContacts ( ) { $ updatedAt = $ this -> dateTime -> formatDate ( true ) ; if ( $ this -> isItTimeToCheckPendingContact ( ) ) { $ collection = $ this -> automationFactory -> create ( ) -> getCollectionByPendingStatus ( ) ; $ idsToUpdateStatus = [ ] ; $ idsToUpdateDate = [ ] ; foreach ( $ collection as $ item ) { $ contact = $ this -> helper -> getContact ( $ item -> getEmail ( ) , $ item -> getWebsiteId ( ) ) ; if ( isset ( $ contact -> id ) && $ contact -> status !== self :: CONTACT_STATUS_PENDING ) { $ idsToUpdateStatus [ ] = $ item -> getId ( ) ; } else { $ idsToUpdateDate [ ] = $ item -> getId ( ) ; } } if ( ! empty ( $ idsToUpdateStatus ) ) { $ this -> automationResource -> update ( $ idsToUpdateStatus , $ updatedAt , self :: CONTACT_STATUS_CONFIRMED ) ; } if ( ! empty ( $ idsToUpdateDate ) ) { $ this -> automationResource -> update ( $ idsToUpdateDate , $ updatedAt ) ; } } $ collection = $ this -> automationFactory -> create ( ) -> getCollectionByPendingStatus ( $ this -> getDateTimeForExpiration ( ) ) ; $ ids = $ collection -> getColumnValues ( 'id' ) ; if ( ! empty ( $ ids ) ) { $ this -> automationResource -> update ( $ ids , $ updatedAt , self :: CONTACT_STATUS_EXPIRED ) ; } } | check automation entries for pending contacts |
38,966 | private function updateDatafieldsByType ( $ type , $ email , $ websiteId ) { switch ( $ type ) { case self :: AUTOMATION_TYPE_NEW_ORDER : case self :: AUTOMATION_TYPE_NEW_GUEST_ORDER : case self :: ORDER_STATUS_AUTOMATION : case self :: AUTOMATION_TYPE_CUSTOMER_FIRST_ORDER : $ this -> updateNewOrderDatafields ( $ websiteId ) ; break ; case self :: AUTOMATION_TYPE_ABANDONED_CART_PROGRAM_ENROLMENT : $ this -> updateAbandoned -> updateAbandonedCartDatafields ( $ email , $ websiteId , $ this -> typeId , $ this -> storeName ) ; default : $ this -> updateDefaultDatafields ( $ email , $ websiteId ) ; break ; } } | Update single contact datafields for this automation type . |
38,967 | private function updateDefaultDatafields ( $ email , $ websiteId ) { $ website = $ this -> helper -> storeManager -> getWebsite ( $ websiteId ) ; $ this -> helper -> updateDataFields ( $ email , $ website , $ this -> storeName ) ; } | Update config datafield . |
38,968 | private function updateNewOrderDatafields ( $ websiteId ) { $ website = $ this -> helper -> storeManager -> getWebsite ( $ websiteId ) ; $ orderModel = $ this -> orderFactory -> create ( ) -> loadByIncrementId ( $ this -> typeId ) ; if ( $ lastOrderId = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID ) ) { $ data [ ] = [ 'Key' => $ lastOrderId , 'Value' => $ orderModel -> getId ( ) , ] ; } if ( $ orderIncrementId = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_INCREMENT_ID ) ) { $ data [ ] = [ 'Key' => $ orderIncrementId , 'Value' => $ orderModel -> getIncrementId ( ) , ] ; } if ( $ storeName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME ) ) { $ data [ ] = [ 'Key' => $ storeName , 'Value' => $ this -> storeName , ] ; } if ( $ websiteName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME ) ) { $ data [ ] = [ 'Key' => $ websiteName , 'Value' => $ website -> getName ( ) , ] ; } if ( $ lastOrderDate = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE ) ) { $ data [ ] = [ 'Key' => $ lastOrderDate , 'Value' => $ orderModel -> getCreatedAt ( ) , ] ; } if ( ( $ customerId = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_ID ) ) && $ orderModel -> getCustomerId ( ) ) { $ data [ ] = [ 'Key' => $ customerId , 'Value' => $ orderModel -> getCustomerId ( ) , ] ; } if ( ! empty ( $ data ) ) { $ client = $ this -> helper -> getWebsiteApiClient ( $ website ) ; $ client -> updateContactDatafieldsByEmail ( $ orderModel -> getCustomerEmail ( ) , $ data ) ; } } | Update new order default datafields . |
38,969 | private function checkCampignEnrolmentActive ( $ programId , $ websiteId ) { if ( ! $ programId ) { return false ; } $ client = $ this -> helper -> getWebsiteApiClient ( $ websiteId ) ; $ program = $ client -> getProgramById ( $ programId ) ; if ( isset ( $ program -> status ) ) { $ this -> programStatus = $ program -> status ; } if ( isset ( $ program -> status ) && $ program -> status == 'Active' ) { return true ; } return false ; } | Program check if is valid and active . |
38,970 | private function sendContactsToAutomation ( $ contacts , $ websiteId ) { $ client = $ this -> helper -> getWebsiteApiClient ( $ websiteId ) ; $ data = [ 'Contacts' => $ contacts , 'ProgramId' => $ this -> programId , 'AddressBooks' => [ ] , ] ; $ result = $ client -> postProgramsEnrolments ( $ data ) ; return $ result ; } | Enrol contacts for a program . |
38,971 | private function setupAutomationTypes ( ) { $ statusTypes = $ this -> automationFactory -> create ( ) -> getAutomationStatusType ( ) ; foreach ( $ statusTypes as $ type ) { $ this -> automationTypes [ $ type ] = \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER_STATUS ; } } | Setup automation types |
38,972 | public function create ( ) { $ syncLevel = $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_CATALOG_VALUES ) ; if ( $ syncLevel == self :: SYNC_CATALOG_DEFAULT_LEVEL ) { return $ this -> defaultLevelCatalogSyncerFactory -> create ( ) ; } elseif ( $ syncLevel == self :: SYNC_CATALOG_STORE_LEVEL ) { return $ this -> storeLevelCatalogSyncerFactory -> create ( ) ; } return null ; } | Create syncer class instance depending on configuration |
38,973 | public function loadProductById ( $ productId ) { $ collection = $ this -> catalogCollection -> create ( ) -> addFieldToFilter ( 'product_id' , $ productId ) -> setPageSize ( 1 ) ; return $ collection -> getFirstItem ( ) ; } | Load by product id . |
38,974 | public function setSent ( $ sendId ) { $ bind = [ 'send_status' => \ Dotdigitalgroup \ Email \ Model \ Campaign :: SENT , 'sent_at' => $ this -> datetime -> gmtDate ( ) ] ; $ conn = $ this -> getConnection ( ) ; $ conn -> update ( $ this -> getMainTable ( ) , $ bind , [ 'send_id = ?' => $ sendId ] ) ; } | Set sent . |
38,975 | protected function configure ( ) { $ this -> setName ( 'dotdigital:sync' ) -> setDescription ( __ ( 'Run syncs to populate email_ tables before importing to Engagement Cloud' ) ) -> addArgument ( 'sync' , InputArgument :: OPTIONAL , sprintf ( '%s (%s)' , __ ( 'The name of the sync to run' ) , implode ( '; ' , $ this -> syncProvider -> getAvailableSyncs ( ) ) ) ) ; parent :: configure ( ) ; } | Configure this command |
38,976 | public function toOptionArray ( ) { $ statuses = $ this -> orderConfig -> getStatuses ( ) ; $ options [ ] = [ 'label' => __ ( '---- Default Option ----' ) , 'value' => '0' , ] ; foreach ( $ statuses as $ code => $ label ) { $ options [ ] = [ 'value' => $ code , 'label' => $ label ] ; } return $ options ; } | Returns the order statuses for field order_statuses . |
38,977 | public function run ( ) { $ this -> emptyTables ( ) ; foreach ( $ this -> dataMigrationTypeProvider -> getTypes ( ) as $ dataMigration ) { $ dataMigration -> execute ( ) ; $ this -> logActions ( $ dataMigration ) ; } $ this -> saveAllOrderStatusesAsString ( ) ; $ this -> saveAllProductTypesAsString ( ) ; $ this -> saveAllProductVisibilitiesAsString ( ) ; $ this -> generateAndSaveCode ( ) ; } | Run all install methods |
38,978 | private function logActions ( AbstractDataMigration $ dataMigration ) { $ this -> logger -> debug ( 'Dotdigitalgroup_Email data installer' , [ 'type' => get_class ( $ dataMigration ) , 'rows_affected' => $ dataMigration -> getRowsAffected ( ) , ] ) ; if ( $ this -> output ) { $ this -> output -> writeln ( sprintf ( '%s: rows affected %s' , get_class ( $ dataMigration ) , $ dataMigration -> getRowsAffected ( ) ) ) ; } } | Log actions of each data migration |
38,979 | private function emptyTables ( ) { foreach ( $ this -> dataMigrationTypeProvider -> getTypes ( ) as $ migrationType ) { $ tableName = $ this -> resourceConnection -> getTableName ( $ migrationType -> getTableName ( ) ) ; $ this -> resourceConnection -> getConnection ( ) -> delete ( $ tableName ) ; $ this -> resourceConnection -> getConnection ( ) -> query ( sprintf ( 'ALTER TABLE %s AUTO_INCREMENT = 1' , $ tableName ) ) ; } } | Truncate relevant tables before running |
38,980 | private function saveAllOrderStatusesAsString ( ) { $ options = array_keys ( $ this -> orderConfig -> getStatuses ( ) ) ; $ statusString = implode ( ',' , $ options ) ; $ this -> config -> saveConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_ORDER_STATUS , $ statusString , 'website' , 0 ) ; } | Get all order statuses and save in config |
38,981 | private function saveAllProductTypesAsString ( ) { $ types = $ this -> typeFactory -> create ( ) -> toOptionArray ( ) ; $ options = [ ] ; foreach ( $ types as $ type ) { $ options [ ] = $ type [ 'value' ] ; } $ typeString = implode ( ',' , $ options ) ; $ this -> config -> saveConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_CATALOG_TYPE , $ typeString , 'website' , '0' ) ; } | Get all product types and save in config |
38,982 | private function saveAllProductVisibilitiesAsString ( ) { $ visibilities = $ this -> visibilityFactory -> create ( ) -> toOptionArray ( ) ; $ options = [ ] ; foreach ( $ visibilities as $ visibility ) { $ options [ ] = $ visibility [ 'value' ] ; } $ visibilityString = implode ( ',' , $ options ) ; $ this -> config -> saveConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_CATALOG_VISIBILITY , $ visibilityString , 'website' , '0' ) ; } | Get all product visibility types and save in config |
38,983 | private function generateAndSaveCode ( ) { $ code = $ this -> randomMath -> getRandomString ( 32 ) ; $ this -> config -> saveConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE , $ code , 'default' , '0' ) ; } | Generate a random string and save in config |
38,984 | public function getHeaderText ( ) { $ rule = $ this -> registry -> registry ( 'current_ddg_rule' ) ; if ( $ rule -> getId ( ) ) { return __ ( 'Edit Rule %1' , $ this -> escapeHtml ( $ rule -> getName ( ) ) ) ; } else { return __ ( 'New Rule' ) ; } } | Getter for form header text . |
38,985 | public function exportSubscribersPerWebsite ( $ website ) { $ isSubscriberSalesDataEnabled = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ENABLE_SUBSCRIBER_SALES_DATA , $ website ) ; $ updated = 0 ; $ limit = $ this -> helper -> getSyncLimit ( $ website -> getId ( ) ) ; $ emailContactModel = $ this -> contactFactory -> create ( ) ; $ subscribersAreCustomers = $ emailContactModel -> getSubscribersToImport ( $ website , $ limit ) ; $ subscribersAreGuest = $ emailContactModel -> getSubscribersToImport ( $ website , $ limit , false ) ; $ subscribersGuestEmails = $ subscribersAreGuest -> getColumnValues ( 'email' ) ; $ existInSales = [ ] ; if ( $ isSubscriberSalesDataEnabled && ! empty ( $ subscribersGuestEmails ) ) { $ existInSales = $ this -> checkInSales ( $ subscribersGuestEmails ) ; } $ emailsNotInSales = array_diff ( $ subscribersGuestEmails , $ existInSales ) ; $ customerSubscribers = $ subscribersAreCustomers -> getColumnValues ( 'email' ) ; $ emailsWithNoSaleData = array_merge ( $ emailsNotInSales , $ customerSubscribers ) ; $ subscribersWithNoSaleData = [ ] ; if ( ! empty ( $ emailsWithNoSaleData ) ) { $ subscribersWithNoSaleData = $ emailContactModel -> getSubscribersToImportFromEmails ( $ emailsWithNoSaleData ) ; } if ( ! empty ( $ subscribersWithNoSaleData ) ) { $ updated += $ this -> subscriberExporter -> exportSubscribers ( $ website , $ subscribersWithNoSaleData ) ; $ this -> countSubscribers += $ updated ; } $ subscribersWithSaleData = [ ] ; if ( ! empty ( $ existInSales ) ) { $ subscribersWithSaleData = $ emailContactModel -> getSubscribersToImportFromEmails ( $ existInSales ) ; } if ( ! empty ( $ subscribersWithSaleData ) ) { $ updated += $ this -> subscriberWithSalesExporter -> exportSubscribersWithSales ( $ website , $ subscribersWithSaleData ) ; $ this -> countSubscribers += $ updated ; } return $ updated ; } | Export subscribers per website . |
38,986 | public function unsubscribe ( ) { $ result [ 'customers' ] = 0 ; $ suppressedEmails = [ ] ; $ websites = $ this -> helper -> getWebsites ( true ) ; foreach ( $ websites as $ website ) { if ( ! $ this -> helper -> isEnabled ( $ website ) ) { continue ; } $ suppressedEmails = $ this -> getSuppressedContacts ( $ website ) ; } if ( ! empty ( $ suppressedEmails ) ) { $ result [ 'customers' ] = $ this -> emailContactResource -> unsubscribe ( $ suppressedEmails ) ; } return $ result ; } | Un - subscribe suppressed contacts . |
38,987 | public function getLoadedProductCollection ( ) { $ params = $ this -> getRequest ( ) -> getParams ( ) ; if ( ! isset ( $ params [ 'customer_id' ] ) || ! isset ( $ params [ 'code' ] ) || ! $ this -> helper -> isCodeValid ( $ params [ 'code' ] ) ) { $ this -> helper -> log ( 'Recently viewed no id or valid code is set' ) ; return [ ] ; } $ productsToDisplay = [ ] ; $ mode = $ this -> getRequest ( ) -> getActionName ( ) ; $ customerId = ( int ) $ this -> getRequest ( ) -> getParam ( 'customer_id' ) ; $ limit = ( int ) $ this -> recommnededHelper -> getDisplayLimitByMode ( $ mode ) ; $ session = $ this -> sessionFactory -> create ( ) ; $ isLoggedIn = $ session -> loginById ( $ customerId ) ; $ productIds = $ this -> catalog -> getRecentlyViewed ( $ customerId , $ limit ) ; $ productCollection = $ this -> catalog -> getProductCollectionFromIds ( $ productIds ) ; foreach ( $ productCollection as $ product ) { if ( $ product -> isSalable ( ) ) { $ productsToDisplay [ $ product -> getId ( ) ] = $ product ; } } $ this -> helper -> log ( 'Recentlyviewed customer : ' . $ customerId . ', mode ' . $ mode . ', limit : ' . $ limit . ', items found : ' . count ( $ productIds ) . ', is customer logged in : ' . $ isLoggedIn . ', products :' . count ( $ productsToDisplay ) ) ; $ session -> logout ( ) ; return $ productsToDisplay ; } | Products collection . |
38,988 | public function getBasketItems ( ) { $ params = $ this -> getRequest ( ) -> getParams ( ) ; if ( ! isset ( $ params [ 'quote_id' ] ) || ! isset ( $ params [ 'code' ] ) || ! $ this -> helper -> isCodeValid ( $ params [ 'code' ] ) ) { $ this -> helper -> log ( 'Abandoned cart not found or invalid code' ) ; return false ; } $ quoteId = ( int ) $ params [ 'quote_id' ] ; $ quoteModel = $ this -> quoteFactory -> create ( ) -> loadByIdWithoutStore ( $ quoteId ) ; if ( ! $ quoteModel -> getId ( ) ) { $ this -> helper -> log ( 'no quote found for ' . $ quoteId ) ; return false ; } if ( ! $ quoteModel -> getIsActive ( ) ) { $ this -> helper -> log ( 'Cart is not active : ' . $ quoteId ) ; return false ; } $ this -> quote = $ quoteModel ; $ storeId = $ quoteModel -> getStoreId ( ) ; $ appEmulation = $ this -> emulationFactory -> create ( ) ; $ appEmulation -> startEnvironmentEmulation ( $ storeId ) ; $ quoteItems = $ quoteModel -> getAllItems ( ) ; $ itemsData = [ ] ; $ parentProductIds = [ ] ; foreach ( $ quoteItems as $ quoteItem ) { if ( $ quoteItem -> getParentItemId ( ) == null ) { $ parentProductIds [ ] = $ quoteItem -> getProduct ( ) -> getId ( ) ; } } foreach ( $ quoteItems as $ quoteItem ) { if ( $ quoteItem -> getParentItemId ( ) != null ) { if ( $ quoteItem -> getParentItem ( ) -> getProductType ( ) == 'bundle' ) { continue ; } $ itemsData [ ] = $ this -> getItemDataForChildProducts ( $ quoteItem ) ; if ( in_array ( $ quoteItem -> getParentItem ( ) -> getProduct ( ) -> getId ( ) , $ parentProductIds ) ) { $ key = array_search ( $ quoteItem -> getParentItem ( ) -> getProduct ( ) -> getId ( ) , $ parentProductIds ) ; unset ( $ parentProductIds [ $ key ] ) ; } } } foreach ( $ quoteItems as $ quoteItem ) { if ( $ quoteItem -> getParentItemId ( ) == null && in_array ( $ quoteItem -> getProduct ( ) -> getId ( ) , $ parentProductIds ) ) { $ itemsData [ ] = $ this -> getItemDataForParentProducts ( $ quoteItem ) ; } } return $ itemsData ; } | Basket items . |
38,989 | private function getItemsData ( $ quoteItem , $ _product , $ _parentProduct ) { $ totalPrice = ( ! isset ( $ _parentProduct ) ? $ quoteItem -> getBaseRowTotalInclTax ( ) : $ quoteItem -> getParentItem ( ) -> getBaseRowTotalInclTax ( ) ) ; $ inStock = ( $ _product -> isInStock ( ) ) ? 'In Stock' : 'Out of stock' ; $ total = $ this -> priceHelper -> currency ( $ totalPrice , true , false ) ; $ productUrl = ( isset ( $ _parentProduct ) ? $ this -> urlFinder -> fetchFor ( $ _parentProduct ) : $ this -> urlFinder -> fetchFor ( $ _product ) ) ; $ grandTotal = $ this -> priceHelper -> currency ( $ this -> getGrandTotal ( ) , true , false ) ; $ itemsData = [ 'grandTotal' => $ grandTotal , 'total' => $ total , 'inStock' => $ inStock , 'productUrl' => $ productUrl , 'product' => ( isset ( $ _parentProduct ) ? $ _parentProduct : $ _product ) , 'qty' => isset ( $ _parentProduct ) ? $ quoteItem -> getParentItem ( ) -> getQty ( ) : $ quoteItem -> getQty ( ) , 'product_details' => $ _product ] ; return $ itemsData ; } | Returns the itemsData array to be viewed ; |
38,990 | public function canShowUrl ( ) { return ( boolean ) $ this -> quote -> getStore ( ) -> getWebsite ( ) -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CONTENT_LINK_ENABLED ) ; } | Can show go to basket url . |
38,991 | public function getApiValid ( ) { $ apiUsername = $ this -> helper -> getApiUsername ( ) ; $ apiPassword = $ this -> helper -> getApiPassword ( ) ; $ result = $ this -> test -> validate ( $ apiUsername , $ apiPassword ) ; return ( $ result ) ? '<span class="message message-success">Valid</span>' : '<span class="message message-error">Not Valid</span>' ; } | Get the api creds are valid . |
38,992 | public function getCronLastExecution ( ) { $ date = $ this -> escapeHtml ( $ this -> helper -> getDateLastCronRun ( 'ddg_automation_importer' ) ) ; if ( ! $ date ) { $ date = '<span class="message message-error">No cron found</span>' ; } return $ date ; } | Get the last successful execution for import . |
38,993 | public function contactSync ( ) { if ( $ this -> jobHasAlreadyBeenRun ( 'ddg_automation_customer_subscriber_guest_sync' ) ) { $ message = 'Skipping ddg_automation_customer_subscriber_guest_sync job run' ; $ this -> helper -> log ( $ message ) ; return [ 'message' => $ message ] ; } $ result = $ this -> contactFactory -> create ( ) -> sync ( ) ; $ subscriberResult = $ this -> subscribersAndGuestSync ( ) ; if ( isset ( $ subscriberResult [ 'message' ] ) && isset ( $ result [ 'message' ] ) ) { $ result [ 'message' ] = $ result [ 'message' ] . ' - ' . $ subscriberResult [ 'message' ] ; } return $ result ; } | CRON FOR CONTACTS SYNC . |
38,994 | public function subscribersAndGuestSync ( ) { $ subscriberModel = $ this -> subscriberFactory -> create ( ) ; $ result = $ subscriberModel -> sync ( ) ; $ subscriberModel -> unsubscribe ( ) ; $ this -> guestFactory -> create ( ) -> sync ( ) ; return $ result ; } | CRON FOR SUBSCRIBERS AND GUEST CONTACTS . |
38,995 | public function catalogSync ( ) { if ( $ this -> jobHasAlreadyBeenRun ( 'ddg_automation_catalog_sync' ) ) { $ message = 'Skipping ddg_automation_catalog_sync job run' ; $ this -> helper -> log ( $ message ) ; return [ 'message' => $ message ] ; } $ result = $ this -> catalogFactory -> create ( ) -> sync ( ) ; return $ result ; } | CRON FOR CATALOG SYNC . |
38,996 | public function emailImporter ( ) { if ( $ this -> jobHasAlreadyBeenRun ( 'ddg_automation_importer' ) ) { $ this -> helper -> log ( 'Skipping ddg_automation_importer job run' ) ; return ; } $ this -> importerFactory -> create ( ) -> processQueue ( ) ; } | CRON FOR EMAIL IMPORTER PROCESSOR . |
38,997 | public function reviewsAndWishlist ( ) { if ( $ this -> jobHasAlreadyBeenRun ( 'ddg_automation_reviews_and_wishlist' ) ) { $ this -> helper -> log ( 'Skipping ddg_automation_reviews_and_wishlist job run' ) ; return ; } $ this -> reviewSync ( ) ; $ this -> cronHelper -> wishlistSync ( ) ; } | CRON FOR SYNC REVIEWS and REGISTER ORDER REVIEW CAMPAIGNS . |
38,998 | public function abandonedCarts ( ) { if ( $ this -> jobHasAlreadyBeenRun ( 'ddg_automation_abandonedcarts' ) ) { $ this -> helper -> log ( 'Skipping ddg_automation_abandonedcarts job run' ) ; return ; } $ this -> quoteFactory -> create ( ) -> processAbandonedCarts ( ) ; $ this -> abandonedCartProgramEnroller -> process ( ) ; } | CRON FOR ABANDONED CARTS . |
38,999 | public function syncAutomation ( ) { if ( $ this -> jobHasAlreadyBeenRun ( 'ddg_automation_status' ) ) { $ this -> helper -> log ( 'Skipping ddg_automation_status job run' ) ; return ; } $ this -> automationFactory -> create ( ) -> sync ( ) ; } | CRON FOR AUTOMATION . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.