1

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.

1

1 Answer 1

2

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.

2
  • 1
    Thanks! I had managed to get addVisibleFilterToCollection working on the search last night. I will look at that init. Is that an abstract class? Similar to _load_before? Edit: I just looked here and found that it was. Thanks for the heads up on this event, I can create an observer most likely to handle this.
    – DWils
    Jul 19, 2013 at 17:08
  • 1
    For anyone else looking for this, here's a list of events for magento: magentocommerce.com/wiki/5_-_modules_and_development/reference/…
    – DWils
    Jul 19, 2013 at 17:15

Your Answer

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

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