예제 #1
0
        public CustomerHelper(string connectionString)
            : base(connectionString)
        {
            AutoMapper.Mapper.CreateMap <IDataReader, customer_entity>();
            AutoMapper.Mapper.CreateMap <IDataRecord, customer_entity>();

            AutoMapper.Mapper.CreateMap <IDataReader, customer_address_entity>();
            AutoMapper.Mapper.CreateMap <IDataRecord, customer_address_entity>();

            address_line_id_attribute = GetAttribute("address_line_id");
        }
예제 #2
0
        private void SyncCustomerEntityDateTime(magentoContext container, eav_attribute attribute, Expression <Func <customer_entity_datetime, bool> > predicate, DateTime value, long entityID, int entityTypeID = 1)
        {
            var entity = container.customer_entity_datetime.Where(c => c.attribute_id == attribute.attribute_id).FirstOrDefault(predicate);

            if (entity == null)
            {
                entity = new customer_entity_datetime()
                {
                    entity_id      = entityID,
                    eav_attribute  = attribute,
                    entity_type_id = entityTypeID
                };
                container.AddTocustomer_entity_datetime(entity);
            }
            entity.value = value;
        }
예제 #3
0
        private void SyncCustomerAddressEntityText(magentoContext container, eav_attribute attribute, Expression <Func <customer_address_entity_text, bool> > predicate, string value, long entityID)
        {
            var entity = container.customer_address_entity_text.Where(c => c.attribute_id == attribute.attribute_id).FirstOrDefault(predicate);

            if (entity == null)
            {
                entity = new customer_address_entity_text()
                {
                    eav_attribute  = attribute,
                    entity_type_id = 2,
                    entity_id      = entityID
                };
                container.AddTocustomer_address_entity_text(entity);
            }
            entity.value = value;
        }
예제 #4
0
        private long SyncAddress(magentoContext container, string country,
                                 eav_attribute countryAttribute, string city,
                                 eav_attribute cityAttribute, string telephones,
                                 eav_attribute telephoneAttribute,
                                 long backEndRelationID,
                                 string company,
                                 eav_attribute companyAttribute, string postcode,
                                 eav_attribute postcodeAttribute, eav_attribute firstNameAddressAttribute,
                                 eav_attribute lastNameAddressAttribute, eav_attribute telephoneAddressAttribute,
                                 string addressLines, eav_attribute addressLinesAttribute,
                                 long addressEntityID = 0)
        {
            customer_address_entity customerAddressEntity = null;

            if (addressEntityID == 0)
            {
                customerAddressEntity = container.customer_address_entity.FirstOrDefault(c => c.parent_id == backEndRelationID && c.customer_address_entity_text.Any(al => al.value == addressLines));
                if (customerAddressEntity == null)
                {
                    customerAddressEntity = new customer_address_entity()
                    {
                        entity_type_id   = 2,
                        attribute_set_id = 0,
                        increment_id     = "0",
                        parent_id        = backEndRelationID,
                        created_at       = DateTime.Now,
                        updated_at       = DateTime.Now,
                        is_active        = true
                    };
                    container.AddTocustomer_address_entity(customerAddressEntity);
                    container.SaveChanges();
                }
                addressEntityID = customerAddressEntity.entity_id;
            }

            SyncCustomerAddressEntityVarchar(container, telephoneAttribute, (c => c.entity_id == addressEntityID), addressEntityID, telephones);
            SyncCustomerAddressEntityVarchar(container, countryAttribute, (c => c.entity_id == addressEntityID), addressEntityID, country);
            SyncCustomerAddressEntityVarchar(container, cityAttribute, (c => c.entity_id == addressEntityID), addressEntityID, city);
            SyncCustomerAddressEntityVarchar(container, companyAttribute, (c => c.entity_id == addressEntityID), addressEntityID, company);
            SyncCustomerAddressEntityVarchar(container, postcodeAttribute, (c => c.entity_id == addressEntityID), addressEntityID, postcode);
            SyncCustomerAddressEntityVarchar(container, firstNameAddressAttribute, (c => c.entity_id == addressEntityID), addressEntityID);
            SyncCustomerAddressEntityVarchar(container, lastNameAddressAttribute, (c => c.entity_id == addressEntityID), addressEntityID);
            SyncCustomerAddressEntityVarchar(container, telephoneAddressAttribute, (c => c.entity_id == addressEntityID), addressEntityID);
            SyncCustomerAddressEntityText(container, addressLinesAttribute, (c => c.entity_id == addressEntityID), addressLines, addressEntityID);

            return(addressEntityID);
        }
