Products created through Magento API don't display on storefront until manually resaved in admin

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");
}

I hit this same problem with Magento’s SOAP API. Your code’s missing the visibility setting - without it, products default to “Not Visible Individually” when created via API. Add visibility to your custom attributes array and set it to “4” for catalog and search visibility. Also make sure you’re assigning the product to a website and category during creation. Products won’t show on the frontend without proper website assignment, no matter what else you set. When you manually save in admin, it handles these assignments automatically - that’s why it fixes the issue.

totally agree, it’s likely tied to the cache not bein updated. When you hit save in admin, it might force the reindexing, but API calls don’t do that. You could try runnin a manual reindex or see if there’s an option in the API to clear cache. hope this helps!

Interesting issue! Are you setting website_ids when creating through the API? What Magento version are you runnin? Indexin can behave differently between versions. Did you check if your products appear in the catalog_product_entity table right after API creation?