这几天折腾了好久, magento 后台 分类下产品是有的。可是在前台就是没办法显示出来。
一开始以为是catalog_category_product_index 表无法重新index而造成无法生成数据。
后来才知道 原来是 Visibility 这个字段搞的鬼。
$product = Mage::getModel('catalog/product')
$product->setVisibility(4)->save();
visibility = 1 代表 not visible
=2 代表 在目录显示
=3 代表 在搜索显示
= 4 代表 可以在 目录 搜索显示
=================================
网上还有很多提到 indexer.php 这个shell脚本的。跑了这个可以重新生成index 数据。
php -f indexer.php -- -reindex catalog_category_product
php -f indexer.php -- -reindex all
等等一系列的命令,可以去搜一下。这里就不一一列举了。