예제 #5
0
        private void SyncCustomerEntityDecimal(magentoContext container, eav_attribute attribute, Expression <Func <customer_entity_decimal, bool> > predicate, decimal value, long entityID, int entityTypeID = 1)
        {
            attribute.backend_type = "decimal";

            var entity = container.customer_entity_decimal.Where(c => c.attribute_id == attribute.attribute_id).FirstOrDefault(predicate);

            if (entity == null)
            {
                entity = new customer_entity_decimal()
                {
                    entity_id      = entityID,
                    eav_attribute  = attribute,
                    entity_type_id = entityTypeID
                };
                container.AddTocustomer_entity_decimal(entity);
            }
            entity.value = value;
        }
예제 #6
0
        protected void SyncRequiredCatalogAttributes()
        {
            using (var helper = new AssortmentHelper(Connector.Connection, Version))
            {
                var attributes = helper.GetAttributeList(CATEGORY_ENTITY_TYPE_ID);

                eav_attribute att = null;
                attributes.TryGetValue("icecat_cat_id", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("icecat_cat_id", CATEGORY_ENTITY_TYPE_ID, "icecat_cat_id", "int", is_required: true);
                }
                else
                {
                    att.is_required     = false;
                    att.is_user_defined = false;
                }

                helper.SyncAttribute(att, addToDefaultSet: true);

                attributes = helper.GetAttributeList(PRODUCT_ENTITY_TYPE_ID);
                if (!attributes.TryGetValue("concentrator_product_id", out att))
                {
                    att = helper.CreateAttribute("concentrator_product_id", PRODUCT_ENTITY_TYPE_ID, "concentrator_product_id", "int", is_visible: false);
                }
                else
                {
                    att.frontend_label          = "Concentrator ID";
                    att.is_required             = false;
                    att.is_user_defined         = false;
                    att.used_in_product_listing = true;
                }

                helper.SyncAttribute(att, addToDefaultSet: true);

                if (!attributes.TryGetValue("barcode", out att))
                {
                    att = helper.CreateAttribute("barcode", PRODUCT_ENTITY_TYPE_ID, "barcode", "varchar");
                }
                else
                {
                    att.frontend_label  = "Barcode";
                    att.is_required     = false;
                    att.is_user_defined = false;
                    att.is_searchable   = true;
                }
                helper.SyncAttribute(att, addToDefaultSet: true);

                if (!attributes.TryGetValue("stock_status", out att))
                {
                    att = helper.CreateAttribute("stock_status", PRODUCT_ENTITY_TYPE_ID, "stock_status", "varchar", is_visible: false);
                }
                else
                {
                    att.frontend_label  = "Stock Status";
                    att.is_required     = false;
                    att.is_user_defined = false;
                }
                helper.SyncAttribute(att, addToDefaultSet: true);



                if (!attributes.TryGetValue("quantity_to_receive", out att))
                {
                    att = helper.CreateAttribute("quantity_to_receive", PRODUCT_ENTITY_TYPE_ID, "quantity_to_receive", "int", is_visible: false);
                }
                else
                {
                    att.frontend_label  = "Quantity on PO";
                    att.is_required     = false;
                    att.is_user_defined = false;
                }
                helper.SyncAttribute(att, addToDefaultSet: true);

                if (!attributes.TryGetValue("promised_delivery_date", out att))
                {
                    att = helper.CreateAttribute("promised_delivery_date", PRODUCT_ENTITY_TYPE_ID, "promised_delivery_date", "date", is_visible: true, used_in_product_listing: true);
                }
                else
                {
                    att.frontend_label          = "Promised Delivery Date";
                    att.frontend_input          = "date";
                    att.is_required             = false;
                    att.is_user_defined         = false;
                    att.is_visible              = false;
                    att.used_in_product_listing = true;
                }
                helper.SyncAttribute(att, addToDefaultSet: true);

                if (!attributes.TryGetValue("custom_item_number", out att))
                {
                    att = helper.CreateAttribute("custom_item_number", PRODUCT_ENTITY_TYPE_ID, "custom_item_number", "varchar", is_visible: true, used_in_product_listing: true, is_searchable: true);
                }
                else
                {
                    att.frontend_label          = "Custom Item Number";
                    att.is_required             = false;
                    att.is_user_defined         = false;
                    att.is_visible              = false;
                    att.used_in_product_listing = false;
                    att.is_searchable           = true;
                }
                helper.SyncAttribute(att, addToDefaultSet: true);

                if (!attributes.TryGetValue("commercial_status", out att))
                {
                    att = helper.CreateAttribute("commercial_status", PRODUCT_ENTITY_TYPE_ID, "commercial_status", "varchar", is_visible: true, used_in_product_listing: true);
                }
                else
                {
                    att.frontend_label          = "Commercial Status";
                    att.is_required             = false;
                    att.is_user_defined         = false;
                    att.is_visible              = false;
                    att.used_in_product_listing = true;
                }
                helper.SyncAttribute(att, addToDefaultSet: true);
            }
        }
