1
votes

I trying to create product programmatically, but it not showing at category page (at "frontend"). I use next code (yes, bad code, but it is one-time task)

$product = new Mage_Catalog_Model_Product();
...
$product->getResource()->save($product);
$product_id = $product->getId();

foreach (array($default_cat, $category_id) as $cat_id) {
    Mage::getSingleton('catalog/category_api')->assignProduct($cat_id,$product_id);
}

It succesfully create product, but when I open category page - it doesn't contain product. When I open product edit page and click "save" - product also added to category page...

What I can do?

UPD. Cache clearing and rendexing doesn't help... And, when I open product edit page - categories list are correct

UPD2. Reason was in qty/stock.

1
Not working for me... Code at link, it's add_product functionuser2726251
have you assign website & inventory stock?Shivam

1 Answers

0
votes

$product->setCategoryIds(1,2,3,4,5)->save()
?