2

I'm trying to "hide" a product for a specific country without disabling it from the store. For now i used two events one is for updating collection on product listing using event (catalog_block_product_list_collection) and the other is before load product page (catalog_product_load_before).

Now it works fine, but the issue is that what if the store owner likes to show the product as featured product on home page or other using a block or else, the above process won't work.

I prefer using event but it doesn't seem to be a reliable solution but before i proceed with overriding core classes, I'd want to be sure that this is the best way.

please guide. really appreciate your time.

thanks,

3 Answers 3

3

Why don't you create an override of Mage_Catalog_Model_Product and add some logic into the isVisibleInCatalog() function to stop the product showing up in the category?

/**
 * Check Product visilbe in catalog
 *
 * @return bool
 */
public function isVisibleInCatalog()
{
    // Custom logic to disable product
    if(LOGICHERE) {
        return false;
    }
    return in_array($this->getStatus(), $this->getVisibleInCatalogStatuses());
}

This will then cause initProduct() within the product helper to return false which should in turn stop it from being disabled.

This is untested but the theory should work.

0

It sounds to me like you should just go to manage products, scope the admin to whichever website or store view is associated with that country and change the product's visibility.

0

I think you want to change products visibility: Use this in your code, integrate it :

$productIds = array(1,2,3);//get the product ids somehow
$attributes = array('visibility'=>Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$storeIds = array(3,4,5,6);//get the store ids somehow, if multiple store
foreach ($storeIds as $storeId){
    Mage::getSingleton('catalog/product_action')->updateAttributes($productIds, $data, $storeId);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.