1
我想使用Magento自定義模塊(控制器)中的編碼更改產品可見性。我正在嘗試下面的代碼,但可見性沒有改變。如何以編程方式更改Magento中的產品可見性
請建議正確的方法。
$relContact = Mage::getModel('catalog/category/indexer/product')->getCollection();
Mage::register('isSecureArea', true);
foreach ($relContact as $product) {
try {
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
//$product->setVisiblity(VISIBILITY_NOT_VISIBLE);
} catch(Exception $e) {
echo "Product #".$product->getId()." Visiblity could not be changed: ".$e->getMessage();
}
使用這種方式產品從前端隱藏/取消隱藏,但仍然在管理面板產品可見性值不會改變?有任何方法可以做到這一點。 –
您正在添加新產品還是更新現有產品? – sudhakar
更新現有產品。 –