Reputation: 3071
I am inserting some products in magento programmatically, I want to show just configurable products in front end (Like magento itself) and when user selects "View Details" in details page he can select attributes to select the associated simple product.(I dont want to show associated products in front end) But now both configurable and simple products are available in product list in front end. why it happens?
Upvotes: 1
Views: 2947
Reputation: 2843
If you want to hide the simple products from frontend, you can also do this from backend, without writing any code.
Go to Catalog->Manage Products, in the Type dropdown, filter "simple product". After filtering select all products and select "Update Attributes" from Mass action. From there change the visibility to "Not Visible Individually" which will be applied to all simple products.
Upvotes: 1
Reputation: 1917
In the General
tab of the simple products, set Visibility
to Not Visible Individually
. This will hide them from the front-end, but keep them enabled for use with the configurable products.
This can also be done programmatically if that's how you're creating the products:
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)
// from Mage_Catalog_Model_Product_Visibility:
// const VISIBILITY_NOT_VISIBLE = 1;
// const VISIBILITY_IN_CATALOG = 2;
// const VISIBILITY_IN_SEARCH = 3;
// const VISIBILITY_BOTH = 4;
// remember to call $product->save() at some point
Upvotes: 2
Reputation: 3071
Thanks friends! I found it. I set visibility to Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH
and now it's Ok
Upvotes: 0