idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
38,800
private function handleCustomerBasket ( ) { $ customerSession = $ this -> customerSessionFactory -> create ( ) ; $ configCartUrl = $ this -> quote -> getStore ( ) -> getWebsite ( ) -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CONTENT_CART_URL ) ; if ( $ customerSession -> isLoggedIn ( ) && $ customerSession -> getCustomerId ( ) == $ this -> quote -> getCustomerId ( ) ) { $ checkoutSession = $ this -> checkoutSession -> create ( ) ; if ( $ checkoutSession -> getQuote ( ) && $ checkoutSession -> getQuote ( ) -> hasItems ( ) ) { $ quote = $ checkoutSession -> getQuote ( ) ; if ( $ this -> quote -> getId ( ) != $ quote -> getId ( ) ) { $ this -> checkMissingAndAdd ( ) ; } } if ( $ configCartUrl ) { $ url = $ configCartUrl ; } else { $ url = $ this -> quote -> getStore ( ) -> getUrl ( 'checkout/cart' ) ; } $ this -> _redirect ( $ url ) ; } else { if ( $ configCartUrl ) { $ cartUrl = $ configCartUrl ; } else { $ cartUrl = 'checkout/cart' ; } $ customerSession -> setBeforeAuthUrl ( $ this -> quote -> getStore ( ) -> getUrl ( $ cartUrl ) ) ; $ configLoginUrl = $ this -> quote -> getStore ( ) -> getWebsite ( ) -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CONTENT_LOGIN_URL ) ; if ( $ configLoginUrl ) { $ loginUrl = $ configLoginUrl ; } else { $ loginUrl = 'customer/account/login' ; } $ this -> _redirect ( $ this -> quote -> getStore ( ) -> getUrl ( $ loginUrl ) ) ; } }
Process customer basket .
38,801
private function checkMissingAndAdd ( ) { $ checkoutSession = $ this -> checkoutSession -> create ( ) ; $ currentQuote = $ checkoutSession -> getQuote ( ) ; if ( $ currentQuote -> hasItems ( ) ) { $ currentSessionItems = $ currentQuote -> getAllItems ( ) ; $ currentItemIds = [ ] ; foreach ( $ currentSessionItems as $ currentSessionItem ) { $ currentItemIds [ ] = $ currentSessionItem -> getId ( ) ; } foreach ( $ this -> quote -> getAllItems ( ) as $ item ) { if ( ! in_array ( $ item -> getId ( ) , $ currentItemIds ) ) { $ currentQuote -> addItem ( $ item ) ; } } $ currentQuote -> collectTotals ( ) ; $ this -> quoteResource -> save ( $ currentQuote ) ; } }
Check missing items from current quote and add .
38,802
private function handleGuestBasket ( ) { $ configCartUrl = $ this -> quote -> getStore ( ) -> getWebsite ( ) -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CONTENT_CART_URL ) ; if ( $ configCartUrl ) { $ url = $ configCartUrl ; } else { $ url = 'checkout/cart' ; } $ this -> _redirect ( $ this -> quote -> getStore ( ) -> getUrl ( $ url ) ) ; }
Process guest basket .
38,803
public function getOrder ( ) { $ params = $ this -> getRequest ( ) -> getParams ( ) ; if ( ! isset ( $ params [ 'code' ] ) || ! $ this -> helper -> isCodeValid ( $ params [ 'code' ] ) ) { $ this -> helper -> log ( 'Review no valid code is set' ) ; return false ; } $ orderId = $ this -> _coreRegistry -> registry ( 'order_id' ) ; $ order = $ this -> _coreRegistry -> registry ( 'current_order' ) ; if ( ! $ orderId ) { $ orderId = ( int ) $ this -> getRequest ( ) -> getParam ( 'order_id' ) ; if ( ! $ orderId ) { return false ; } $ this -> _coreRegistry -> unregister ( 'order_id' ) ; $ this -> _coreRegistry -> register ( 'order_id' , $ orderId ) ; } if ( ! $ order ) { if ( ! $ orderId ) { return false ; } $ order = $ this -> orderFactory -> create ( ) ; $ this -> orderResource -> load ( $ order , $ orderId ) ; $ this -> _coreRegistry -> unregister ( 'current_order' ) ; $ this -> _coreRegistry -> register ( 'current_order' , $ order ) ; } return $ order ; }
Current Order .
38,804
public function filterItemsForReview ( $ items , $ websiteId ) { $ order = $ this -> getOrder ( ) ; if ( empty ( $ items ) || ! $ order ) { return false ; } if ( $ order -> getCustomerIsGuest ( ) ) { return $ items ; } if ( ! $ this -> helper -> isNewProductOnly ( $ websiteId ) ) { return $ items ; } $ customerId = $ order -> getCustomerId ( ) ; $ items = $ this -> review -> filterItemsForReview ( $ items , $ customerId , $ order ) ; return $ items ; }
Filter items for review . If a customer has already placed a review for a product then exclude the product .
38,805
public function getProductNames ( ) { $ items = $ this -> getOrder ( ) -> getAllItems ( ) ; $ productNames = [ ] ; foreach ( $ items as $ item ) { if ( $ item -> getParentItemId ( ) === null ) { $ productNames [ ] = str_replace ( '"' , ' ' , $ item -> getName ( ) ) ; } } return json_encode ( $ productNames ) ; }
Get product names
38,806
public function execute ( \ Magento \ Framework \ Event \ Observer $ observer ) { $ subscriber = $ observer -> getEvent ( ) -> getSubscriber ( ) ; $ email = $ subscriber -> getEmail ( ) ; $ websiteId = $ this -> storeManager -> getStore ( $ subscriber -> getStoreId ( ) ) -> getWebsiteId ( ) ; $ apiEnabled = $ this -> helper -> isEnabled ( $ websiteId ) ; if ( $ apiEnabled ) { try { $ this -> importerFactory -> create ( ) -> registerQueue ( \ Dotdigitalgroup \ Email \ Model \ Importer :: IMPORT_TYPE_CONTACT , $ email , \ Dotdigitalgroup \ Email \ Model \ Importer :: MODE_CONTACT_DELETE , $ websiteId ) ; $ contactModel = $ this -> contactFactory -> create ( ) -> loadByCustomerEmail ( $ email , $ websiteId ) ; if ( $ contactModel -> getId ( ) ) { $ this -> contactResource -> delete ( $ contactModel ) ; } } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } } return $ this ; }
Remove contact from account
38,807
public function setProduct ( $ product ) { $ this -> id = $ product -> getId ( ) ; $ this -> sku = $ product -> getSku ( ) ; $ this -> name = $ product -> getName ( ) ; $ this -> status = $ this -> statusFactory -> create ( ) -> getOptionText ( $ product -> getStatus ( ) ) ; $ options = $ this -> visibilityFactory -> create ( ) -> getOptionArray ( ) ; $ this -> visibility = ( string ) $ options [ $ product -> getVisibility ( ) ] ; $ this -> getMinPrices ( $ product ) ; $ this -> url = $ this -> urlFinder -> fetchFor ( $ product ) ; $ this -> imagePath = $ this -> mediaConfigFactory -> create ( ) -> getMediaUrl ( $ product -> getSmallImage ( ) ) ; $ this -> stock = ( float ) number_format ( $ this -> getStockQty ( $ product ) , 2 , '.' , '' ) ; $ shortDescription = $ product -> getShortDescription ( ) ; if ( $ this -> stringUtils -> strlen ( $ shortDescription ) > \ Dotdigitalgroup \ Email \ Helper \ Data :: DM_FIELD_LIMIT ) { $ shortDescription = mb_substr ( $ shortDescription , 0 , \ Dotdigitalgroup \ Email \ Helper \ Data :: DM_FIELD_LIMIT ) ; } $ this -> shortDescription = $ shortDescription ; $ count = 0 ; $ categoryCollection = $ product -> getCategoryCollection ( ) -> addNameToResult ( ) ; foreach ( $ categoryCollection as $ cat ) { $ this -> categories [ $ count ] [ 'Id' ] = $ cat -> getId ( ) ; $ this -> categories [ $ count ] [ 'Name' ] = $ cat -> getName ( ) ; ++ $ count ; } $ count = 0 ; $ websiteIds = $ product -> getWebsiteIds ( ) ; foreach ( $ websiteIds as $ websiteId ) { $ website = $ this -> storeManager -> getWebsite ( $ websiteId ) ; $ this -> websites [ $ count ] [ 'Id' ] = $ website -> getId ( ) ; $ this -> websites [ $ count ] [ 'Name' ] = $ website -> getName ( ) ; ++ $ count ; } $ this -> processProductOptions ( $ product ) ; unset ( $ this -> itemFactory , $ this -> mediaConfigFactory , $ this -> visibilityFactory , $ this -> statusFactory , $ this -> helper , $ this -> storeManager ) ; return $ this ; }
Set the product data .
38,808
private function getMinPrices ( $ product ) { if ( $ product -> getTypeId ( ) == 'configurable' ) { foreach ( $ product -> getTypeInstance ( ) -> getUsedProducts ( $ product ) as $ childProduct ) { $ childPrices [ ] = $ childProduct -> getPrice ( ) ; if ( $ childProduct -> getSpecialPrice ( ) !== null ) { $ childSpecialPrices [ ] = $ childProduct -> getSpecialPrice ( ) ; } } $ this -> price = isset ( $ childPrices ) ? min ( $ childPrices ) : null ; $ this -> specialPrice = isset ( $ childSpecialPrices ) ? min ( $ childSpecialPrices ) : null ; } elseif ( $ product -> getTypeId ( ) == 'bundle' ) { $ this -> price = $ product -> getPriceInfo ( ) -> getPrice ( 'regular_price' ) -> getMinimalPrice ( ) -> getValue ( ) ; $ this -> specialPrice = $ product -> getPriceInfo ( ) -> getPrice ( 'final_price' ) -> getMinimalPrice ( ) -> getValue ( ) ; $ this -> specialPrice = ( $ this -> specialPrice === $ this -> price ) ? null : $ this -> specialPrice ; } elseif ( $ product -> getTypeId ( ) == 'grouped' ) { foreach ( $ product -> getTypeInstance ( ) -> getAssociatedProducts ( $ product ) as $ childProduct ) { $ childPrices [ ] = $ childProduct -> getPrice ( ) ; if ( $ childProduct -> getSpecialPrice ( ) !== null ) { $ childSpecialPrices [ ] = $ childProduct -> getSpecialPrice ( ) ; } } $ this -> price = isset ( $ childPrices ) ? min ( $ childPrices ) : null ; $ this -> specialPrice = isset ( $ childSpecialPrices ) ? min ( $ childSpecialPrices ) : null ; } else { $ this -> price = $ product -> getPrice ( ) ; $ this -> specialPrice = $ product -> getSpecialPrice ( ) ; } $ this -> formatPriceValues ( ) ; }
Set the Minimum Prices for Configurable and Bundle products .
38,809
private function formatPriceValues ( ) { $ this -> price = ( float ) number_format ( $ this -> price , 2 , '.' , '' ) ; $ this -> specialPrice = ( float ) number_format ( $ this -> specialPrice , 2 , '.' , '' ) ; }
Formats the price values .
38,810
public function toOptionArray ( ) { $ visibilities = $ this -> productVisibility -> getAllOptions ( ) ; $ options [ ] = [ 'label' => __ ( '---- Default Option ----' ) , 'value' => '0' , ] ; foreach ( $ visibilities as $ visibility ) { $ options [ ] = [ 'label' => $ visibility [ 'label' ] , 'value' => $ visibility [ 'value' ] , ] ; } return $ options ; }
Return options .
38,811
public function getLoginUserHtml ( ) { $ token = $ this -> generateToken ( ) ; $ baseUrl = $ this -> configFactory -> getLogUserUrl ( ) ; $ loginuserUrl = $ baseUrl . $ token . '&suppressfooter=true' ; return $ loginuserUrl ; }
User login url .
38,812
public function generateToken ( ) { $ adminUser = $ this -> auth -> getUser ( ) ; $ refreshToken = $ adminUser -> getRefreshToken ( ) ; if ( $ refreshToken ) { $ accessToken = $ this -> client -> getAccessToken ( $ this -> configFactory -> getTokenUrl ( ) , $ this -> buildUrlParams ( $ this -> helper -> encryptor -> decrypt ( $ refreshToken ) ) ) ; if ( is_string ( $ accessToken ) ) { return $ accessToken ; } } return false ; }
Generate new token and connect from the admin .
38,813
public function buildUrlParams ( $ refreshToken ) { $ params = 'client_id=' . $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CLIENT_ID ) . '&client_secret=' . $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CLIENT_SECRET_ID ) . '&refresh_token=' . $ refreshToken . '&grant_type=refresh_token' ; return $ params ; }
Build url param .
38,814
public function getAbandonedCartProgramEnrolmentWindow ( $ storeId ) { $ fromTime = $ this -> dateTimeFactory -> create ( [ 'time' => 'now' , 'timezone' => new \ DateTimezone ( 'UTC' ) ] ) ; $ minutes = ( int ) $ this -> helper -> getScopeConfig ( ) -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_LOSTBASKET_ENROL_TO_PROGRAM_INTERVAL , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE , $ storeId ) ; $ interval = $ this -> dateIntervalFactory -> create ( [ 'interval_spec' => sprintf ( 'PT%sM' , $ minutes ) ] ) ; $ fromTime -> sub ( $ interval ) ; $ toTime = clone $ fromTime ; $ fromTime -> sub ( $ this -> dateIntervalFactory -> create ( [ 'interval_spec' => 'PT5M' ] ) ) ; return [ 'from' => $ fromTime -> format ( 'Y-m-d H:i:s' ) , 'to' => $ toTime -> format ( 'Y-m-d H:i:s' ) , 'date' => true , ] ; }
Set time window for abandoned cart program enrolments
38,815
public function exportCatalog ( $ storeId , $ limit ) { $ connectorProducts = [ ] ; $ products = $ this -> getProductsToExport ( $ storeId , $ limit ) ; foreach ( $ products as $ product ) { $ connectorProduct = $ this -> connectorProductFactory -> create ( ) -> setProduct ( $ product ) ; $ connectorProducts [ $ product -> getId ( ) ] = $ connectorProduct -> expose ( ) ; } return $ connectorProducts ; }
Export catalog .
38,816
public function newCustomerAutomation ( $ customer ) { $ email = $ customer -> getEmail ( ) ; $ websiteId = $ customer -> getWebsiteId ( ) ; $ customerId = $ customer -> getId ( ) ; $ store = $ this -> storeManager -> getStore ( $ customer -> getStoreId ( ) ) ; $ storeName = $ store -> getName ( ) ; try { $ apiEnabled = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_API_ENABLED , $ websiteId ) ; $ programId = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER , $ websiteId ) ; if ( $ programId && $ apiEnabled ) { $ this -> setEmail ( $ email ) -> setAutomationType ( \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: AUTOMATION_TYPE_NEW_CUSTOMER ) -> setEnrolmentStatus ( \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: AUTOMATION_STATUS_PENDING ) -> setTypeId ( $ customerId ) -> setWebsiteId ( $ websiteId ) -> setStoreName ( $ storeName ) -> setProgramId ( $ programId ) ; $ this -> automationResource -> save ( $ this ) ; } } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } }
New customer automation
38,817
public function toJSON ( $ pretty = false ) { if ( ! $ pretty ) { return json_encode ( $ this -> expose ( ) ) ; } else { return $ this -> prettyPrint ( json_encode ( $ this -> expose ( ) ) ) ; } }
Returns the object as JSON .
38,818
public function flush ( ) { $ this -> apiUsername = '' ; $ this -> apiPassword = '' ; $ this -> requestBody = null ; $ this -> requestLength = 0 ; $ this -> verb = 'GET' ; $ this -> responseBody = null ; $ this -> responseInfo = null ; return $ this ; }
Reset the client .
38,819
private function executePost ( $ ch ) { if ( ! is_string ( $ this -> requestBody ) ) { $ this -> buildPostBody ( ) ; } curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ this -> requestBody ) ; curl_setopt ( $ ch , CURLOPT_POST , true ) ; $ this -> doExecute ( $ ch ) ; }
Execute post request .
38,820
private function executePut ( $ ch ) { if ( ! is_string ( $ this -> requestBody ) ) { $ this -> buildPostBody ( ) ; } $ this -> requestLength = strlen ( $ this -> requestBody ) ; $ fh = fopen ( 'php://memory' , 'rw' ) ; fwrite ( $ fh , $ this -> requestBody ) ; rewind ( $ fh ) ; curl_setopt ( $ ch , CURLOPT_INFILE , $ fh ) ; curl_setopt ( $ ch , CURLOPT_INFILESIZE , $ this -> requestLength ) ; curl_setopt ( $ ch , CURLOPT_PUT , true ) ; $ this -> doExecute ( $ ch ) ; fclose ( $ fh ) ; }
Execute put .
38,821
private function setCurlOpts ( & $ ch ) { curl_setopt ( $ ch , CURLOPT_TIMEOUT , 60 ) ; curl_setopt ( $ ch , CURLOPT_URL , $ this -> url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYHOST , 0 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , 0 ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , [ 'Accept: ' . $ this -> acceptType , 'Content-Type: application/json' , ] ) ; }
Curl options .
38,822
private function setAuth ( & $ ch ) { if ( $ this -> apiUsername !== null && $ this -> apiPassword !== null ) { curl_setopt ( $ ch , CURLAUTH_BASIC , CURLAUTH_DIGEST ) ; curl_setopt ( $ ch , CURLOPT_USERPWD , $ this -> apiUsername . ':' . $ this -> apiPassword ) ; } }
Basic auth .
38,823
private function registerWishlist ( $ wishlist , $ itemCount , $ customer ) { try { $ emailWishlist = $ this -> wishlistFactory -> create ( ) ; if ( ! $ emailWishlist -> getWishlist ( $ wishlist -> getWishlistId ( ) ) ) { $ storeName = $ this -> storeManager -> getStore ( $ customer -> getStoreId ( ) ) -> getName ( ) ; $ emailWishlist -> setWishlistId ( $ wishlist -> getWishlistId ( ) ) -> setCustomerId ( $ wishlist -> getCustomerId ( ) ) -> setStoreId ( $ customer -> getStoreId ( ) ) -> setItemCount ( $ itemCount ) ; $ this -> emailWishlistResource -> save ( $ emailWishlist ) ; $ this -> registerWithAutomation ( $ wishlist , $ customer , $ storeName ) ; } } catch ( \ Exception $ e ) { $ this -> helper -> error ( ( string ) $ e , [ ] ) ; } }
Register new wishlist .
38,824
public function apply ( $ collection , $ storeId ) { $ ruleModel = $ this -> rulesFactory -> create ( ) ; $ websiteId = $ this -> helper -> storeManager -> getStore ( $ storeId ) -> getWebsiteId ( ) ; return $ ruleModel -> process ( $ collection , \ Dotdigitalgroup \ Email \ Model \ Rules :: ABANDONED , $ websiteId ) ; }
Apply rules to sales collection
38,825
public function execute ( \ Magento \ Framework \ Event \ Observer $ observer ) { try { $ wishlistItem = $ observer -> getEvent ( ) -> getItem ( ) ; $ emailWishlist = $ this -> emailWishlistCollection -> create ( ) -> getWishlistById ( $ wishlistItem -> getWishlistId ( ) ) ; if ( $ emailWishlist ) { $ count = $ emailWishlist -> getItemCount ( ) ; $ emailWishlist -> setItemCount ( -- $ count ) ; $ emailWishlist -> setWishlistModified ( 1 ) ; $ this -> emailWishlistResource -> save ( $ emailWishlist ) ; } } catch ( \ Exception $ e ) { $ this -> helper -> log ( ( string ) $ e , [ ] ) ; } }
Delete wishlist item event .
38,826
public function joinTablesOnCollectionByType ( $ collection , $ type ) { if ( $ type == \ Dotdigitalgroup \ Email \ Model \ Rules :: ABANDONED ) { $ collection -> getSelect ( ) -> joinLeft ( [ 'quote_address' => $ this -> getTable ( 'quote_address' ) ] , 'main_table.entity_id = quote_address.quote_id' , [ 'shipping_method' , 'country_id' , 'city' , 'region_id' ] ) -> joinLeft ( [ 'quote_payment' => $ this -> getTable ( 'quote_payment' ) ] , 'main_table.entity_id = quote_payment.quote_id' , [ 'method' ] ) -> where ( 'address_type = ?' , 'shipping' ) ; } elseif ( $ type == \ Dotdigitalgroup \ Email \ Model \ Rules :: REVIEW ) { $ collection -> getSelect ( ) -> join ( [ 'order_address' => $ this -> getTable ( 'sales_order_address' ) ] , 'main_table.entity_id = order_address.parent_id' , [ 'country_id' , 'city' , 'region_id' ] ) -> join ( [ 'order_payment' => $ this -> getTable ( 'sales_order_payment' ) ] , 'main_table.entity_id = order_payment.parent_id' , [ 'method' ] ) -> where ( 'order_address.address_type = ?' , 'shipping' ) ; } return $ collection ; }
Join tables on collection by type .
38,827
private function _getAddressBook ( $ importType , $ websiteId ) { switch ( $ importType ) { case \ Dotdigitalgroup \ Email \ Model \ Importer :: IMPORT_TYPE_CONTACT : $ addressBook = $ this -> helper -> getCustomerAddressBook ( $ websiteId ) ; break ; case \ Dotdigitalgroup \ Email \ Model \ Importer :: IMPORT_TYPE_SUBSCRIBERS : $ addressBook = $ this -> helper -> getSubscriberAddressBook ( $ websiteId ) ; break ; case \ Dotdigitalgroup \ Email \ Model \ Importer :: IMPORT_TYPE_GUEST : $ addressBook = $ this -> helper -> getGuestAddressBook ( $ websiteId ) ; break ; default : $ addressBook = '' ; } return $ addressBook ; }
Get addressbook by import type .
38,828
private function getStoreQuotesForGuestsAndCustomers ( $ storeId , $ updated ) { $ salesCollection = $ this -> orderCollection -> create ( ) -> getStoreQuotesForGuestsAndCustomers ( $ storeId , $ updated ) ; $ this -> rules -> apply ( $ salesCollection , $ storeId ) ; return $ salesCollection ; }
Retrieve store quotes
38,829
public function afterCreate ( \ Magento \ Sales \ Api \ OrderCustomerManagementInterface $ subject , $ customer ) { $ this -> automation -> newCustomerAutomation ( $ customer ) ; return $ customer ; }
Plugin for create function .
38,830
public function generateCoupon ( ) { $ params = $ this -> getRequest ( ) -> getParams ( ) ; if ( ! isset ( $ params [ 'code' ] ) || ! $ this -> helper -> isCodeValid ( $ params [ 'code' ] ) ) { return false ; } $ priceRuleId = ( int ) $ params [ 'id' ] ; $ expireDate = false ; if ( isset ( $ params [ 'expire_days' ] ) && is_numeric ( $ params [ 'expire_days' ] ) && $ params [ 'expire_days' ] > 0 ) { $ days = ( int ) $ params [ 'expire_days' ] ; $ expireDate = $ this -> _localeDate -> date ( ) -> add ( $ this -> dateIntervalFactory -> create ( [ 'interval_spec' => sprintf ( 'P%sD' , $ days ) ] ) ) ; } return $ this -> dotmailerCouponGenerator -> generateCoupon ( $ priceRuleId , $ expireDate ) ; }
Generates the coupon code based on the code id .
38,831
public function beforeSave ( ) { parent :: beforeSave ( ) ; if ( $ this -> isObjectNew ( ) && ! $ this -> getCreatedAt ( ) ) { $ this -> setCreatedAt ( $ this -> dateTime -> formatDate ( true ) ) ; } $ this -> setUpdatedAt ( $ this -> dateTime -> formatDate ( true ) ) ; return $ this ; }
Prepare data to be saved to database .
38,832
public function sync ( ) { $ response = [ 'success' => true , 'message' => 'Done.' ] ; $ this -> start = microtime ( true ) ; $ countProducts = $ this -> syncCatalog ( ) ; if ( $ countProducts ) { $ message = '----------- Catalog sync ----------- : ' . gmdate ( 'H:i:s' , microtime ( true ) - $ this -> start ) . ', Total synced = ' . $ countProducts ; $ this -> helper -> log ( $ message ) ; $ response [ 'message' ] = $ message ; } return $ response ; }
Catalog sync .
38,833
public function syncCatalog ( ) { try { $ this -> catalogResourceFactory -> create ( ) -> removeOrphanProducts ( ) ; return $ this -> catalogSyncFactory -> create ( ) -> sync ( ) ; } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } }
Sync product catalogs
38,834
public function renderCellTemplate ( $ columnName ) { if ( $ columnName == 'attribute' ) { return $ this -> _getAttributeRenderer ( ) -> setName ( $ this -> _getCellInputElementName ( $ columnName ) ) -> setTitle ( $ columnName ) -> setClass ( $ this -> className ) -> setOptions ( $ this -> getElement ( ) -> getValues ( ) ) -> toHtml ( ) ; } elseif ( $ columnName == 'conditions' ) { return $ this -> _getConditionsRenderer ( ) -> setName ( $ this -> _getCellInputElementName ( $ columnName ) ) -> setTitle ( $ columnName ) -> setClass ( $ this -> className ) -> setOptions ( $ this -> condition -> toOptionArray ( ) ) -> toHtml ( ) ; } elseif ( $ columnName == 'cvalue' ) { return $ this -> _getValueRenderer ( ) -> setName ( $ this -> _getCellInputElementName ( $ columnName ) ) -> setTitle ( $ columnName ) -> setClass ( $ this -> className ) -> setOptions ( $ this -> value -> toOptionArray ( ) ) -> toHtml ( ) ; } return parent :: renderCellTemplate ( $ columnName ) ; }
render cell template .
38,835
private function _getAttributeRenderer ( ) { if ( ! $ this -> getAttributeRenderer ) { $ this -> getAttributeRenderer = $ this -> getLayout ( ) -> createBlock ( \ Dotdigitalgroup \ Email \ Block \ Adminhtml \ Config \ Select :: class , '' , [ 'data' => [ 'is_render_to_js_template' => true ] ] ) ; } return $ this -> getAttributeRenderer ; }
Get rendered for attribute field .
38,836
private function _getConditionsRenderer ( ) { if ( ! $ this -> getConditionsRenderer ) { $ this -> getConditionsRenderer = $ this -> getLayout ( ) -> createBlock ( \ Dotdigitalgroup \ Email \ Block \ Adminhtml \ Config \ Select :: class , '' , [ 'data' => [ 'is_render_to_js_template' => true ] ] ) ; } return $ this -> getConditionsRenderer ; }
Get renderer for conditions field .
38,837
private function _getValueRenderer ( ) { if ( ! $ this -> getValueRenderer ) { $ this -> getValueRenderer = $ this -> getLayout ( ) -> createBlock ( \ Dotdigitalgroup \ Email \ Block \ Adminhtml \ Config \ Select :: class , '' , [ 'data' => [ 'is_render_to_js_template' => true ] ] ) ; } return $ this -> getValueRenderer ; }
Get renderer for value field .
38,838
public function getWishlistById ( $ wishListId ) { $ collection = $ this -> addFieldToFilter ( 'wishlist_id' , $ wishListId ) -> setPageSize ( 1 ) ; if ( $ collection -> getSize ( ) ) { return $ collection -> getFirstItem ( ) ; } return false ; }
Get the collection first item .
38,839
private function checkAndCreateAbandonedCart ( $ setup , $ context ) { $ connection = $ setup -> getConnection ( ) ; $ abandonedCartTableName = $ setup -> getTable ( Schema :: EMAIL_ABANDONED_CART_TABLE ) ; if ( version_compare ( $ context -> getVersion ( ) , '2.3.8' , '>' ) && ! $ connection -> isTableExists ( $ abandonedCartTableName ) ) { $ this -> shared -> createAbandonedCartTable ( $ setup , $ abandonedCartTableName ) ; } }
Create table for abandoned carts if doesn t exists between two versions .
38,840
public function getAuthoriseUrl ( ) { $ clientId = $ this -> _scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CLIENT_ID ) ; $ redirectUri = $ this -> helper -> getRedirectUri ( ) ; $ redirectUri .= 'connector/email/callback' ; $ adminUser = $ this -> auth -> getUser ( ) ; $ params = [ 'redirect_uri' => $ redirectUri , 'scope' => 'Account' , 'state' => $ adminUser -> getId ( ) , 'response_type' => 'code' , ] ; $ authorizeBaseUrl = $ this -> configHelper -> getAuthorizeLink ( ) ; $ url = $ authorizeBaseUrl . http_build_query ( $ params ) . '&client_id=' . $ clientId ; return $ url ; }
Autorisation url for OAUTH .
38,841
public function fetchFor ( $ product ) { $ product = $ this -> getScopedProduct ( $ product ) ; if ( $ product -> getVisibility ( ) == \ Magento \ Catalog \ Model \ Product \ Visibility :: VISIBILITY_NOT_VISIBLE && $ product -> getTypeId ( ) == \ Magento \ Catalog \ Model \ Product \ Type :: TYPE_SIMPLE ) { $ parentId = $ this -> getFirstParentId ( $ product ) ; if ( isset ( $ parentId ) ) { $ parentProduct = $ this -> productRepository -> getById ( $ parentId , false , $ product -> getStoreId ( ) ) ; return $ parentProduct -> getProductUrl ( ) ; } } return $ product -> getProductUrl ( ) ; }
Fetch a URL for a product depending on its visibility and type .
38,842
private function getScopedProduct ( $ product ) { if ( ! in_array ( $ product -> getStoreId ( ) , $ product -> getStoreIds ( ) ) ) { $ productInWebsites = $ product -> getWebsiteIds ( ) ; $ firstWebsite = $ this -> storeManager -> getWebsite ( $ productInWebsites [ 0 ] ) ; $ storeId = ( int ) $ firstWebsite -> getDefaultGroup ( ) -> getDefaultStoreId ( ) ; return $ this -> productRepository -> getById ( $ product -> getId ( ) , false , $ storeId ) ; } return $ product ; }
In default - level catalog sync the supplied Product s store ID can be 1 even though the product is not in store 1 This method finds the default store of the first website the product belongs to and uses that to get a new product .
38,843
public function resetWishlists ( $ from = null , $ to = null ) { $ conn = $ this -> getConnection ( ) ; if ( $ from && $ to ) { $ where = [ 'created_at >= ?' => $ from . ' 00:00:00' , 'created_at <= ?' => $ to . ' 23:59:59' , 'wishlist_imported is ?' => new \ Zend_Db_Expr ( 'not null' ) ] ; } else { $ where = $ conn -> quoteInto ( 'wishlist_imported is ?' , new \ Zend_Db_Expr ( 'not null' ) ) ; } $ num = $ conn -> update ( $ this -> getTable ( Schema :: EMAIL_WISHLIST_TABLE ) , [ 'wishlist_imported' => new \ Zend_Db_Expr ( 'null' ) , 'wishlist_modified' => new \ Zend_Db_Expr ( 'null' ) , ] , $ where ) ; return $ num ; }
Reset the email wishlist for re - import .
38,844
public function processAbandonedCarts ( ) { $ result = [ ] ; $ stores = $ this -> helper -> getStores ( ) ; $ this -> acPendingContactUpdater -> update ( ) ; foreach ( $ stores as $ store ) { $ storeId = $ store -> getId ( ) ; $ websiteId = $ store -> getWebsiteId ( ) ; $ result = $ this -> processAbandonedCartsForCustomers ( $ storeId , $ websiteId , $ result ) ; $ result = $ this -> processAbandonedCartsForGuests ( $ storeId , $ websiteId , $ result ) ; } return $ result ; }
Process abandoned carts .
38,845
private function processAbandonedCartsForCustomers ( $ storeId , $ websiteId , $ result ) { $ secondCustomerEnabled = $ this -> isLostBasketCustomerEnabled ( self :: CUSTOMER_LOST_BASKET_TWO , $ storeId ) ; $ thirdCustomerEnabled = $ this -> isLostBasketCustomerEnabled ( self :: CUSTOMER_LOST_BASKET_THREE , $ storeId ) ; if ( $ this -> isLostBasketCustomerEnabled ( self :: CUSTOMER_LOST_BASKET_ONE , $ storeId ) || $ secondCustomerEnabled || $ thirdCustomerEnabled ) { $ result [ $ storeId ] [ 'firstCustomer' ] = $ this -> processCustomerFirstAbandonedCart ( $ storeId ) ; } if ( $ secondCustomerEnabled ) { $ result [ $ storeId ] [ 'secondCustomer' ] = $ this -> processExistingAbandonedCart ( $ this -> getLostBasketCustomerCampaignId ( self :: CUSTOMER_LOST_BASKET_TWO , $ storeId ) , $ storeId , $ websiteId , self :: CUSTOMER_LOST_BASKET_TWO ) ; } if ( $ thirdCustomerEnabled ) { $ result [ $ storeId ] [ 'thirdCustomer' ] = $ this -> processExistingAbandonedCart ( $ this -> getLostBasketCustomerCampaignId ( self :: CUSTOMER_LOST_BASKET_THREE , $ storeId ) , $ storeId , $ websiteId , self :: CUSTOMER_LOST_BASKET_THREE ) ; } return $ result ; }
Process abandoned carts for customer
38,846
private function processAbandonedCartsForGuests ( $ storeId , $ websiteId , $ result ) { $ secondGuestEnabled = $ this -> isLostBasketGuestEnabled ( self :: GUEST_LOST_BASKET_TWO , $ storeId ) ; $ thirdGuestEnabled = $ this -> isLostBasketGuestEnabled ( self :: GUEST_LOST_BASKET_THREE , $ storeId ) ; if ( $ this -> isLostBasketGuestEnabled ( self :: GUEST_LOST_BASKET_ONE , $ storeId ) || $ secondGuestEnabled || $ thirdGuestEnabled ) { $ result [ $ storeId ] [ 'firstGuest' ] = $ this -> processGuestFirstAbandonedCart ( $ storeId ) ; } if ( $ secondGuestEnabled ) { $ result [ $ storeId ] [ 'secondGuest' ] = $ this -> processExistingAbandonedCart ( $ this -> getLostBasketGuestCampaignId ( self :: GUEST_LOST_BASKET_TWO , $ storeId ) , $ storeId , $ websiteId , self :: GUEST_LOST_BASKET_TWO , true ) ; } if ( $ thirdGuestEnabled ) { $ result [ $ storeId ] [ 'thirdGuest' ] = $ this -> processExistingAbandonedCart ( $ this -> getLostBasketGuestCampaignId ( self :: GUEST_LOST_BASKET_THREE , $ storeId ) , $ storeId , $ websiteId , self :: GUEST_LOST_BASKET_THREE , true ) ; } return $ result ; }
Process abandoned carts for guests
38,847
public function isIntervalCampaignFound ( $ email , $ storeId ) { $ cartLimit = $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ABANDONED_CART_LIMIT , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE , $ storeId ) ; if ( ! $ cartLimit ) { return false ; } $ fromTime = $ this -> timeZone -> scopeDate ( $ storeId , 'now' , true ) ; $ toTime = clone $ fromTime ; $ interval = $ this -> dateIntervalFactory -> create ( [ 'interval_spec' => sprintf ( 'PT%sH' , $ cartLimit ) ] ) ; $ fromTime -> sub ( $ interval ) ; $ fromDate = $ fromTime -> getTimestamp ( ) ; $ toDate = $ toTime -> getTimestamp ( ) ; $ updated = [ 'from' => $ fromDate , 'to' => $ toDate , 'date' => true , ] ; $ campaignLimit = $ this -> campaignCollection -> create ( ) -> getNumberOfCampaignsForContactByInterval ( $ email , $ updated ) ; if ( $ campaignLimit ) { return true ; } return false ; }
Send email only if the interval limit passed no emails during this interval . Return false for any found for this period .
38,848
public function getAuthorizeLink ( $ website = 0 ) { if ( $ this -> isAuthorizeCustomDomain ( $ website ) ) { $ baseUrl = $ this -> getWebsiteConfig ( self :: XML_PATH_CONNECTOR_CUSTOM_DOMAIN ) . self :: API_CONNECTOR_OAUTH_URL_AUTHORISE ; } else { $ baseUrl = $ this -> getRegionAuthorize ( $ website ) . self :: API_CONNECTOR_OAUTH_URL_AUTHORISE ; } return $ baseUrl ; }
Authorization link for OAUTH .
38,849
private function isAuthorizeCustomDomain ( $ website = 0 ) { $ website = $ this -> storeManager -> getWebsite ( $ website ) ; $ customDomain = $ website -> getConfig ( self :: XML_PATH_CONNECTOR_CUSTOM_DOMAIN ) ; return ( bool ) $ customDomain ; }
Is authorization link for custom domain set .
38,850
private function getRegionAuthorize ( $ website ) { $ website = $ this -> storeManager -> getWebsite ( $ website ) ; $ apiEndpoint = $ this -> getWebsiteConfig ( self :: PATH_FOR_API_ENDPOINT , $ website ) . '/' ; $ regionBaseUrl = str_replace ( 'api' , 'app' , $ apiEndpoint ) ; return $ regionBaseUrl ; }
Region aware authorize link .
38,851
public function getCallbackUrl ( ) { if ( $ callback = $ this -> scopeConfig -> getValue ( self :: XML_PATH_CONNECTOR_CUSTOM_AUTHORIZATION ) ) { return $ callback ; } return $ this -> storeManager -> getStore ( ) -> getBaseUrl ( \ Magento \ Framework \ UrlInterface :: URL_TYPE_WEB , true ) ; }
Callback authorization url .
38,852
public function getTokenUrl ( $ website = 0 ) { if ( $ this -> isAuthorizeCustomDomain ( $ website ) ) { $ website = $ this -> storeManager -> getWebsite ( $ website ) ; $ tokenUrl = $ website -> getConfig ( self :: XML_PATH_CONNECTOR_CUSTOM_DOMAIN ) . self :: API_CONNECTOR_OAUTH_URL_TOKEN ; } else { $ tokenUrl = $ this -> getRegionAuthorize ( $ website ) . self :: API_CONNECTOR_OAUTH_URL_TOKEN ; } return $ tokenUrl ; }
Token url for OAUTH .
38,853
public function getLogUserUrl ( $ website = 0 ) { if ( $ this -> isAuthorizeCustomDomain ( $ website ) ) { $ logUserUrl = $ this -> getWebsiteConfig ( self :: XML_PATH_CONNECTOR_CUSTOM_DOMAIN ) . self :: API_CONNECTOR_OAUTH_URL_LOG_USER ; } else { $ logUserUrl = $ this -> getRegionAuthorize ( $ website ) . self :: API_CONNECTOR_OAUTH_URL_LOG_USER ; } return $ logUserUrl ; }
Get login user url with for OAUTH .
38,854
public function isEnabled ( $ website = 0 ) { $ website = $ this -> storeManager -> getWebsite ( $ website ) ; $ enabled = $ this -> scopeConfig -> isSetFlag ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_API_ENABLED , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ website ) ; $ apiUsername = $ this -> getApiUsername ( $ website ) ; $ apiPassword = $ this -> getApiPassword ( $ website ) ; if ( ! $ apiUsername || ! $ apiPassword || ! $ enabled ) { return false ; } return true ; }
Get api creadentials enabled .
38,855
public function auth ( $ authRequest ) { if ( $ authRequest != $ this -> scopeConfig -> getValue ( Config :: XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE ) ) { return false ; } return true ; }
Passcode for dynamic content liks .
38,856
public function isIpAllowed ( ) { if ( $ ipString = $ this -> getConfigValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_IP_RESTRICTION_ADDRESSES , 'default' ) ) { $ ipArray = explode ( ',' , $ ipString ) ; foreach ( $ ipArray as $ key => $ ip ) { $ ipArray [ $ key ] = trim ( $ ip ) ; } $ ipAddress = $ this -> _remoteAddress -> getRemoteAddress ( ) ; if ( in_array ( $ ipAddress , $ ipArray ) ) { return true ; } } else { return true ; } $ this -> log ( sprintf ( "Failed to authenticate IP address - %s" , $ ipAddress ) ) ; return false ; }
Check for IP address to match the ones from config .
38,857
public function getConfigValue ( $ path , $ contextScope = 'default' , $ contextScopeId = null ) { $ config = $ this -> scopeConfig -> getValue ( $ path , $ contextScope , $ contextScopeId ) ; return $ config ; }
Get config scope value .
38,858
public function getWebsite ( ) { $ websiteId = $ this -> _request -> getParam ( 'website' , false ) ; if ( $ websiteId ) { return $ this -> storeManager -> getWebsite ( $ websiteId ) ; } return $ this -> storeManager -> getWebsite ( ) ; }
Get website selected in admin .
38,859
public function getWebsiteForSelectedScopeInAdmin ( ) { $ storeId = $ this -> _request -> getParam ( 'store' ) ; $ websiteId = ( $ storeId ) ? $ this -> storeManager -> getStore ( $ storeId ) -> getWebsiteId ( ) : $ this -> _request -> getParam ( 'website' , 0 ) ; return $ this -> storeManager -> getWebsite ( $ websiteId ) ; }
Get website for selected scope in admin
38,860
public function getPasscode ( ) { $ websiteId = ( int ) $ this -> _request -> getParam ( 'website' , false ) ; $ scope = 'default' ; $ scopeId = '0' ; if ( $ websiteId ) { $ scope = 'website' ; $ scopeId = $ websiteId ; } $ passcode = $ this -> getConfigValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE , $ scope , $ scopeId ) ; return $ passcode ; }
Get passcode from config .
38,861
public function saveConfigData ( $ path , $ value , $ scope , $ scopeId ) { $ this -> resourceConfig -> saveConfig ( $ path , $ value , $ scope , $ scopeId ) ; }
Save config data .
38,862
public function disableTransactionalDataConfig ( $ scope , $ scopeId ) { $ this -> resourceConfig -> saveConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED , 0 , $ scope , $ scopeId ) ; }
Disable wishlist sync .
38,863
public function isRoiTrackingEnabled ( ) { return ( bool ) $ this -> scopeConfig -> isSetFlag ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED ) ; }
Is the Roi page tracking enabled .
38,864
public function getMappedStoreName ( \ Magento \ Store \ Model \ Website $ website ) { $ mapped = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_MAPPING_CUSTOMER_STORENAME ) ; $ storeName = ( $ mapped ) ? $ mapped : '' ; return $ storeName ; }
Store name datafield .
38,865
public function getContactId ( $ email , $ websiteId ) { if ( ! $ this -> isEnabled ( $ websiteId ) ) { return false ; } $ contactFromTable = $ this -> getContactByEmail ( $ email , $ websiteId ) ; if ( $ contactId = $ contactFromTable -> getContactId ( ) ) { return $ contactId ; } $ contact = $ this -> getContact ( $ email , $ websiteId , $ contactFromTable ) ; if ( $ contact && isset ( $ contact -> id ) ) { return $ contact -> id ; } return false ; }
Get the contact id for the customer based on website id .
38,866
public function getWebsiteApiClient ( $ website = 0 , $ username = '' , $ password = '' ) { if ( $ username && $ password ) { $ apiUsername = $ username ; $ apiPassword = $ password ; } else { $ apiUsername = $ this -> getApiUsername ( $ website ) ; $ apiPassword = $ this -> getApiPassword ( $ website ) ; } $ client = $ this -> clientFactory -> create ( ) ; $ client -> setApiUsername ( $ apiUsername ) -> setApiPassword ( $ apiPassword ) ; $ websiteId = $ this -> storeManager -> getWebsite ( $ website ) -> getId ( ) ; $ apiEndpoint = $ this -> getApiEndpoint ( $ websiteId , $ client ) ; if ( $ apiEndpoint ) { $ client -> setApiEndpoint ( $ apiEndpoint ) ; } return $ client ; }
Api client by website .
38,867
public function getApiEndpoint ( $ websiteId , $ client ) { $ apiEndpoint = $ this -> getApiEndPointFromConfig ( $ websiteId ) ; if ( ! $ apiEndpoint ) { $ apiEndpoint = $ this -> getApiEndPointFromApi ( $ client ) ; if ( $ apiEndpoint ) { $ this -> saveApiEndpoint ( $ apiEndpoint , $ websiteId ) ; } } return $ apiEndpoint ; }
Get Api endPoint
38,868
public function getApiEndPointFromApi ( $ client ) { $ accountInfo = $ client -> getAccountInfo ( ) ; $ apiEndpoint = false ; if ( is_object ( $ accountInfo ) && ! isset ( $ accountInfo -> message ) ) { foreach ( $ accountInfo -> properties as $ property ) { if ( $ property -> name == 'ApiEndpoint' && ! empty ( $ property -> value ) ) { $ apiEndpoint = $ property -> value ; break ; } } } return $ apiEndpoint ; }
Get api end point from api
38,869
public function getApiEndPointFromConfig ( $ websiteId ) { if ( $ websiteId > 0 ) { $ apiEndpoint = $ this -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: PATH_FOR_API_ENDPOINT , $ websiteId ) ; } else { $ apiEndpoint = $ this -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: PATH_FOR_API_ENDPOINT , $ websiteId , ScopeConfigInterface :: SCOPE_TYPE_DEFAULT ) ; } return $ apiEndpoint ; }
Get api end point for given website
38,870
public function saveApiEndpoint ( $ apiEndpoint , $ websiteId ) { if ( $ websiteId > 0 ) { $ scope = \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE ; } else { $ scope = ScopeConfigInterface :: SCOPE_TYPE_DEFAULT ; } $ this -> writer -> save ( \ Dotdigitalgroup \ Email \ Helper \ Config :: PATH_FOR_API_ENDPOINT , $ apiEndpoint , $ scope , $ websiteId ) ; }
Save api endpoint into config .
38,871
public function getCustomerAddressBook ( $ website = 0 ) { $ website = $ this -> storeManager -> getWebsite ( $ website ) ; return $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ website ) ; }
Get the addres book for customer .
38,872
public function getSubscriberAddressBook ( $ website ) { $ website = $ this -> storeManager -> getWebsite ( $ website ) ; return $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ website -> getId ( ) ) ; }
Subscriber address book .
38,873
public function getGuestAddressBook ( $ website ) { $ website = $ this -> storeManager -> getWebsite ( $ website ) ; return $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ website -> getid ( ) ) ; }
Guest address book .
38,874
public function getCustomAttributes ( $ website = 0 ) { $ attr = $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_MAPPING_CUSTOM_DATAFIELDS , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ website -> getId ( ) ) ; if ( ! $ attr ) { return [ ] ; } return $ this -> serializer -> unserialize ( $ attr ) ; }
Get custom datafield mapped .
38,875
public function getConfigSelectedStatus ( $ website = 0 ) { $ status = $ this -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_ORDER_STATUS , $ website ) ; if ( $ status ) { return explode ( ',' , $ status ) ; } else { return false ; } }
Order status config value .
38,876
public function getConfigSelectedCustomOrderAttributes ( $ website = 0 ) { $ customAttributes = $ this -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES , $ website ) ; if ( $ customAttributes ) { return explode ( ',' , $ customAttributes ) ; } else { return false ; } }
Get array of custom attributes for orders from config .
38,877
public function setConnectorContactToReImport ( $ customerId ) { $ contactModel = $ this -> contactFactory -> create ( ) ; $ contactModel -> loadByCustomerId ( $ customerId ) -> setEmailImported ( \ Dotdigitalgroup \ Email \ Model \ Contact :: EMAIL_CONTACT_NOT_IMPORTED ) ; $ this -> contactResource -> save ( $ contactModel ) ; }
Mark contact for reimport .
38,878
public function disableConfigForWebsite ( $ path ) { $ scopeId = 0 ; if ( $ website = $ this -> _request -> getParam ( 'website' ) ) { $ scope = 'websites' ; $ scopeId = $ this -> storeManager -> getWebsite ( $ website ) -> getId ( ) ; } else { $ scope = 'default' ; } $ this -> resourceConfig -> saveConfig ( $ path , 0 , $ scope , $ scopeId ) ; }
Disable website config when the request is made admin area only!
38,879
public function getCustomersWithDuplicateEmails ( ) { $ customers = $ this -> customerFactory -> create ( ) -> getCollection ( ) ; $ customers -> getSelect ( ) -> columns ( [ 'emails' => 'COUNT(e.entity_id)' ] ) -> group ( 'email' ) -> having ( 'emails > ?' , 1 ) ; return $ customers ; }
Number of customers with duplicate emails emails as total number .
38,880
public function generateDynamicUrl ( ) { $ website = $ this -> _request -> getParam ( 'website' , false ) ; $ website = ( $ website ) ? $ this -> storeManager -> getWebsite ( $ website ) : 0 ; $ defaultGroup = $ this -> storeManager -> getWebsite ( $ website ) -> getDefaultGroup ( ) ; if ( ! $ defaultGroup ) { return $ this -> storeManager -> getStore ( ) -> getBaseUrl ( \ Magento \ Framework \ UrlInterface :: URL_TYPE_WEB ) ; } $ baseUrl = $ this -> storeManager -> getStore ( $ defaultGroup -> getDefaultStore ( ) ) -> getBaseUrl ( \ Magento \ Framework \ UrlInterface :: URL_TYPE_LINK ) ; return $ baseUrl ; }
Generate the baseurl for the default store dynamic content will be displayed .
38,881
public function getOrderTableDescription ( ) { $ salesTable = $ this -> adapter -> getTableName ( 'sales_order' ) ; $ adapter = $ this -> adapter -> getConnection ( 'sales' ) ; $ columns = $ adapter -> describeTable ( $ salesTable ) ; return $ columns ; }
get sales_flat_order table description .
38,882
public function updateDataFields ( $ email , $ website , $ storeName ) { $ data = [ ] ; if ( $ storeNameKey = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME ) ) { $ data [ ] = [ 'Key' => $ storeNameKey , 'Value' => $ storeName , ] ; } if ( $ websiteName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME ) ) { $ data [ ] = [ 'Key' => $ websiteName , 'Value' => $ website -> getName ( ) , ] ; } if ( ! empty ( $ data ) ) { if ( $ this -> isEnabled ( $ website ) ) { $ client = $ this -> getWebsiteApiClient ( $ website ) ; $ client -> updateContactDatafieldsByEmail ( $ email , $ data ) ; } } }
Update data fields .
38,883
public function updateLastQuoteId ( $ quoteId , $ email , $ websiteId ) { if ( $ this -> isEnabled ( $ websiteId ) ) { $ client = $ this -> getWebsiteApiClient ( $ websiteId ) ; $ quoteIdField = $ this -> getLastQuoteId ( ) ; $ data [ ] = [ 'Key' => $ quoteIdField , 'Value' => $ quoteId , ] ; $ client -> updateContactDatafieldsByEmail ( $ email , $ data ) ; } }
Update last quote id datafield .
38,884
public function isOrderSyncEnabled ( $ websiteId = 0 ) { return $ this -> scopeConfig -> isSetFlag ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ websiteId ) ; }
Get order sync enabled value from configuration .
38,885
public function isCatalogSyncEnabled ( $ websiteId = 0 ) { return $ this -> scopeConfig -> isSetFlag ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_CATALOG_ENABLED , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ websiteId ) ; }
Get the catalog sync enabled value from config .
38,886
public function isCustomerSyncEnabled ( $ website = 0 ) { $ website = $ this -> storeManager -> getWebsite ( $ website ) ; return $ this -> scopeConfig -> isSetFlag ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_CUSTOMER_ENABLED , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ website ) ; }
Customer sync enabled .
38,887
public function getSyncLimit ( $ website = 0 ) { $ website = $ this -> storeManager -> getWebsite ( $ website ) ; return $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_LIMIT , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ website ) ; }
Customer sync size limit .
38,888
public function isGuestSyncEnabled ( $ websiteId = 0 ) { return $ this -> scopeConfig -> isSetFlag ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_GUEST_ENABLED , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ websiteId ) ; }
Get the guest sync enabled value .
38,889
public function isSubscriberSyncEnabled ( $ websiteId = 0 ) { return $ this -> scopeConfig -> getValue ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_WEBSITE , $ websiteId ) ; }
Is subscriber sync enabled .
38,890
public function getAutomationIdByType ( $ automationType , $ storeId = 0 ) { $ path = constant ( EmailConfig :: class . '::' . $ automationType ) ; $ automationCampaignId = $ this -> scopeConfig -> getValue ( $ path , \ Magento \ Store \ Model \ ScopeInterface :: SCOPE_STORE , $ storeId ) ; return $ automationCampaignId ; }
Get the config id by the automation type .
38,891
public function updateAbandonedProductName ( $ name , $ email , $ websiteId ) { if ( $ this -> isEnabled ( $ websiteId ) ) { $ client = $ this -> getWebsiteApiClient ( $ websiteId ) ; $ field = $ this -> getAbandonedProductName ( ) ; if ( $ field ) { $ data [ ] = [ 'Key' => $ field , 'Value' => $ name , ] ; $ client -> updateContactDatafieldsByEmail ( $ email , $ data ) ; } } }
Api - update the product name most expensive .
38,892
public function getApiResponseTimeLimit ( $ websiteId = 0 ) { $ website = $ this -> storeManager -> getWebsite ( $ websiteId ) ; $ limit = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_DEBUG_API_REQUEST_LIMIT ) ; return $ limit ; }
Trigger log for api calls longer then config value .
38,893
public function getReviewReminderAnchor ( $ website ) { return $ this -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_AUTOMATION_REVIEW_ANCHOR , $ website ) ; }
Product review from config to link the product link .
38,894
public function getReviewDisplayType ( $ website ) { return $ this -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_DYNAMIC_CONTENT_REVIEW_DISPLAY_TYPE , $ website ) ; }
Get display type for review product .
38,895
public function getDelay ( $ website ) { return $ this -> getReviewWebsiteSettings ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_REVIEW_DELAY , $ website ) ; }
Get review setting delay time .
38,896
public function isNewProductOnly ( $ website ) { return $ this -> getReviewWebsiteSettings ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_REVIEW_NEW_PRODUCT , $ website ) ; }
Is the review new product enabled .
38,897
public function getCampaign ( $ website ) { return $ this -> getReviewWebsiteSettings ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_REVIEW_CAMPAIGN , $ website ) ; }
Get review campaign for automation review .
38,898
public function getAnchor ( $ website ) { return $ this -> getReviewWebsiteSettings ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_REVIEW_ANCHOR , $ website ) ; }
Get review anchor value .
38,899
public function getDisplayType ( $ website ) { return $ this -> getReviewWebsiteSettings ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_REVIEW_DISPLAY_TYPE , $ website ) ; }
Get review display type .