I’m creating products using Magento’s API but they won’t show up on my website’s frontend. The only way to make them visible is to go into the admin panel, open each product, make no changes at all, and hit save. Then suddenly they appear on the storefront.
Does anyone know what’s causing this? I think when I save manually in the admin, it’s setting some database fields that my API call isn’t handling properly.
public void CreateProduct(Item item)
{
var productData = new catalogProductCreateEntity();
productData.name = item.Title;
productData.description = item.FullDescription;
productData.price = item.Cost.ToString();
productData.short_description = item.Summary;
productData.status = "1";
productData.weight = "0";
productData.tax_class_id = "2";
productData.gift_message_available = "0";
var customAttributes = new associativeEntity[4];
var attr = new associativeEntity();
attr.key = "shipping_cost";
attr.value = item.ShippingPrice;
customAttributes[0] = attr;
attr = new associativeEntity();
attr.key = "item_depth";
attr.value = item.DepthValue;
customAttributes[1] = attr;
attr = new associativeEntity();
attr.key = "item_height";
attr.value = item.HeightValue;
customAttributes[2] = attr;
attr = new associativeEntity();
attr.key = "item_width";
attr.value = item.WidthValue;
customAttributes[3] = attr;
productData.additional_attributes = customAttributes;
_magento.catalogProductCreate(SessionManager.GetCurrentSession(), "simple", "26", item.ProductCode, productData);
var inventory = new catalogInventoryStockItemUpdateEntity();
inventory.manage_stock = 0;
inventory.qty = "0";
_magento.catalogInventoryStockItemUpdate(SessionManager.GetCurrentSession(), item.ProductCode, inventory);
Console.WriteLine(item.Title + " has been created");
}