Question

What we have here is a class that extends Mage_Catalog_Model_Product_Status, and adds two CONST variables, STATUS_PENDING and STATUS_PREVIEW.

What I am trying to find is the logic model that decides if a product appears in the frontend, preview is a special case here. I want to be able to see if a product is visible depending on if the user is a logged in admin, otherwise it will not display to customers in the search or by direct link.

So my goal is to find where the Varien router decides if a product is visible or if it should be redirected to our 404 page, extend the class and add filters to the query depending on if the user is an admin or not (e.g. changing it from STATUS_PREVIEW to STATUS_DISABLED if the user is not an admin)

Also in regards to catalog search, It was my impression that addVisibleFilterToCollection was supposed to handle this in the layer model on a product collection, however that method has been depreciated and is essentially useless in this case.

How can I control this in the product view and catalog search? If anyone could point me to the correct Models/Methods to handle this, I would greatly appreciate it, I have been at this for several hours trying to figure it out on my own.

Was it helpful?

Solution

You can use catalog_controller_product_init event to validate product status and redirect to 404 if your condition fails. This will helps for product view page.

addVisibleFilterToCollection function do trick for catalog search result also.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top