Reputation: 69
I wonder if anyone can help me with this. I've tried both methods below to programmatically add a product to a website (tick to a website an existing product, not create one) but neither made the product available on front-end. Back-end added fine.
Method 1
$product = Mage::getModel('catalog/product')->load(6318);
$product->setWebsiteIds(array(1));
$product->setStatus(1);
$product->save();
Method 2
$websiteId = array(1);
$productId = array(6318);
$actionModel = Mage::getSingleton('catalog/product_action');
$actionModel->updateWebsites($productId, $websiteId, 'add');
Tried with reindex as well but nothing.
$process = Mage::getModel('index/indexer')->getProcessByCode('catalog_product_attribute');
$process->reindexAll();
I have done full cache clearing as well as full reindex from back-end but nothing.
Any ideas?
Thanks a lot! Leo
Upvotes: 1
Views: 1498
Reputation: 404
Follow some following steps in admin, edit product you created and check
1. Status of product ( must be enabled )
2. Stock Availability ( must be in stock )
3. Its qty
4. Websites ( if available must be checked )
5. Add product in some category and open that category on frontend.
If any value is missing or wrong then add/change that and check frontend.
Upvotes: 1