예제 #7
0
        private void SyncRequiredCustomerAttributes()
        {
            using (var helper = new CustomerHelper(Connector.Connection))
            {
                var attributes        = helper.GetAttributeList(CUSTOMER_ENTITY_TYPE_ID);
                var addressAttributes = helper.GetAttributeList(CUSTOMER_ADDRESS_ENTITY_TYPE_ID);

                #region Basic Customer data
                eav_attribute att = null;

                attributes.TryGetValue("account_number", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("account_number", CUSTOMER_ENTITY_TYPE_ID, "account_number", "int", is_required: true);
                }
                att.is_required     = true;
                att.is_user_defined = true;

                att.frontend_label = "Account Number";

                helper.SyncAttribute(att, addToDefaultSet: true);


                attributes.TryGetValue("parent_customer_id", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("parent_customer_id", CUSTOMER_ENTITY_TYPE_ID, "parent_customer_id", "int", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Parent Customer ID";



                attributes.TryGetValue("company_name", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("company_name", CUSTOMER_ENTITY_TYPE_ID, "company_name", "varchar", is_required: true);
                }
                att.is_required     = true;
                att.is_user_defined = true;

                att.frontend_label = "Company Name";

                helper.SyncAttribute(att, addToDefaultSet: true);



                attributes.TryGetValue("store_name", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("store_name", CUSTOMER_ENTITY_TYPE_ID, "store_name", "varchar", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Store Name";

                helper.SyncAttribute(att, addToDefaultSet: true);


                attributes.TryGetValue("website", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("website", CUSTOMER_ENTITY_TYPE_ID, "website", "varchar", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Website";

                helper.SyncAttribute(att, addToDefaultSet: true);



                attributes.TryGetValue("segment", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("segment", CUSTOMER_ENTITY_TYPE_ID, "segment", "varchar", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Segment";

                helper.SyncAttribute(att, addToDefaultSet: true);


                attributes.TryGetValue("purchase_group", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("purchase_group", CUSTOMER_ENTITY_TYPE_ID, "purchase_group", "varchar", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Purchase Group";

                helper.SyncAttribute(att, addToDefaultSet: true);

                attributes.TryGetValue("electronic_invoice", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("electronic_invoice", CUSTOMER_ENTITY_TYPE_ID, "electronic_invoice", "int", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;
                att.frontend_input  = "boolean";

                att.frontend_label = "Electronic Invoice";

                helper.SyncAttribute(att, addToDefaultSet: true);

                #endregion


                attributes.TryGetValue("new_account_confirmed", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("new_account_confirmed", CUSTOMER_ENTITY_TYPE_ID, "new_account_confirmed", "int", is_required: true);
                }
                att.is_required     = true;
                att.is_user_defined = true;
                att.frontend_input  = "boolean";
                att.frontend_label  = "New Account Confirmed";

                helper.SyncAttribute(att, addToDefaultSet: true);


                attributes.TryGetValue("pending_change", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("pending_change", CUSTOMER_ENTITY_TYPE_ID, "pending_change", "int", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;
                att.frontend_input  = "boolean";
                att.frontend_label  = "Pending Change";


                attributes.TryGetValue("created_in", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("created_in", CUSTOMER_ENTITY_TYPE_ID, "created_in", "varchar", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Source System";

                helper.SyncAttribute(att, addToDefaultSet: true);


                attributes.TryGetValue("account_manager_name", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("account_manager_name", CUSTOMER_ENTITY_TYPE_ID, "account_manager_name", "varchar", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Account Manager";

                helper.SyncAttribute(att, addToDefaultSet: true);

                attributes.TryGetValue("invoice_amount", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("invoice_amount", CUSTOMER_ENTITY_TYPE_ID, "invoice_amount", "decimal", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;
                att.backend_type    = "decimal";
                att.frontend_label  = "Invoice Amount";

                helper.SyncAttribute(att, addToDefaultSet: true);

                attributes.TryGetValue("invoice_amount_open", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("invoice_amount_open", CUSTOMER_ENTITY_TYPE_ID, "invoice_amount_open", "decimal", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;
                att.backend_type    = "decimal";
                att.frontend_label  = "Open Invoice Amount";

                helper.SyncAttribute(att, addToDefaultSet: true);



                attributes.TryGetValue("default_carrier", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("default_carrier", CUSTOMER_ENTITY_TYPE_ID, "default_carrier", "int", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Default Carrier ID";

                helper.SyncAttribute(att, addToDefaultSet: true);


                attributes.TryGetValue("default_carrier_name", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("default_carrier_name", CUSTOMER_ENTITY_TYPE_ID, "default_carrier_name", "varchar", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Default Carrier";

                helper.SyncAttribute(att, addToDefaultSet: true);

                attributes.TryGetValue("route_code", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("route_code", CUSTOMER_ENTITY_TYPE_ID, "route_code", "varchar", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Route Code";

                helper.SyncAttribute(att, addToDefaultSet: true);

                attributes.TryGetValue("credit_limit", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("credit_limit", CUSTOMER_ENTITY_TYPE_ID, "credit_limit", "decimal", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;
                att.backend_type    = "decimal";
                att.frontend_label  = "Credit Limit";

                helper.SyncAttribute(att, addToDefaultSet: true);


                attributes.TryGetValue("payment_days", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("payment_days", CUSTOMER_ENTITY_TYPE_ID, "payment_days", "varchar", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;
                att.frontend_label  = "Payment Days";
                helper.SyncAttribute(att, addToDefaultSet: true);


                attributes.TryGetValue("payment_instrument", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("payment_instrument", CUSTOMER_ENTITY_TYPE_ID, "payment_instrument", "varchar", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Payment Instrument";


                helper.SyncAttribute(att, addToDefaultSet: true);



                addressAttributes.TryGetValue("address_line_id", out att);
                if (att == null)
                {
                    att = helper.CreateAttribute("address_line_id", CUSTOMER_ADDRESS_ENTITY_TYPE_ID, "address_line_id", "int", is_required: false);
                }
                att.is_required     = false;
                att.is_user_defined = true;

                att.frontend_label = "Address Line ID";


                helper.SyncAttribute(att, addToDefaultSet: true);
            }
        }