我正在通过 Magento API 上传产品,但它们没有出现在前端。我必须进入后端,打开它们,什么都不做,保存产品,然后它就会出现。
知道为什么吗?我假设将它保存在后端的行为是在数据库中保存一些额外的标志,我只是不知道是什么。
@史蒂夫马德森。这是代码,我认为我没有遗漏任何重要的东西,因为后端界面会提示我,然后我打开产品。
public void Import(Product product)
{
var mageProduct = new catalogProductCreateEntity();
mageProduct.name = product.Name;
mageProduct.description = product.Description;
mageProduct.price = product.Price.ToString();
mageProduct.short_description = product.ShortDescription;
mageProduct.description = product.Description;
mageProduct.status = "1";
mageProduct.weight = "0";
mageProduct.tax_class_id = "2";
mageProduct.gift_message_available = "0";
var additionalattributes = new associativeEntity[4];
var entity = new associativeEntity();
entity.key = "ship_price";
entity.value = product.PostageCost;
additionalattributes[0] = entity;
entity = new associativeEntity();
entity.key = "depth_cm";
entity.value = product.Depth;
additionalattributes[1] = entity;
entity = new associativeEntity();
entity.key = "height_cm";
entity.value = product.Height;
additionalattributes[2] = entity;
entity = new associativeEntity();
entity.key = "width_cm";
entity.value = product.Width;
additionalattributes[3] = entity;
mageProduct.additional_attributes = additionalattributes;
_m.catalogProductCreate(MageSessionProvider.GetSession(), "simple", "26", product.SKU, mageProduct);
var stock = new catalogInventoryStockItemUpdateEntity();
stock.manage_stock = 0;
stock.qty = "0";
_m.catalogInventoryStockItemUpdate(MageSessionProvider.GetSession(), product.SKU, stock);
Console.WriteLine(product.Name + " imported");
}