I’m uploading products via the Magento API and they are not showing up in the frontend. I have to go into the backend, open them up, change nothing, save the product and then it will appear.
Any idea why? I assume the act of saving it in the back end, is saving some extra flags in the DB, I just don’t know what.
@Steve Madsen. here is the code, I don't think I'm missing anything crucial, as the backend interface would prompt me of it, then I open of the product.
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");
}
I've seen a lot of cases where something inserted into the Magento databases manually, or via the API, will have a missing attribute that, for whatever reason, is set to a default value when saved in the Magento UI. The UI is setting the default values properly, whereas the API or database inserts don't set the attribute.
So, in your case, my first line of debugging would be
Magento uses an Entity Attribute Value modeling scheme, which optimizing for database flexibility rather than querying. Long story short, you can run the following queries to get your basic product attribute values.
You'll want to replace every instance of [3455] with the a product id from your database. You can get this ID by examining the URL of a proudct in the Magento Admin UI. You can run the query without the WHERE clauses, although the default indexing isn't optimized for this use case, and you'll get a slowish query depending on your database size.
SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_varchar.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_varchar ON catalog_product_entity.entity_id = catalog_product_entity_varchar.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_varchar.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455
UNION
SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_text.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_text ON catalog_product_entity.entity_id = catalog_product_entity_text.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_text.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455
UNION
SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_datetime.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_datetime ON catalog_product_entity.entity_id = catalog_product_entity_datetime.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_datetime.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455
UNION
SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_decimal.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_decimal ON catalog_product_entity.entity_id = catalog_product_entity_decimal.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_decimal.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455
UNION
SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_gallery.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_gallery ON catalog_product_entity.entity_id = catalog_product_entity_gallery.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_gallery.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455
UNION
SELECT eav_attribute.frontend_label, eav_attribute.attribute_code,
catalog_product_entity_int.value
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_int ON catalog_product_entity.entity_id = catalog_product_entity_int.entity_id
LEFT JOIN eav_attribute on catalog_product_entity_int.attribute_id = eav_attribute.attribute_id
WHERE catalog_product_entity.entity_id = 3455;