Try our conversational search powered by Generative AI!

Price

Vote:
 

Hi everyone !

I would like to use a csv file including prices for items, this file will be updated via ftp, I'd like to know how to include the price in episerver trade, create products in catalogs?


Thanks for your help !

#65954
Feb 15, 2013 15:05
Vote:
 

The answer is more that one sentence, but in general what you should do is to create mapping xml files which will describe mapping from CSV file structure to corresponding entities in the Commerce. "Product" may consist of more that just one record in DB. It may be product or variation, ir may have records in inventory (stock availability), pricing, associations and even SEO settings, etc.

I would recoemmend you to look in Commerce Manager -> Catalog Management -> Import / Export -> CSV Import Catalog. Using this section you are able to "train" import process to understand your CSV file structure and map CSV data to Commerce entities.

You can get more info in this guide: http://webhelp.episerver.com/Commerce/1.2/#User%20Guide/CatalogManagement/Using%20CSV%20Files%20to%20Quickly.htm

#66031
Feb 18, 2013 17:36
Vote:
 

Tks for your answer.

#66100
Feb 20, 2013 10:25
Vote:
 

DO you have any examples of doing this as an import via a webservice  - I need to find a way how to set up the new products, thier variants together with Prices and Inventory.

#81257
Feb 12, 2014 17:23
Vote:
 

I bet that "via webservice" would be pretty lenghty reply, but I can share snippet for creating products and part of sales prices under inventory:

var entry = CatalogContext.Current.GetCatalogEntryDto(importEntry.EntryCode, catalogEntryResponseGroup);
var entryRow = entry.CatalogEntry.Count == 0 ? entry.CatalogEntry.NewCatalogEntryRow() : entry.CatalogEntry[0];
var inventoryRow = entry.Inventory.Count == 0 ? entry.Inventory.NewInventoryRow() : entry.Inventory[0];

// do stuff with entry
entryRow.ApplicationId = AppContext.Current.ApplicationId;
entryRow.CatalogId = catalogId;
if (entryRow.IsNew())
{
    entryRow.Code = entryCode;
    entryRow.Name = entryName;
    ....
}

// create or update variation data
var variationRow = entry.Variation.Count == 0 ? entry.Variation.NewVariationRow() : entry.Variation[0];
variationRow.CatalogEntryId = entryRow.CatalogEntryId;
if (variationRow.IsNew())
{
    variationRow.ListPrice = importEntry.UnitPrice.GetValueOrDefault(0);
    variationRow.MaxQuantity = 100;
    ...
}

// update inventory
inventoryRow.ApplicationId = AppContext.Current.ApplicationId;
inventoryRow.SkuId = skuId;
inventoryRow.AllowBackorder = true;
...
entry.Inventory.AddInventoryRow(inventoryRow);

// save entry
CatalogContext.Current.SaveCatalogEntry(entry);

    

Also you need to bind associations between entry and any other catalog nodes if needed. Following code snippet should give you some hints:

// add association
private CatalogRelationDto.NodeEntryRelationRow AddNodeRelation(
        CatalogRelationDto relation,
        int catalogEntryId,
        ImportEntry importEntry,
        int catalogId,
        int catalogNodeId)
{
    var nodeRelation = relation.NodeEntryRelation.NewNodeEntryRelationRow();
    nodeRelation.CatalogId = catalogId;
    nodeRelation.CatalogEntryId = catalogEntryId;
    nodeRelation.CatalogNodeId = catalogNodeId;

    if (nodeRelation.IsNew())
    {
        nodeRelation.SortOrder = importEntry.SortOrder.GetValueOrDefault(0);
    }
    else
    {
        if (this.schema.IsSortOrderSupplied && importEntry.SortOrder.HasValue)
        {
            nodeRelation.SortOrder = (int)importEntry.SortOrder;
        }
    }

    if (nodeRelation.IsNew())
    {
        relation.NodeEntryRelation.AddNodeEntryRelationRow(nodeRelation);
    }

    return nodeRelation;
}

    

 

When it comes to "via webservice" - my guess is that this is just a matter of *where* exactly import logic is located and who is initiator of the process. Other than that - Commerce logic and code should remain the same regardless via which "integration interface" products are pushed into the commerce db...

#81262
Feb 13, 2014 0:42
Vote:
 

HI, this is great. Many thanks.

#81270
Feb 13, 2014 9:03
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.