This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Add_A_Product_Attribute_List_Option() | |
{ | |
//enter your context info | |
var apiContext = new Mozu.Api.ApiContext(tenantId: 14617, masterCatalogId: 1, catalogId: 1); | |
//create a new attribute resource | |
var attributeResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.AttributeResource(apiContext); | |
//define the attribute name | |
var attributeName = "Purse-Size"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private System.Collections.Concurrent.ConcurrentDictionary<string,string> ImportCustomers(IEnumerable<Mozu.Api.Contracts.Customer.CustomerAccountAndAuthInfo> accountAuthCollection) | |
{ | |
var accountResource = new Mozu.Api.Resources.Commerce.Customer.CustomerAccountResource(_apiContext); | |
var contactResource = new Mozu.Api.Resources.Commerce.Customer.Accounts.CustomerContactResource(_apiContext); | |
var accountExternalIds = new System.Collections.Concurrent.ConcurrentDictionary<string, string>(); | |
Parallel.ForEach(accountAuthCollection, new System.Threading.Tasks.ParallelOptions() { MaxDegreeOfParallelism = 1 }, accountAuthInfo => | |
{ | |
var filter = string.Format("ExternalId eq '{0}'", accountAuthInfo.Account.ExternalId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private System.Collections.Concurrent.ConcurrentDictionary<string,string> ImportCustomers(IEnumerable<Mozu.Api.Contracts.Customer.CustomerAccountAndAuthInfo> accountAuthCollection) | |
{ | |
var accountResource = new Mozu.Api.Resources.Commerce.Customer.CustomerAccountResource(_apiContext); | |
var contactResource = new Mozu.Api.Resources.Commerce.Customer.Accounts.CustomerContactResource(_apiContext); | |
var accountExternalIds = new System.Collections.Concurrent.ConcurrentDictionary<string, string>(); | |
Parallel.ForEach(accountAuthCollection, new System.Threading.Tasks.ParallelOptions() { MaxDegreeOfParallelism = 1 }, accountAuthInfo => | |
{ | |
var filter = string.Format("ExternalId eq '{0}'", accountAuthInfo.Account.ExternalId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Mozu.Api.Contracts.Customer.CustomerAccount MapCustomerAccount(System.Data.DataRow drAccount) | |
{ | |
var mappedAccount = new Mozu.Api.Contracts.Customer.CustomerAccount() | |
{ | |
ExternalId = drAccount["Id"].ToString(), | |
EmailAddress = drAccount["Email"].ToString(), | |
FirstName = drAccount["FirstName"].ToString(), | |
LastName = drAccount["LastNameOrSurname"].ToString(), | |
CompanyOrOrganization = drAccount["CompanyOrOrganization"].ToString(), | |
TaxExempt = Convert.ToBoolean(drAccount["TaxExempt"]), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Mozu.Api.Contracts.Customer.CustomerLoginInfo MapCustomerLoginInfo(System.Data.DataRow drAccount) | |
{ | |
var mappedAccountAndAuthInfo = new Mozu.Api.Contracts.Customer.CustomerLoginInfo() | |
{ | |
IsImport = true, | |
EmailAddress = drAccount["Email"].ToString(), | |
Password = drAccount["Password"].ToString(), | |
Username = drAccount["Username"].ToString(), | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Mozu.Api.Contracts.Customer.CustomerContact MapCustomerContact(System.Data.DataRow drContact) | |
{ | |
var mappedContact = new Mozu.Api.Contracts.Customer.CustomerContact() | |
{ | |
CompanyOrOrganization = drContact["CompanyOrOrganization"].ToString(), | |
Email = drContact["Email"].ToString(), | |
FaxNumber = drContact["FaxNumber"].ToString(), | |
FirstName = drContact["FirstName"].ToString(), | |
LastNameOrSurname = drContact["LastNameOrSurname"].ToString(), | |
MiddleNameOrInitial = drContact["MiddleNameOrInitial"].ToString(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private System.Data.DataTable GetAccountTestData() | |
{ | |
var tblAccount = new System.Data.DataTable(); | |
tblAccount.Columns.Add("Id"); | |
tblAccount.Columns.Add("AccountID"); | |
tblAccount.Columns.Add("UserName"); | |
tblAccount.Columns.Add("Email"); | |
tblAccount.Columns.Add("Password"); | |
tblAccount.Columns.Add("FirstName"); | |
tblAccount.Columns.Add("LastNameOrSurname"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private System.Data.DataTable GetContactTestData() | |
{ | |
var tblContact = new System.Data.DataTable(); | |
tblContact.Columns.Add("Id"); | |
tblContact.Columns.Add("Type"); | |
tblContact.Columns.Add("IsPrimary"); | |
tblContact.Columns.Add("CompanyOrOrganization"); | |
tblContact.Columns.Add("FirstName"); | |
tblContact.Columns.Add("MiddleNameorInitial"); | |
tblContact.Columns.Add("LastNameOrSurname"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void Add_Customer_Accounts_Test() | |
{ | |
var tblAccounts = GetAccountTestData(); | |
var tblContacts = GetContactTestData(); | |
var accountAndAuths = new List<Mozu.Api.Contracts.Customer.CustomerAccountAndAuthInfo>(); | |
foreach(System.Data.DataRow drAcct in tblAccounts.Rows) | |
{ | |
var customerLoginInfo = MapCustomerLoginInfo(drAcct); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MozuExtensions | |
{ | |
public static class MozuExtensions | |
{ | |
/// <summary> | |
/// Retrieves all products from the master catalog using the tenant that was supplied when Mozu.Api.Resources.Commerce.Catalog.Admin.ProductResource was created. | |
/// <para /> | |
/// Accepts an optional pageSize parameter -- pageSize is set to 200 by default. | |
/// </summary> | |
/// <param name="productResource"></param> |
OlderNewer