idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
38,700
public function enable ( ) { $ configModel = new Configuration ( ) ; $ this -> enable = $ configModel -> getConfiguration ( self :: CONFIG_KEY ) ; return $ this -> enable ; }
Get the Name of the Shipping Option .
38,701
public function amount ( ) { $ orderData = Session :: get ( 'order_data' ) ; $ cartProducts = Session :: get ( 'cart' ) ; $ this -> process ( $ orderData , $ cartProducts ) ; return $ this -> amount ; }
Calculate and Return the Amount .
38,702
public function calculate ( $ checkoutFormData ) { $ view = view ( $ this -> view ) -> with ( 'shippingOption' , $ this ) ; return $ view -> render ( ) ; }
Calculate the cost of Shipping based on Checkout Form Data .
38,703
public function sortable ( $ order = null ) { if ( null === $ order ) { return $ this -> sortable ; } $ this -> sortable = $ order ; return $ this ; }
Get the Column Type .
38,704
public function identifier ( $ identifier = null ) { if ( null === $ identifier ) { return $ this -> identifier ; } $ this -> identifier = $ identifier ; return $ this ; }
Get the column identifier .
38,705
public function column ( $ identifier , $ options = [ ] ) : self { if ( is_callable ( $ options ) ) { $ column = new TextColumn ( $ identifier , $ options ) ; } else { $ column = new TextColumn ( $ identifier , $ options ) ; } $ this -> columns -> put ( $ identifier , $ column ) ; return $ this ; }
Add Text Columns to the DataGrid Columns .
38,706
public function pageName ( $ pageName = null ) { if ( null === $ pageName ) { return $ this -> pageName ; } $ this -> pageName = $ pageName ; return $ this ; }
Page Name method is used in the event if we want to customize the page request param It is important in the event of multiple datagrid on same page .
38,707
public function getTranslation ( $ languageId = null ) { $ languageId = request ( ) -> get ( 'language_id' ) ; if ( null === $ languageId ) { return $ this ; } else { return $ this -> translations ( ) -> whereLanguageId ( $ languageId ) -> first ( ) ; } }
Category Model Get Translation Model and return the value
38,708
public function boot ( ) { $ activeTheme = 'avored-default' ; $ dbConnectError = false ; try { DB :: connection ( ) -> getPdo ( ) ; } catch ( \ Exception $ e ) { $ dbConnectError = true ; } if ( false === $ dbConnectError && Schema :: hasTable ( 'configurations' ) ) { $ repository = $ this -> app -> get ( ConfigurationInterface :: class ) ; $ activeTheme = $ repository -> getValueByKey ( 'active_theme_identifier' ) ; } $ theme = Theme :: get ( $ activeTheme ) ; $ fallBackPath = base_path ( 'resources/lang' ) ; $ this -> app [ 'lang.path' ] = array_get ( $ theme , 'lang_path' ) ; }
Load the Default Theme in the Boot method
38,709
protected function registerTheme ( ) { $ this -> app -> singleton ( 'theme' , function ( $ app ) { $ loadDefaultLangPath = base_path ( 'resources/lang' ) ; $ app [ 'path.lang' ] = $ loadDefaultLangPath ; return new Manager ( $ app [ 'files' ] ) ; } ) ; }
Register the Them Provider instance .
38,710
public function makeSizes ( ) { $ name = basename ( $ this -> dbPath ) ; $ path = str_replace ( '/' . $ name , '' , $ this -> dbPath ) ; $ sizes = config ( 'avored-framework.image.sizes' ) ; foreach ( $ sizes as $ sizeName => $ widthHeight ) { list ( $ width , $ height ) = $ widthHeight ; $ imagePath = storage_path ( 'app/public/' . $ path ) . DIRECTORY_SEPARATOR . $ sizeName . '-' . $ name ; $ this -> driver -> path ( $ this -> dbPath ) -> make ( ) -> resize ( $ width , $ height ) -> saveImage ( $ imagePath , 100 ) ; } return $ this ; }
Make Different Sizes of the image based on config
38,711
public function directory ( $ path ) { if ( ! File :: exists ( $ path ) ) { File :: makeDirectory ( $ path , 0775 , true , true ) ; } return $ this ; }
Create Directories if not exists .
38,712
public function make ( $ name ) : DataGrid { $ dataGrid = new DataGrid ( $ this -> request ) ; $ this -> collection -> put ( $ name , $ dataGrid ) ; return $ dataGrid ; }
DataGrid Make an Object .
38,713
public function render ( $ dataGrid ) { if ( null !== $ this -> request -> get ( 'q' ) ) { foreach ( $ this -> request -> get ( 'q' ) as $ key => $ val ) { $ dataGrid -> model -> where ( $ key , 'like' , '%' . $ val . '%' ) ; } } $ options = [ 'path' => asset ( request ( ) -> path ( ) ) ] ; if ( ! $ dataGrid -> model instanceof Collection ) { $ dataGrid -> data = $ dataGrid -> model -> paginate ( $ this -> pageItem , [ '*' ] , $ dataGrid -> pageName ( ) ) ; if ( null !== $ this -> request -> get ( 'asc' ) ) { $ dataGrid -> model -> orderBy ( $ this -> request -> get ( 'asc' ) , 'asc' ) ; } if ( null !== $ this -> request -> get ( 'desc' , 'id' ) ) { $ dataGrid -> model -> orderBy ( $ this -> request -> get ( 'desc' , 'id' ) , 'desc' ) ; } } else { $ dataGrid -> data = $ this -> paginate ( $ dataGrid -> model , $ this -> pageItem , null , $ options ) ; } return view ( 'avored-framework::datagrid.grid' ) -> with ( 'dataGrid' , $ dataGrid ) ; }
Render the Datagrid by given datagrid object
38,714
public function linkColumn ( $ identifier , $ options = [ ] , $ callback ) { $ column = new LinkColumn ( $ identifier , $ options , $ callback ) ; $ this -> columns -> put ( $ identifier , $ column ) ; return $ this ; }
I feel this method is moved to DataGrid file
38,715
public function update ( $ property , $ data ) { if ( Session :: has ( 'multi_language_enabled' ) ) { $ languageId = $ data [ 'language_id' ] ; $ languaModel = Language :: find ( $ languageId ) ; if ( $ languaModel -> is_default ) { return $ property -> update ( $ data ) ; } else { $ translatedModel = $ property -> translations ( ) -> whereLanguageId ( $ languageId ) -> first ( ) ; if ( null === $ translatedModel ) { return PropertyTranslation :: create ( array_merge ( $ data , [ 'property_id' => $ property -> id ] ) ) ; } else { $ translatedModel -> update ( $ data , $ property -> getTranslatedAttributes ( ) ) ; return $ translatedModel ; } } } else { return $ category -> update ( $ data ) ; } }
Update Product Property
38,716
public function getValueByKey ( $ key ) { $ model = Configuration :: whereConfigurationKey ( $ key ) -> first ( ) ; if ( null === $ model ) { return null ; } return $ model -> configuration_value ; }
Find an Configuration_value by given configurationKey
38,717
public function setValueByKey ( $ key , $ value ) { $ model = Configuration :: whereConfigurationKey ( $ key ) -> first ( ) ; if ( null === $ model ) { return null ; } $ model -> update ( [ 'configuration_value' => $ value ] ) ; return $ model ; }
Set an Configuration value by given configuration Key
38,718
public function destroy ( $ id ) { $ product = Product :: find ( $ id ) ; $ product -> delete ( ) ; return JsonResponse :: create ( null , 204 ) ; }
Destroy an Record and Return Null Json Response
38,719
public function get ( $ identifier ) { if ( $ this -> themeLoaded === false ) { $ this -> loadThemes ( ) ; } return $ this -> themeList -> get ( $ identifier ) ; }
Get the theme into an collection
38,720
public function getByPath ( $ path ) { foreach ( $ this -> themeList as $ theme => $ themeInfo ) { $ path1 = $ this -> pathSlashFix ( $ path ) ; $ path2 = $ this -> pathSlashFix ( $ themeInfo [ 'path' ] ) ; if ( $ path1 == $ path2 ) { $ actualTheme = $ this -> themeList [ $ theme ] ; break ; } } return $ actualTheme ; }
Get the ThemeInfo By Path
38,721
public function index ( ) { $ productsBuilder = $ this -> repository -> query ( ) -> where ( 'type' , '!=' , 'VARIABLE_PRODUCT' ) -> orderBy ( 'id' , 'desc' ) ; $ productGrid = new ProductDataGrid ( $ productsBuilder ) ; return view ( 'avored-framework::product.index' ) -> with ( 'dataGrid' , $ productGrid -> dataGrid ) ; }
Display a listing of the resource . r .
38,722
public function uploadImage ( Request $ request ) { $ image = $ request -> image ; $ tmpPath = str_split ( strtolower ( str_random ( 3 ) ) ) ; $ checkDirectory = 'uploads/catalog/images/' . implode ( '/' , $ tmpPath ) ; $ dbPath = $ checkDirectory . '/' . $ image -> getClientOriginalName ( ) ; $ image = Image :: upload ( $ request -> file ( 'image' ) , $ checkDirectory ) -> makeSizes ( ) -> get ( ) ; $ tmp = $ this -> _getTmpString ( ) ; return view ( 'avored-framework::product.upload-image' ) -> with ( 'image' , $ image ) -> with ( 'tmp' , $ tmp ) ; }
upload image file and re sized it .
38,723
public function getAttribute ( $ key , $ translated = false ) { if ( false === $ translated ) { return parent :: getAttribute ( $ key ) ; } $ defaultLanguage = Session :: get ( 'default_language' ) ; $ languageId = request ( ) -> get ( 'language_id' , $ defaultLanguage -> id ) ; if ( in_array ( $ key , $ this -> getTranslatedAttributes ( ) ) && $ defaultLanguage -> id != $ languageId ) { $ translatedModel = $ this -> translations ( ) -> whereLanguageId ( $ languageId ) -> first ( ) ; if ( $ translatedModel === null ) { return null ; } return $ translatedModel -> attributes [ $ key ] ; } return parent :: getAttribute ( $ key ) ; }
Get the Attribute of an model
38,724
public function index ( ) { $ modules = Module :: all ( ) ; $ moduleDataGrid = new ModuleDataGrid ( $ modules ) ; return view ( 'avored-framework::system.module.index' ) -> with ( 'modules' , $ modules ) -> with ( 'dataGrid' , $ moduleDataGrid -> dataGrid ) ; }
Display a listing of the modules .
38,725
public function store ( UploadModuleRequest $ request ) { $ path = storage_path ( 'app/' . $ request -> module_zip_file -> store ( 'public/uploads/modules' ) ) ; $ zip = new ZipArchive ; if ( $ zip -> open ( $ path ) === true ) { $ extractPath = base_path ( 'modules' ) ; $ zip -> extractTo ( $ extractPath ) ; $ zip -> close ( ) ; return redirect ( ) -> route ( 'admin.module.index' ) -> with ( 'notificationText' , 'Module Extracted successfully' ) ; } else { return redirect ( ) -> back ( ) -> with ( 'errorNotificationText' , 'There is some issue: Please check your permission and try again later!' ) ; } }
Store and Extract upload module zip files
38,726
public function getProductVariationJsonData ( ) { $ jsonData = [ ] ; $ lists = ProductAttributeIntegerValue :: whereIn ( 'product_id' , $ this -> productVariations -> pluck ( 'variation_id' ) ) -> get ( ) ; foreach ( $ lists as $ list ) { $ variationModel = self :: find ( $ list -> product_id ) ; if ( array_has ( $ jsonData , $ list -> product_id ) ) { $ data = array_get ( $ jsonData , $ list -> product_id ) ; $ data [ $ list -> attribute_id ] = [ $ list -> value => [ 'qty' => $ variationModel -> qty , 'price' => $ variationModel -> price ] ] ; $ jsonData [ $ list -> product_id ] = $ data ; } else { $ jsonData [ $ list -> product_id ] = [ $ list -> attribute_id => [ $ list -> value => [ 'qty' => $ variationModel -> qty , 'price' => $ variationModel -> price ] ] ] ; } } return $ jsonData ; }
Get the Product Variation Product Json Data
38,727
public function getPriceAttribute ( $ val ) { $ currentCurrencyCode = Session :: get ( 'currency_code' ) ; if ( null === $ currentCurrencyCode ) { return $ val ; } $ siteCurrency = App :: get ( SiteCurrencyInterface :: class ) ; $ model = $ siteCurrency -> findByCode ( $ currentCurrencyCode ) ; return $ val * $ model -> conversion_rate ; }
Get the Price for the Product
38,728
public function saveProductImages ( array $ data ) : self { if ( isset ( $ data [ 'image' ] ) && count ( $ data [ 'image' ] ) > 0 ) { $ exitingIds = $ this -> images ( ) -> get ( ) -> pluck ( 'id' ) -> toArray ( ) ; foreach ( $ data [ 'image' ] as $ key => $ data ) { if ( is_int ( $ key ) ) { if ( ( $ findKey = array_search ( $ key , $ exitingIds ) ) !== false ) { $ productImage = ProductImage :: findorfail ( $ key ) ; $ productImage -> update ( $ data ) ; unset ( $ exitingIds [ $ findKey ] ) ; } continue ; } ProductImage :: create ( $ data + [ 'product_id' => $ this -> id ] ) ; } if ( count ( $ exitingIds ) > 0 ) { ProductImage :: destroy ( $ exitingIds ) ; } } return $ this ; }
Save Product Images .
38,729
public function saveProduct ( $ data ) { Event :: fire ( new ProductBeforeSave ( $ data ) ) ; $ this -> update ( $ data ) ; $ this -> saveProductImages ( $ data ) ; $ this -> saveCategoryFilters ( $ data ) ; $ this -> saveProductCategories ( $ data ) ; $ this -> saveProductProperties ( $ data ) ; $ this -> saveProductAttributes ( $ data ) ; $ this -> saveProductDownloadable ( $ data ) ; Event :: fire ( new ProductAfterSave ( $ this , $ data ) ) ; return $ this ; }
Update the Product and Product Related Data .
38,730
protected function saveProductCategories ( $ data ) { if ( isset ( $ data [ 'category_id' ] ) && count ( $ data [ 'category_id' ] ) > 0 ) { $ this -> categories ( ) -> sync ( $ data [ 'category_id' ] ) ; } }
Save Product Categories
38,731
protected function saveProductDownloadable ( $ data ) { if ( isset ( $ data [ 'downloadable' ] ) && count ( $ data [ 'downloadable' ] ) > 0 ) { $ repository = App :: get ( ProductDownloadableUrlInterface :: class ) ; $ mainDownloadableMedia = ( $ data [ 'downloadable' ] [ 'main_product' ] ) ?? null ; if ( null === $ mainDownloadableMedia ) { throw new \ Exception ( 'Invalid Downloadable Media Given or Nothing Given' ) ; } $ tmpPath = str_split ( strtolower ( str_random ( 3 ) ) ) ; $ path = 'uploads/downloadables/' . implode ( '/' , $ tmpPath ) ; $ dbPath = $ mainDownloadableMedia -> store ( $ path , 'avored' ) ; $ token = str_random ( 32 ) ; $ downModel = $ repository -> query ( ) -> whereProductId ( $ this -> id ) -> first ( ) ; if ( null === $ downModel ) { $ downModel = ProductDownloadableUrl :: create ( [ 'token' => $ token , 'product_id' => $ this -> id , 'main_path' => $ dbPath ] ) ; } else { $ downModel -> update ( [ 'main_path' => $ dbPath ] ) ; } $ demoDownloadableMedia = ( $ data [ 'downloadable' ] [ 'demo_product' ] ) ?? null ; if ( null !== $ demoDownloadableMedia ) { $ tmpPath = str_split ( strtolower ( str_random ( 3 ) ) ) ; $ path = 'uploads/downloadables/' . implode ( '/' , $ tmpPath ) ; $ demoDbPath = $ demoDownloadableMedia -> store ( $ path , 'avored' ) ; $ downModel -> update ( [ 'demo_path' => $ demoDbPath ] ) ; } } }
Save Product Downloadable Information
38,732
public function getImageAttribute ( ) { $ defaultPath = '/img/default-product.jpg' ; $ image = $ this -> images ( ) -> where ( 'is_main_image' , '=' , 1 ) -> first ( ) ; if ( null === $ image ) { return new LocalFile ( $ defaultPath ) ; } if ( $ image -> path instanceof LocalFile ) { return $ image -> path ; } }
return default Image or LocalFile Object .
38,733
public function getProductAllProperties ( ) { $ collection = Collection :: make ( [ ] ) ; foreach ( $ this -> productVarcharProperties as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ this -> productBooleanProperties as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ this -> productTextProperties as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ this -> productDecimalProperties as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ this -> productDecimalProperties as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ this -> productIntegerProperties as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ this -> productDatetimeProperties as $ item ) { $ collection -> push ( $ item ) ; } return $ collection ; }
Get All Properties for the Product .
38,734
public function getProductAllAttributes ( $ variation = null ) { if ( null === $ variation ) { $ variations = $ this -> productVariations ( ) -> get ( ) ; } $ collection = Collection :: make ( [ ] ) ; if ( null === $ variations || $ variations -> count ( ) <= 0 ) { return $ collection ; } foreach ( $ variations as $ variation ) { $ variationModel = self :: findorfail ( $ variation -> variation_id ) ; foreach ( $ variationModel -> productVarcharAttributes as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ variationModel -> productBooleanAttributes as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ variationModel -> productTextAttributes as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ variationModel -> productDecimalAttributes as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ variationModel -> productDecimalAttributes as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ variationModel -> productIntegerAttributes as $ item ) { $ collection -> push ( $ item ) ; } foreach ( $ variationModel -> productDatetimeAttributes as $ item ) { $ collection -> push ( $ item ) ; } } return $ collection ; }
Get All Attribute for the Product .
38,735
public function getVariableProduct ( $ attributeDropdownOption ) { $ productAttributeIntegerValue = ProductAttributeIntegerValue :: whereAttributeId ( $ attributeDropdownOption -> attribute_id ) -> whereValue ( $ attributeDropdownOption -> id ) -> first ( ) ; if ( null === $ productAttributeIntegerValue ) { return ; } return self :: findorfail ( $ productAttributeIntegerValue -> product_id ) ; }
Get Variable Product by Attribute Drop down Option .
38,736
private function _saveRolePermissions ( $ request , $ role ) { $ permissionIds = [ ] ; if ( count ( $ request -> get ( 'permissions' ) ) > 0 ) { foreach ( $ request -> get ( 'permissions' ) as $ key => $ value ) { if ( $ value != 1 ) { continue ; } $ permissions = explode ( ',' , $ key ) ; foreach ( $ permissions as $ permissionName ) { if ( null === ( $ permissionModel = Permission :: getPermissionByName ( $ permissionName ) ) ) { $ permissionModel = Permission :: create ( [ 'name' => $ permissionName ] ) ; } $ permissionIds [ ] = $ permissionModel -> id ; } } } $ ids = array_unique ( $ permissionIds ) ; $ role -> permissions ( ) -> sync ( $ ids ) ; }
Save Role Permission for the Users
38,737
public function changePasswordUpdate ( ChangePasswordRequest $ request , User $ user ) { $ password = $ request -> get ( 'password' ) ; $ user -> update ( [ 'password' => bcrypt ( $ password ) ] ) ; Mail :: to ( $ user -> email ) -> send ( new ChangePasswordMail ( $ user , $ password ) ) ; return redirect ( ) -> route ( 'admin.user.index' ) ; }
Update the specified User Password in storage .
38,738
public function getPathAttribute ( $ path ) { if ( null === $ this -> attributes [ 'path' ] || empty ( $ this -> attributes [ 'path' ] ) ) { return ; } $ symlink = config ( 'avored-framework.symlink_storage_folder' ) ; $ relativePath = $ this -> attributes [ 'path' ] ; $ localImage = new LocalFile ( $ relativePath ) ; return $ localImage ; }
Get Path Attribute for the Image
38,739
public function options ( ) { $ countries = $ this -> all ( ) ; $ options = Collection :: make ( ) ; foreach ( $ countries as $ country ) { $ options -> push ( [ 'name' => $ country -> name , 'id' => $ country -> id ] ) ; } return $ options ; }
Get All Country Options for Dropdown Field
38,740
protected function createRequest ( $ client , $ userId , $ request , array $ scopes ) { return ( new ServerRequest ) -> withParsedBody ( [ 'grant_type' => 'password' , 'client_id' => $ client -> id , 'client_secret' => $ client -> secret , 'username' => $ request -> get ( 'email' ) , 'password' => $ request -> get ( 'password' ) , 'user_id' => $ userId , 'scope' => implode ( ' ' , $ scopes ) ] ) ; }
Create a request instance for the given client .
38,741
public function index ( ) { $ orderStateGrid = new OrderStatusDataGrid ( $ this -> repository -> query ( ) ) ; return view ( 'avored-framework::product.order-status.index' ) -> with ( 'dataGrid' , $ orderStateGrid -> dataGrid ) ; }
Display a listing of the OrderStatus .
38,742
public function down ( ) { Schema :: disableForeignKeyConstraints ( ) ; Schema :: dropIfExists ( 'order_product_variations' ) ; Schema :: dropIfExists ( 'product_variations' ) ; Schema :: dropIfExists ( 'product_attribute_integer_values' ) ; Schema :: dropIfExists ( 'attribute_dropdown_option_translations' ) ; Schema :: dropIfExists ( 'attribute_dropdown_options' ) ; Schema :: dropIfExists ( 'attribute_product' ) ; Schema :: dropIfExists ( 'product_property' ) ; Schema :: dropIfExists ( 'product_property_boolean_values' ) ; Schema :: dropIfExists ( 'product_property_text_values' ) ; Schema :: dropIfExists ( 'product_property_decimal_values' ) ; Schema :: dropIfExists ( 'product_property_integer_values' ) ; Schema :: dropIfExists ( 'product_property_varchar_values' ) ; Schema :: dropIfExists ( 'product_property_datetime_values' ) ; Schema :: dropIfExists ( 'property_dropdown_options' ) ; Schema :: dropIfExists ( 'property_translations' ) ; Schema :: dropIfExists ( 'properties' ) ; Schema :: dropIfExists ( 'category_filters' ) ; Schema :: dropIfExists ( 'category_product' ) ; Schema :: dropIfExists ( 'product_images' ) ; Schema :: dropIfExists ( 'product_prices' ) ; Schema :: dropIfExists ( 'category_translations' ) ; Schema :: dropIfExists ( 'attribute_translations' ) ; Schema :: dropIfExists ( 'attributes' ) ; Schema :: dropIfExists ( 'order_return_products' ) ; Schema :: dropIfExists ( 'order_return_requests' ) ; Schema :: dropIfExists ( 'product_order' ) ; Schema :: dropIfExists ( 'order_product' ) ; Schema :: dropIfExists ( 'order_histories' ) ; Schema :: dropIfExists ( 'orders' ) ; Schema :: dropIfExists ( 'order_statuses' ) ; Schema :: dropIfExists ( 'product_downloadable_urls' ) ; Schema :: dropIfExists ( 'menu_groups' ) ; Schema :: dropIfExists ( 'menus' ) ; Schema :: dropIfExists ( 'products' ) ; Schema :: dropIfExists ( 'categories' ) ; Schema :: dropIfExists ( 'oauth_personal_access_clients' ) ; Schema :: dropIfExists ( 'oauth_clients' ) ; Schema :: dropIfExists ( 'oauth_refresh_tokens' ) ; Schema :: dropIfExists ( 'oauth_access_tokens' ) ; Schema :: dropIfExists ( 'oauth_auth_codes' ) ; Schema :: dropIfExists ( 'admin_password_resets' ) ; Schema :: dropIfExists ( 'admin_users' ) ; Schema :: dropIfExists ( 'password_resets' ) ; Schema :: dropIfExists ( 'user_user_group' ) ; Schema :: dropIfExists ( 'user_groups' ) ; Schema :: dropIfExists ( 'users' ) ; Schema :: dropIfExists ( 'addresses' ) ; Schema :: dropIfExists ( 'configurations' ) ; Schema :: dropIfExists ( 'tax_rates' ) ; Schema :: dropIfExists ( 'tax_groups' ) ; Schema :: dropIfExists ( 'site_currencies' ) ; Schema :: dropIfExists ( 'pages' ) ; Schema :: dropIfExists ( 'wishlists' ) ; Schema :: dropIfExists ( 'permission_role' ) ; Schema :: dropIfExists ( 'permissions' ) ; Schema :: dropIfExists ( 'roles' ) ; Schema :: dropIfExists ( 'states' ) ; Schema :: dropIfExists ( 'countries' ) ; Schema :: dropIfExists ( 'languages' ) ; Schema :: enableForeignKeyConstraints ( ) ; }
Uninstall the AvoRed Address Module Schema .
38,743
public function getCountryIdAttribute ( ) { if ( isset ( $ this -> attributes [ 'country_id' ] ) && $ this -> attributes [ 'country_id' ] > 0 ) { return $ this -> attributes [ 'country_id' ] ; } $ configRepository = app ( ConfigurationInterface :: class ) ; $ defaultCountry = $ configRepository -> getValueByKey ( 'user_default_country' ) ; if ( isset ( $ defaultCountry ) ) { return $ defaultCountry ; } return null ; }
To Check If Country Id is Null then it Returns Default Country ID from Configuration
38,744
public function get ( $ key ) { $ tab = $ this -> adminTabs -> get ( $ key ) ; if ( null == $ tab ) { throw new \ Exception ( 'Required Tab is missing' ) ; } return $ this -> adminTabs -> get ( $ key ) ; }
Get Tab from Tabs Collection .
38,745
public function all ( $ type = 'product' ) { $ tabs = $ this -> adminTabs -> filter ( function ( $ item , $ key ) use ( $ type ) { if ( $ item -> type ( ) == $ type ) { return true ; } } ) ; return $ tabs ; }
Return all registered Tab with Specified Type .
38,746
public function saveFilter ( $ categoryId , $ filterId , $ type ) { $ filterModel = CategoryFilter :: whereCategoryId ( $ categoryId ) -> whereFilterId ( $ filterId ) -> whereType ( 'PROPERTY' ) -> first ( ) ; if ( null === $ filterModel ) { CategoryFilter :: create ( [ 'category_id' => $ categoryId , 'filter_id' => $ filterId , 'type' => 'PROPERTY' ] ) ; } }
Save Categoy Filter
38,747
public function add ( $ key , $ callable = null ) { if ( null !== $ callable ) { $ group = new PermissionGroup ( $ callable ) ; $ group -> key ( $ key ) ; $ this -> permissions -> put ( $ key , $ group ) ; } else { $ group = new PermissionGroup ( ) ; $ group -> key ( $ key ) ; $ this -> permissions -> put ( $ key , $ group ) ; } return $ group ; }
Add Permission into Collection .
38,748
public function get ( $ key ) { if ( $ this -> permissions -> has ( $ key ) ) { return $ this -> permissions -> get ( $ key ) ; } return $ collection = Collection :: make ( [ ] ) ; }
Get Permission Collection if exists or Return Empty Collection .
38,749
public function addConfiguration ( $ key ) { $ adminConfiguration = new AdminConfiguration ( ) ; $ adminConfiguration -> key ( $ key ) ; $ this -> groupList -> put ( $ key , $ adminConfiguration ) ; return $ adminConfiguration ; }
Add Configuration to the group list
38,750
public function deleteContactIds ( ) { $ conn = $ this -> getConnection ( ) ; $ num = $ conn -> update ( $ this -> getTable ( Schema :: EMAIL_CONTACT_TABLE ) , [ 'contact_id' => $ this -> expressionFactory -> create ( [ "expression" => 'null' ] ) ] , $ conn -> quoteInto ( 'contact_id is ?' , $ this -> expressionFactory -> create ( [ "expression" => 'not null' ] ) ) ) ; return $ num ; }
Remove all contact_id from the table .
38,751
public function setContactSuppressedForContactIds ( $ suppressedContactIds ) { if ( empty ( $ suppressedContactIds ) ) { return 0 ; } $ conn = $ this -> getConnection ( ) ; $ updated = $ conn -> update ( $ this -> getMainTable ( ) , [ 'suppressed' => 1 ] , [ 'email_contact_id IN(?)' => $ suppressedContactIds ] ) ; return $ updated ; }
Set suppressed for contact ids .
38,752
public function updateSubscribers ( $ emailContactIds ) { if ( empty ( $ emailContactIds ) ) { return 0 ; } $ write = $ this -> getConnection ( ) ; $ updated = $ write -> update ( $ this -> getMainTable ( ) , [ 'subscriber_imported' => 1 ] , [ "email_contact_id IN (?)" => $ emailContactIds ] ) ; return $ updated ; }
Update subscriber imported .
38,753
public function getSalesDataForSubscribersWithOrderStatusesAndBrand ( $ emails , $ websiteId ) { $ orderStatuses = $ this -> config -> getWebsiteConfig ( Config :: XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_STATUS , $ websiteId ) ; $ orderStatuses = explode ( ',' , $ orderStatuses ) ; $ orderCollection = $ this -> orderCollectionFactory -> create ( ) -> addFieldToSelect ( [ 'customer_email' ] ) -> addExpressionFieldToSelect ( 'total_spend' , 'SUM({{grand_total}})' , 'grand_total' ) -> addExpressionFieldToSelect ( 'number_of_orders' , 'COUNT({{*}})' , '*' ) -> addExpressionFieldToSelect ( 'average_order_value' , 'AVG({{grand_total}})' , 'grand_total' ) -> addFieldToFilter ( 'customer_email' , [ 'in' => $ emails ] ) ; $ columns = $ this -> buildCollectionColumns ( ) ; $ orderCollection -> getSelect ( ) -> columns ( $ columns ) -> group ( 'customer_email' ) ; if ( ! empty ( $ orderStatuses ) ) { $ orderCollection -> getSelect ( ) -> where ( 'status in (?)' , $ orderStatuses ) ; } $ orderArray = [ ] ; foreach ( $ orderCollection as $ item ) { $ orderArray [ $ item -> getCustomerEmail ( ) ] = $ item -> toArray ( [ 'total_spend' , 'number_of_orders' , 'average_order_value' , 'last_order_date' , 'first_order_id' , 'last_order_id' , 'last_increment_id' , 'product_id_for_first_brand' , 'product_id_for_last_brand' , 'week_day' , 'month_day' , 'product_id_for_most_sold_product' ] ) ; } return $ orderArray ; }
Get collection for subscribers by emails .
38,754
public function getSalesDataForCustomersWithOrderStatusesAndBrand ( $ customerIds , $ statuses ) { $ orderCollection = $ this -> orderCollectionFactory -> create ( ) ; $ salesOrder = $ orderCollection -> getTable ( 'sales_order' ) ; $ salesOrderGrid = $ orderCollection -> getTable ( 'sales_order_grid' ) ; $ salesOrderItem = $ orderCollection -> getTable ( 'sales_order_item' ) ; $ orderCollection -> addFieldToSelect ( [ 'customer_id' ] ) -> addExpressionFieldToSelect ( 'total_spend' , 'SUM({{grand_total}})' , 'grand_total' ) -> addExpressionFieldToSelect ( 'number_of_orders' , 'COUNT({{*}})' , '*' ) -> addExpressionFieldToSelect ( 'average_order_value' , 'AVG({{grand_total}})' , 'grand_total' ) -> addFieldToFilter ( 'customer_id' , [ 'in' => $ customerIds ] ) ; $ columnData = $ this -> buildColumnData ( $ salesOrderGrid , $ salesOrder , $ salesOrderItem ) ; $ orderCollection -> getSelect ( ) -> columns ( $ columnData ) -> group ( 'customer_id' ) ; if ( ! empty ( $ statuses ) ) { $ orderCollection -> getSelect ( ) -> where ( 'status in (?)' , $ statuses ) ; } $ orderArray = [ ] ; foreach ( $ orderCollection as $ item ) { $ orderArray [ $ item -> getCustomerId ( ) ] = $ item -> toArray ( [ 'total_spend' , 'number_of_orders' , 'average_order_value' , 'last_order_date' , 'first_order_id' , 'last_order_id' , 'last_increment_id' , 'product_id_for_first_brand' , 'product_id_for_last_brand' , 'week_day' , 'month_day' , 'product_id_for_most_sold_product' ] ) ; } return $ this -> getCollectionWithLastQuoteId ( $ customerIds , $ orderArray ) ; }
Customer collection with all data ready for export .
38,755
public function getDateLastCronRun ( $ cronJob ) { $ collection = $ this -> schelduleFactory -> create ( ) -> getCollection ( ) -> addFieldToFilter ( 'status' , \ Magento \ Cron \ Model \ Schedule :: STATUS_SUCCESS ) -> addFieldToFilter ( 'job_code' , $ cronJob ) ; $ collection -> getSelect ( ) -> limit ( 1 ) -> order ( 'executed_at DESC' ) ; if ( $ collection -> getSize ( ) == 0 ) { return false ; } $ executedAt = $ collection -> getFirstItem ( ) -> getExecutedAt ( ) ; return $ executedAt ; }
Get last cron ran date .
38,756
public function updateNotImportedByCustomerIds ( $ customerIds ) { $ this -> getConnection ( ) -> update ( $ this -> getMainTable ( ) , [ 'email_imported' => $ this -> expressionFactory -> create ( [ "expression" => 'null' ] ) ] , [ "customer_id IN (?)" => $ customerIds ] ) ; }
Update contacts to re - import by customer ids
38,757
private function registerReview ( $ review ) { try { $ reviewModel = $ this -> reviewFactory -> create ( ) ; $ reviewModel -> setReviewId ( $ review -> getReviewId ( ) ) -> setCustomerId ( $ review -> getCustomerId ( ) ) -> setStoreId ( $ review -> getStoreId ( ) ) ; $ this -> reviewResource -> save ( $ reviewModel ) ; } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } }
Register review .
38,758
public function createReviewCampaigns ( ) { $ this -> searchOrdersForReview ( ) ; foreach ( $ this -> reviewCollection as $ websiteId => $ collection ) { $ this -> registerCampaign ( $ collection , $ websiteId ) ; } }
Create review campaigns
38,759
public function registerCampaign ( $ collection , $ websiteId ) { $ campaignId = $ this -> helper -> getCampaign ( $ websiteId ) ; if ( $ campaignId ) { foreach ( $ collection as $ order ) { $ this -> helper -> log ( '-- Order Review: ' . $ order -> getIncrementId ( ) . ' Campaign Id: ' . $ campaignId ) ; try { $ emailCampaign = $ this -> campaignFactory -> create ( ) -> setEmail ( $ order -> getCustomerEmail ( ) ) -> setStoreId ( $ order -> getStoreId ( ) ) -> setCampaignId ( $ campaignId ) -> setEventName ( 'Order Review' ) -> setCreatedAt ( $ this -> dateTime -> formatDate ( true ) ) -> setOrderIncrementId ( $ order -> getIncrementId ( ) ) -> setQuoteId ( $ order -> getQuoteId ( ) ) ; if ( $ order -> getCustomerId ( ) ) { $ emailCampaign -> setCustomerId ( $ order -> getCustomerId ( ) ) ; } $ this -> campaignResource -> saveItem ( $ emailCampaign ) ; } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } } } }
Register review campaign .
38,760
public function searchOrdersForReview ( ) { $ websites = $ this -> helper -> getwebsites ( true ) ; foreach ( $ websites as $ website ) { $ apiEnabled = $ this -> helper -> isEnabled ( $ website ) ; if ( $ apiEnabled && $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_REVIEWS_ENABLED , $ website ) && $ this -> helper -> getOrderStatus ( $ website ) && $ this -> helper -> getDelay ( $ website ) ) { $ storeIds = $ website -> getStoreIds ( ) ; if ( empty ( $ storeIds ) ) { continue ; } $ orderStatusFromConfig = $ this -> helper -> getOrderStatus ( $ website ) ; $ delayInDays = $ this -> helper -> getDelay ( $ website ) ; $ campaignCollection = $ this -> campaignCollection -> create ( ) -> getCollectionByEvent ( 'Order Review' ) ; $ campaignOrderIds = $ campaignCollection -> getColumnValues ( 'order_increment_id' ) ; $ fromTime = new \ DateTime ( 'now' , new \ DateTimezone ( 'UTC' ) ) ; $ interval = $ this -> dateIntervalFactory -> create ( [ 'interval_spec' => sprintf ( 'P%sD' , $ delayInDays ) ] ) ; $ fromTime -> sub ( $ interval ) ; $ toTime = clone $ fromTime ; $ fromTime -> sub ( $ this -> dateIntervalFactory -> create ( [ 'interval_spec' => 'PT2H' ] ) ) ; $ fromDate = $ fromTime -> format ( 'Y-m-d H:i:s' ) ; $ toDate = $ toTime -> format ( 'Y-m-d H:i:s' ) ; $ created = [ 'from' => $ fromDate , 'to' => $ toDate , 'date' => true ] ; $ collection = $ this -> orderCollection -> create ( ) -> getSalesCollectionForReviews ( $ orderStatusFromConfig , $ created , $ website , $ campaignOrderIds ) ; $ collection = $ this -> rulesFactory -> create ( ) -> process ( $ collection , \ Dotdigitalgroup \ Email \ Model \ Rules :: REVIEW , $ website -> getId ( ) ) ; if ( $ collection -> getSize ( ) ) { $ this -> reviewCollection [ $ website -> getId ( ) ] = $ collection ; } } } }
Search for orders to review per website .
38,761
public function deleteConsentByEmails ( $ emails ) { if ( empty ( $ emails ) ) { return [ ] ; } $ collection = $ this -> consentCollectionFactory -> create ( ) ; $ collection -> getSelect ( ) -> joinInner ( [ 'c' => $ this -> getTable ( Schema :: EMAIL_CONTACT_TABLE ) ] , "c.email_contact_id = main_table.email_contact_id" , [ ] ) ; $ collection -> addFieldToFilter ( 'c.email' , [ 'in' => $ emails ] ) ; return $ collection -> walk ( 'delete' ) ; }
Delete Consent for contact .
38,762
public function _getWishlist ( ) { $ customerId = ( int ) $ this -> getRequest ( ) -> getParam ( 'customer_id' ) ; if ( ! $ customerId ) { return [ ] ; } $ customer = $ this -> customerFactory -> create ( ) ; $ this -> customerResource -> load ( $ customer , $ customerId ) ; if ( ! $ customer -> getId ( ) ) { return [ ] ; } return $ this -> wishlist -> getWishlistsForCustomer ( $ customerId ) ; }
Get wishlist for customer .
38,763
private function addRecommendedProducts ( & $ productsToDisplayCounter , $ limit , $ maxPerChild , $ recommendedProducts , & $ productsToDisplay , & $ product ) { $ i = 0 ; foreach ( $ recommendedProducts as $ product ) { if ( $ product -> getId ( ) && $ productsToDisplayCounter < $ limit && $ i <= $ maxPerChild && $ product -> isSaleable ( ) && ! $ product -> getParentId ( ) ) { $ productsToDisplay [ $ product -> getId ( ) ] = $ product ; $ i ++ ; $ productsToDisplayCounter ++ ; } } }
Add recommended products
38,764
private function fillProductsToDisplay ( $ productsToDisplay , & $ productsToDisplayCounter , $ limit ) { $ fallbackIds = $ this -> recommnededHelper -> getFallbackIds ( ) ; $ productCollection = $ this -> catalog -> getProductCollectionFromIds ( $ fallbackIds ) ; foreach ( $ productCollection as $ product ) { if ( $ product -> isSaleable ( ) ) { $ productsToDisplay [ $ product -> getId ( ) ] = $ product ; $ productsToDisplayCounter ++ ; } if ( $ productsToDisplayCounter == $ limit ) { break ; } } return $ productsToDisplay ; }
Fill products to display
38,765
private function getRecommendedProduct ( $ productModel , $ mode ) { $ products = [ ] ; switch ( $ mode ) { case 'related' : $ products = $ productModel -> getRelatedProductIds ( ) ; break ; case 'upsell' : $ products = $ productModel -> getUpSellProductIds ( ) ; break ; case 'crosssell' : $ products = $ productModel -> getCrossSellProductIds ( ) ; break ; } return $ products ; }
Product related items .
38,766
public function getDataFields ( ) { $ website = $ this -> helper -> getWebsite ( ) ; $ client = $ this -> helper -> getWebsiteApiClient ( $ website ) ; $ datafields = $ client -> getDataFields ( ) ; return $ datafields ; }
Get data fields .
38,767
public function execute ( ) { $ logFile = $ this -> getRequest ( ) -> getParam ( 'log' ) ; switch ( $ logFile ) { case "connector" : $ header = 'Marketing Automation Log' ; break ; case "system" : $ header = 'Magento System Log' ; break ; case "exception" : $ header = 'Magento Exception Log' ; break ; case "debug" : $ header = 'Magento Debug Log' ; break ; default : $ header = 'Marketing Automation Log' ; } $ content = nl2br ( $ this -> escaper -> escapeHtml ( $ this -> file -> getLogFileContent ( $ logFile ) ) ) ; $ response = [ 'content' => $ content , 'header' => $ header ] ; $ this -> getResponse ( ) -> representJson ( $ this -> jsonHelper -> jsonEncode ( $ response ) ) ; }
Ajax get log file content .
38,768
public function render ( \ Magento \ Framework \ Data \ Form \ Element \ AbstractElement $ element ) { $ element -> unsScope ( ) -> unsCanUseWebsiteValue ( ) -> unsCanUseDefaultValue ( ) ; return parent :: render ( $ element ) ; }
Unset some non - related element parameters .
38,769
public function resetReviews ( $ from = null , $ to = null ) { $ conn = $ this -> getConnection ( ) ; if ( $ from && $ to ) { $ where = [ 'created_at >= ?' => $ from . ' 00:00:00' , 'created_at <= ?' => $ to . ' 23:59:59' , 'review_imported is ?' => new \ Zend_Db_Expr ( 'not null' ) ] ; } else { $ where = $ conn -> quoteInto ( 'review_imported is ?' , new \ Zend_Db_Expr ( 'not null' ) ) ; } $ num = $ conn -> update ( $ this -> getTable ( Schema :: EMAIL_REVIEW_TABLE ) , [ 'review_imported' => new \ Zend_Db_Expr ( 'null' ) ] , $ where ) ; return $ num ; }
Reset the email reviews for re - import .
38,770
public function filterItemsForReview ( $ items , $ customerId , $ order ) { foreach ( $ items as $ key => $ item ) { $ productId = $ item -> getProduct ( ) -> getId ( ) ; $ collection = $ this -> reviewFactory -> create ( ) -> getCollection ( ) -> addCustomerFilter ( $ customerId ) -> addStoreFilter ( $ order -> getStoreId ( ) ) -> addFieldToFilter ( 'main_table.entity_pk_value' , $ productId ) ; if ( $ collection -> getSize ( ) ) { unset ( $ items [ $ key ] ) ; } } return $ items ; }
Filter items for review .
38,771
public function getProductCollection ( $ quote ) { $ productIds = [ ] ; $ products = [ ] ; $ items = $ quote -> getAllVisibleItems ( ) ; foreach ( $ items as $ item ) { $ productIds [ ] = $ item -> getProductId ( ) ; } if ( ! empty ( $ productIds ) ) { $ products = $ this -> productCollection -> create ( ) -> addAttributeToSelect ( '*' ) -> addFieldToFilter ( 'entity_id' , [ 'in' => $ productIds ] ) ; } return $ products ; }
Get product collection from order .
38,772
public function getMageReviewsByIds ( $ ids ) { $ reviews = $ this -> mageReviewCollection -> create ( ) -> addFieldToFilter ( 'main_table.review_id' , [ 'in' => $ ids ] ) -> addFieldToFilter ( 'customer_id' , [ 'notnull' => 'true' ] ) ; $ reviews -> getSelect ( ) -> joinLeft ( [ 'c' => $ this -> getTable ( 'customer_entity' ) ] , 'c.entity_id = customer_id' , [ 'email' , 'store_id' ] ) ; return $ reviews ; }
Get Mage reviews by ids .
38,773
public function getProductByIdAndStore ( $ id , $ storeId ) { $ product = $ this -> productFactory -> create ( ) -> getCollection ( ) -> addIdFilter ( $ id ) -> setStoreId ( $ storeId ) -> addAttributeToSelect ( [ 'product_url' , 'name' , 'store_id' , 'small_image' ] ) -> setPage ( 1 , 1 ) ; return $ product -> getFirstItem ( ) ; }
Get product by id and store .
38,774
public function getVoteCollectionByReview ( $ reviewId ) { $ votesCollection = $ this -> voteCollection -> create ( ) -> setReviewFilter ( $ reviewId ) ; $ votesCollection -> getSelect ( ) -> join ( [ 'rating' => $ this -> getTable ( 'rating' ) ] , 'rating.rating_id = main_table.rating_id' , [ 'rating_code' => 'rating.rating_code' ] ) ; return $ votesCollection ; }
Get vote collection by review .
38,775
public function execute ( ) { $ params = $ this -> getRequest ( ) -> getParams ( ) ; $ apiUsername = $ params [ 'api_username' ] ; $ apiPassword = base64_decode ( $ params [ 'api_password' ] ) ; if ( $ this -> data -> isEnabled ( ) ) { $ client = $ this -> data -> getWebsiteApiClient ( ) ; $ result = $ client -> validate ( $ apiUsername , $ apiPassword ) ; $ resonseData [ 'success' ] = true ; if ( ! $ result ) { $ resonseData [ 'success' ] = false ; $ resonseData [ 'message' ] = 'Authorization has been denied for this request.' ; } $ this -> getResponse ( ) -> representJson ( $ this -> jsonHelper -> jsonEncode ( $ resonseData ) ) ; } }
Validate api user .
38,776
public function resetOrders ( $ from = null , $ to = null ) { $ conn = $ this -> getConnection ( ) ; if ( $ from && $ to ) { $ where = [ 'created_at >= ?' => $ from . ' 00:00:00' , 'created_at <= ?' => $ to . ' 23:59:59' , 'email_imported is ?' => new \ Zend_Db_Expr ( 'not null' ) ] ; } else { $ where = $ conn -> quoteInto ( 'email_imported is ?' , new \ Zend_Db_Expr ( 'not null' ) ) ; } $ num = $ conn -> update ( $ this -> getTable ( Schema :: EMAIL_ORDER_TABLE ) , [ 'email_imported' => new \ Zend_Db_Expr ( 'null' ) , 'modified' => new \ Zend_Db_Expr ( 'null' ) , ] , $ where ) ; return $ num ; }
Reset the email order for re - import .
38,777
public function setImported ( $ ids ) { if ( empty ( $ ids ) ) { return ; } $ connection = $ this -> getConnection ( ) ; $ tableName = $ this -> getTable ( Schema :: EMAIL_ORDER_TABLE ) ; $ connection -> update ( $ tableName , [ 'modified' => new \ Zend_Db_Expr ( 'null' ) , 'email_imported' => '1' , 'updated_at' => gmdate ( 'Y-m-d H:i:s' ) ] , [ "order_id IN (?)" => $ ids ] ) ; }
Mark the connector orders to be imported .
38,778
public function generateCoupon ( $ priceRuleId , $ expireDate ) { $ rule = $ this -> getPriceRule ( $ priceRuleId ) ; $ coupon = $ rule -> acquireCoupon ( ) ; $ coupon = $ this -> setUpCoupon ( $ expireDate , $ coupon , $ rule ) ; $ this -> couponResourceInterface -> save ( $ coupon ) ; return $ coupon -> getCode ( ) ; }
Generate coupon .
38,779
public function registerQueue ( $ importType , $ importData , $ importMode , $ websiteId , $ file = false ) { try { if ( ! empty ( $ importData ) ) { $ importData = $ this -> serializer -> serialize ( $ importData ) ; } if ( $ file ) { $ this -> setImportFile ( $ file ) ; } if ( $ importData || $ file ) { $ this -> setImportType ( $ importType ) -> setImportData ( $ importData ) -> setWebsiteId ( $ websiteId ) -> setImportMode ( $ importMode ) ; $ this -> importerResource -> save ( $ this ) ; return true ; } } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } if ( $ this -> serializer -> jsonError ) { $ jle = $ this -> serializer -> jsonError ; $ format = "Json error ($jle) for Import type ($importType) / mode ($importMode) for website ($websiteId)" ; $ this -> helper -> log ( $ format ) ; } return false ; }
Register import in queue .
38,780
public function processQueue ( ) { $ this -> totalItems = 0 ; $ this -> bulkSyncLimit = 5 ; $ this -> _setPriority ( ) ; $ this -> _checkImportStatus ( ) ; foreach ( $ this -> bulkPriority as $ bulk ) { if ( $ this -> totalItems < $ bulk [ 'limit' ] ) { $ collection = $ this -> _getQueue ( $ bulk [ 'type' ] , $ bulk [ 'mode' ] , $ bulk [ 'limit' ] - $ this -> totalItems ) ; if ( $ collection -> getSize ( ) ) { $ this -> totalItems += $ collection -> getSize ( ) ; $ bulkModel = $ this -> objectManager -> create ( $ bulk [ 'model' ] ) ; $ bulkModel -> sync ( $ collection ) ; } } } $ this -> totalItems = 0 ; foreach ( $ this -> singlePriority as $ single ) { if ( $ this -> totalItems < $ single [ 'limit' ] ) { $ collection = $ this -> _getQueue ( $ single [ 'type' ] , $ single [ 'mode' ] , $ single [ 'limit' ] - $ this -> totalItems ) ; if ( $ collection -> getSize ( ) ) { $ this -> totalItems += $ collection -> getSize ( ) ; $ singleModel = $ this -> objectManager -> create ( $ single [ 'model' ] ) ; $ singleModel -> sync ( $ collection ) ; } } } }
Proccess the data from queue .
38,781
public function _checkImportStatus ( ) { if ( $ items = $ this -> _getImportingItems ( $ this -> bulkSyncLimit ) ) { foreach ( $ items as $ item ) { $ websiteId = $ item -> getWebsiteId ( ) ; $ client = false ; if ( $ this -> helper -> isEnabled ( $ websiteId ) ) { $ client = $ this -> helper -> getWebsiteApiClient ( $ websiteId ) ; } if ( $ client ) { try { if ( $ item -> getImportType ( ) == self :: IMPORT_TYPE_CONTACT || $ item -> getImportType ( ) == self :: IMPORT_TYPE_SUBSCRIBERS || $ item -> getImportType ( ) == self :: IMPORT_TYPE_GUEST ) { $ response = $ client -> getContactsImportByImportId ( $ item -> getImportId ( ) ) ; } else { $ response = $ client -> getContactsTransactionalDataImportByImportId ( $ item -> getImportId ( ) ) ; } } catch ( \ Exception $ e ) { $ item -> setMessage ( $ e -> getMessage ( ) ) -> setImportStatus ( self :: FAILED ) ; $ this -> saveItem ( $ item ) ; continue ; } $ this -> processResponse ( $ response , $ item , $ websiteId ) ; } } } }
Check importing status for pending import .
38,782
public function _processContactImportReportFaults ( $ id , $ websiteId ) { $ client = $ this -> helper -> getWebsiteApiClient ( $ websiteId ) ; $ report = $ client -> getContactImportReportFaults ( $ id ) ; if ( $ report ) { $ reportData = explode ( PHP_EOL , $ this -> _removeUtf8Bom ( $ report ) ) ; unset ( $ reportData [ 0 ] ) ; if ( ! empty ( $ reportData ) ) { $ contacts = [ ] ; foreach ( $ reportData as $ row ) { $ row = explode ( ',' , $ row ) ; if ( in_array ( $ row [ 0 ] , $ this -> reasons ) ) { $ contacts [ ] = $ row [ 1 ] ; } } $ this -> helper -> contactResource -> unsubscribe ( $ contacts ) ; } } }
Get report info for contacts sync .
38,783
public function _getQueue ( $ importType , $ importMode , $ limit ) { return $ this -> getCollection ( ) -> getQueueByTypeAndMode ( $ importType , $ importMode , $ limit ) ; }
Get the imports by type .
38,784
public function setOrderData ( $ orderData ) { $ this -> id = $ orderData -> getIncrementId ( ) ; $ this -> email = $ orderData -> getCustomerEmail ( ) ; $ this -> quoteId = $ orderData -> getQuoteId ( ) ; $ this -> storeName = $ orderData -> getStoreName ( ) ; $ this -> purchaseDate = $ orderData -> getCreatedAt ( ) ; $ this -> deliveryMethod = $ orderData -> getShippingDescription ( ) ; $ this -> deliveryTotal = ( float ) number_format ( $ orderData -> getShippingAmount ( ) , 2 , '.' , '' ) ; $ this -> currency = $ orderData -> getStoreCurrencyCode ( ) ; $ payment = $ orderData -> getPayment ( ) ; if ( $ payment ) { if ( $ payment -> getMethod ( ) ) { $ methodInstance = $ payment -> getMethodInstance ( $ payment -> getMethod ( ) ) ; if ( $ methodInstance ) { $ this -> payment = $ methodInstance -> getTitle ( ) ; } } } $ this -> couponCode = $ orderData -> getCouponCode ( ) ; $ website = $ this -> _storeManager -> getStore ( $ orderData -> getStore ( ) ) -> getWebsite ( ) ; $ customAttributes = $ this -> helper -> getConfigSelectedCustomOrderAttributes ( $ website ) ; if ( $ customAttributes ) { $ fields = $ this -> helper -> getOrderTableDescription ( ) ; $ this -> custom = [ ] ; foreach ( $ customAttributes as $ customAttribute ) { if ( isset ( $ fields [ $ customAttribute ] ) ) { $ field = $ fields [ $ customAttribute ] ; $ value = $ this -> _getCustomAttributeValue ( $ field , $ orderData ) ; if ( $ value ) { $ this -> _assignCustom ( $ field , $ value ) ; } } } } $ this -> processBillingAddress ( $ orderData ) ; $ this -> processShippingAddress ( $ orderData ) ; $ syncCustomOption = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_ORDER_PRODUCT_CUSTOM_OPTIONS , $ website ) ; $ this -> processOrderItems ( $ orderData , $ syncCustomOption ) ; $ this -> orderSubtotal = ( float ) number_format ( $ orderData -> getData ( 'subtotal' ) , 2 , '.' , '' ) ; $ this -> discountAmount = ( float ) number_format ( $ orderData -> getData ( 'discount_amount' ) , 2 , '.' , '' ) ; $ orderTotal = abs ( $ orderData -> getData ( 'grand_total' ) - $ orderData -> getTotalRefunded ( ) ) ; $ this -> orderTotal = ( float ) number_format ( $ orderTotal , 2 , '.' , '' ) ; $ this -> orderStatus = $ orderData -> getStatus ( ) ; unset ( $ this -> _storeManager ) ; return $ this ; }
Set the order data information .
38,785
public function _getStreet ( $ street , $ line ) { $ street = explode ( "\n" , $ street ) ; if ( $ line == 1 ) { return $ street [ 0 ] ; } if ( isset ( $ street [ $ line - 1 ] ) ) { return $ street [ $ line - 1 ] ; } else { return '' ; } }
Get the street name by line number .
38,786
public function expose ( ) { $ properties = array_diff_key ( get_object_vars ( $ this ) , array_flip ( [ '_storeManager' , 'helper' , 'customerFactory' , 'productFactory' , 'attributeCollection' , 'setFactory' , 'attributeSet' , 'productResource' ] ) ) ; $ properties = array_filter ( $ properties ) ; return $ properties ; }
Exposes the class as an array of objects . Return any exposed data that will included into the import as transactinoal data for Orders .
38,787
public function _getCustomAttributeValue ( $ field , $ orderData ) { $ type = $ field [ 'DATA_TYPE' ] ; $ function = 'get' ; $ exploded = explode ( '_' , $ field [ 'COLUMN_NAME' ] ) ; foreach ( $ exploded as $ one ) { $ function .= ucfirst ( $ one ) ; } $ value = null ; try { switch ( $ type ) { case 'int' : case 'smallint' : $ value = ( int ) $ orderData -> $ function ( ) ; break ; case 'decimal' : $ value = ( float ) number_format ( $ orderData -> $ function ( ) , 2 , '.' , '' ) ; break ; case 'timestamp' : case 'datetime' : case 'date' : $ value = $ orderData -> $ function ( ) ; break ; default : $ value = $ orderData -> $ function ( ) ; } } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } return $ value ; }
Get attrubute value for the field .
38,788
public function _getAttributesArray ( $ attributeSetId ) { $ result = [ ] ; $ attributes = $ this -> attributeCollection -> create ( ) -> setAttributeSetFilter ( $ attributeSetId ) -> getItems ( ) ; foreach ( $ attributes as $ attribute ) { $ result [ ] = $ attribute -> getAttributeCode ( ) ; } return $ result ; }
Get attributes from attribute set .
38,789
private function limitLength ( $ value ) { if ( $ this -> stringUtils -> strlen ( $ value ) > \ Dotdigitalgroup \ Email \ Helper \ Data :: DM_FIELD_LIMIT ) { $ value = mb_substr ( $ value , 0 , \ Dotdigitalgroup \ Email \ Helper \ Data :: DM_FIELD_LIMIT ) ; } return $ value ; }
Check string length and limit to 250 .
38,790
private function resetContact ( $ contact ) { if ( $ contact -> getCustomerId ( ) && $ contact -> getEmailImported ( ) ) { $ contact -> setEmailImported ( \ Dotdigitalgroup \ Email \ Model \ Contact :: EMAIL_CONTACT_NOT_IMPORTED ) ; $ this -> contactResource -> save ( $ contact ) ; } elseif ( ! $ contact -> getCustomerId ( ) && $ contact -> getIsSubscriber ( ) && $ contact -> getSubscriberImported ( ) ) { $ contact -> setSubscriberImported ( \ Dotdigitalgroup \ Email \ Model \ Contact :: EMAIL_CONTACT_NOT_IMPORTED ) ; $ this -> contactResource -> save ( $ contact ) ; } }
Reset contact based on type and status
38,791
private function doAutomationEnrolment ( $ data ) { if ( $ data [ 'programId' ] ) { try { $ typeId = $ data [ 'order_id' ] ; $ automationTypeId = $ data [ 'automationType' ] ; $ exists = $ this -> emailAutomationFactory -> create ( ) -> addFieldToFilter ( 'type_id' , $ typeId ) -> addFieldToFilter ( 'automation_type' , $ automationTypeId ) -> setPageSize ( 1 ) ; if ( ! $ exists -> getSize ( ) ) { $ automation = $ this -> automationFactory -> create ( ) -> setEmail ( $ data [ 'email' ] ) -> setAutomationType ( $ data [ 'automationType' ] ) -> setEnrolmentStatus ( \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: AUTOMATION_STATUS_PENDING ) -> setTypeId ( $ data [ 'order_id' ] ) -> setWebsiteId ( $ data [ 'website_id' ] ) -> setStoreName ( $ data [ 'store_name' ] ) -> setProgramId ( $ data [ 'programId' ] ) ; $ this -> automationResource -> save ( $ automation ) ; } } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } } else { $ this -> helper -> log ( 'automation type : ' . $ data [ 'automationType' ] . ' program id not found' ) ; } }
Save enrolment to queue for cron automation enrolment .
38,792
public function reviewSync ( ) { $ this -> orderFactory -> create ( ) -> createReviewCampaigns ( ) ; $ result = $ this -> reviewFactory -> create ( ) -> sync ( ) ; return $ result ; }
Review sync .
38,793
public function sync ( ) { $ response = [ 'success' => true , 'message' => 'Done.' ] ; $ this -> countReviews = 0 ; $ this -> reviews = [ ] ; $ this -> start = microtime ( true ) ; $ websites = $ this -> helper -> getwebsites ( true ) ; foreach ( $ websites as $ website ) { $ apiEnabled = $ this -> helper -> isEnabled ( $ website ) ; $ reviewEnabled = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED , $ website ) ; $ storeIds = $ website -> getStoreIds ( ) ; if ( $ apiEnabled && $ reviewEnabled && ! empty ( $ storeIds ) ) { $ this -> _exportReviewsForWebsite ( $ website ) ; } if ( isset ( $ this -> reviews [ $ website -> getId ( ) ] ) ) { $ reviews = $ this -> reviews [ $ website -> getId ( ) ] ; $ this -> importerFactory -> create ( ) -> registerQueue ( \ Dotdigitalgroup \ Email \ Model \ Importer :: IMPORT_TYPE_REVIEWS , $ reviews , \ Dotdigitalgroup \ Email \ Model \ Importer :: MODE_BULK , $ website -> getId ( ) ) ; $ this -> _setImported ( $ this -> reviewIds ) ; $ this -> countReviews += count ( $ reviews ) ; } } if ( $ this -> countReviews ) { $ message = '----------- Review sync ----------- : ' . gmdate ( 'H:i:s' , microtime ( true ) - $ this -> start ) . ', synced = ' . $ this -> countReviews ; $ this -> helper -> log ( $ message ) ; $ response [ 'message' ] = $ message ; } return $ response ; }
Sync reviews .
38,794
public function _exportReviewsForWebsite ( \ Magento \ Store \ Model \ Website $ website ) { $ limit = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT , $ website ) ; $ emailReviews = $ this -> _getReviewsToExport ( $ website , $ limit ) ; $ this -> reviewIds = [ ] ; if ( $ emailReviews -> getSize ( ) ) { $ ids = $ emailReviews -> getColumnValues ( 'review_id' ) ; $ reviewResourceFactory = $ this -> reviewResourceFactory -> create ( ) ; $ reviews = $ reviewResourceFactory -> getMageReviewsByIds ( $ ids ) ; foreach ( $ reviews as $ mageReview ) { try { $ product = $ reviewResourceFactory -> getProductByIdAndStore ( $ mageReview -> getEntityPkValue ( ) , $ mageReview -> getStoreId ( ) ) ; $ connectorReview = $ this -> connectorReviewFactory -> create ( ) -> setReviewData ( $ mageReview ) -> setProduct ( $ product ) ; $ votesCollection = $ reviewResourceFactory -> getVoteCollectionByReview ( $ mageReview -> getReviewId ( ) ) ; foreach ( $ votesCollection as $ ratingItem ) { $ rating = $ this -> ratingFactory -> create ( ) -> setRating ( $ ratingItem ) ; $ connectorReview -> createRating ( $ ratingItem -> getRatingCode ( ) , $ rating ) ; } $ this -> reviews [ $ website -> getId ( ) ] [ ] = $ connectorReview -> expose ( ) ; $ this -> reviewIds [ ] = $ mageReview -> getReviewId ( ) ; } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } } } }
Export reviews for website .
38,795
public function uninstall ( SchemaSetupInterface $ setup , ModuleContextInterface $ context ) { $ defaultConnection = $ setup -> getConnection ( ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_CONTACT_CONSENT_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_CONTACT_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_ORDER_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_CAMPAIGN_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_REVIEW_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_WISHLIST_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_CATALOG_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_RULES_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_IMPORTER_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_AUTOMATION_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_ABANDONED_CART_TABLE ) ; $ this -> dropTable ( $ setup , Schema :: EMAIL_FAILED_AUTH_TABLE ) ; $ defaultConnection -> dropColumn ( $ this -> getTableNameWithPrefix ( $ setup , 'admin_user' ) , 'refresh_token' ) ; $ defaultConnection -> delete ( $ this -> getTableNameWithPrefix ( $ setup , 'core_config_data' ) , "path LIKE 'connector_api_credentials/%'" ) ; }
Invoked when remove - data flag is set during module uninstall .
38,796
private function _getIframeFormUrl ( ) { $ formUrl = \ Dotdigitalgroup \ Email \ Helper \ Config :: API_CONNECTOR_TRIAL_FORM_URL ; $ ipAddress = $ this -> serverAddress -> getServerAddress ( ) ; if ( $ ipAddress ) { $ ipAddress = $ this -> _request -> getServer ( 'HTTP_X_FORWARDED_FOR' , $ ipAddress ) ; if ( strpos ( $ ipAddress , ',' ) !== false ) { $ ipList = explode ( ',' , $ ipAddress ) ; $ ipAddress = trim ( reset ( $ ipList ) ) ; } } $ timezone = $ this -> _getTimeZoneId ( ) ; $ culture = $ this -> _getCultureId ( ) ; $ company = $ this -> helper -> getWebsiteConfig ( \ Magento \ Store \ Model \ Information :: XML_PATH_STORE_INFO_NAME ) ; $ callback = $ this -> helper -> storeManager -> getStore ( ) -> getBaseUrl ( \ Magento \ Framework \ UrlInterface :: URL_TYPE_WEB , true ) . 'connector/email/accountcallback' ; $ params = [ 'callback' => $ callback , 'company' => $ company , 'culture' => $ culture , 'timezone' => $ timezone , 'ip' => $ ipAddress , 'code' => $ this -> trialSetup -> generateTemporaryPasscode ( ) ] ; $ url = $ formUrl . '?' . http_build_query ( $ params ) ; return $ url ; }
Generate url for iframe for trial account popup .
38,797
private function _getTimeZoneId ( ) { $ timeZone = $ this -> localeDate -> getConfigTimezone ( ) ; $ result = '085' ; if ( $ timeZone ) { foreach ( $ this -> timeZones as $ time ) { if ( $ time [ 'MageTimeZone' ] == $ timeZone ) { $ result = $ time [ 'MicrosoftTimeZoneIndex' ] ; } } } return $ result ; }
Get time zone id for trial account .
38,798
private function _getCultureId ( ) { $ fallback = 'en_US' ; $ supportedCultures = [ 'en_US' => '1033' , 'en_GB' => '2057' , 'fr_FR' => '1036' , 'es_ES' => '3082' , 'de_DE' => '1031' , 'it_IT' => '1040' , 'ru_RU' => '1049' , 'pt_PT' => '2070' , ] ; $ localeCode = $ this -> helper -> getWebsiteConfig ( \ Magento \ Directory \ Helper \ Data :: XML_PATH_DEFAULT_LOCALE ) ; if ( isset ( $ supportedCultures [ $ localeCode ] ) ) { return $ supportedCultures [ $ localeCode ] ; } return $ supportedCultures [ $ fallback ] ; }
Get culture id needed for trial account .
38,799
public function execute ( ) { $ quoteId = $ this -> getRequest ( ) -> getParam ( 'quote_id' ) ; if ( ! $ quoteId ) { return $ this -> _redirect ( '' ) ; } $ quoteModel = $ this -> quoteFactory -> create ( ) ; $ this -> quoteResource -> load ( $ quoteModel , $ quoteId ) ; if ( ! $ quoteModel -> getId ( ) ) { return $ this -> _redirect ( '' ) ; } $ this -> quote = $ quoteModel ; if ( $ quoteModel -> getCustomerId ( ) ) { return $ this -> handleCustomerBasket ( ) ; } else { return $ this -> handleGuestBasket ( ) ; } }
Wishlist page to display the user items with specific email .