Magento - Programmatically added products don't show up

旧时模样 提交于 2020-01-15 03:20:47

问题


I am trying to import products using a custom made import profile. Here I set some values on the product and then save it, like this:

$product = Mage::getModel('catalog/product');
$data = array();
// Inbetween I fill $data with some values
$product->addData($data);
$product->save();

However, the products do show up in the admin, but do not show up on the frontend (I did add them to categories).

The odd thing is, they do appear on the frontend once I open them in the admin and save them again (without modifying anything). Am I forgetting something, or some value that is somehow set by that action?

I tried to rebuild all indices in the backend and to clear the cache, but this does not work, contrary to Magento API: Rebuild Indexes after adding new products.


回答1:


Some guesses, since this comes up from time to time. See also here.




回答2:


I had the same problem and solved it by adding the Website ID to the product:

$newProduct ->setWebsiteIds(array(1))

Keep in mind that the parameter is an array, so you can add multiple website td's



来源:https://stackoverflow.com/questions/4555371/magento-programmatically-added-products-dont-show-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!