When we create / edit product, then we select category and website, for store views whose category is not selected, the visibility should be set to "not visible".
Is it possible by default?
Not possible by default, no. You could try to write an observer for catalog_product_prepare_save
, which is dispatched from the product save controller and receives the parameters product
and request
.
But with a single save
, only one store view can be saved, so you cannot achieve what you want with manipulating the product object alone. You have to save the visibility attribute directly. Fortunately, there is a method for it:
addAttributeUpdate($code, $value, $store)
$product->addAttributeUpdate('visibility', false, $storeId);
Yes it is by default in magento. if you don't select any category for product then this product will not appear in frontend.