Question

I am not sure if this is a bug or something with my configuration.

I have one database on one magento install running two stores.

Some products are only enabled in (store 1) and these do only show up under (store 1). However through analytics I found some 404 pages that come from /review/product/list/id/nnn pages which brought to my attention, that products not in (store 2) are showing the product name, price and image. (the product did once exist and was in the sitemap so this would be why and how it was brought to my attention).

When you click the link back from the product review form page, you get as expected a 404 not found page so my question is why and how does this much of the product show up at all ? The product review templates all seem to come from the same templates that already do not allow the product to show up, so I am wondering is this more the routing url controlling what shows or within the code itself ?

Even if i output the value for $_product = $this->getProduct(); I get info on the product, and the info does show it is store2 which this product should by all accounts not exist in.

Was it helpful?

Solution

Oh this is an odd one, it does appear that there is a "bug" or maybe just a "difference" in opinions as to when a product should show in the review.

Product View

So currently the catalog product view page uses Mage_Catalog_Helper_Product to help init and render the product. Sounds good and it does a couple of good checks.

$product = Mage::getModel('catalog/product')
    ->setStoreId(Mage::app()->getStore()->getId())
    ->load($productId);
if (!$this->canShow($product)) {
    return false;
}
if (!in_array(Mage::app()->getStore()->getWebsiteId(), $product->getWebsiteIds())) {
    return false;
}

The canShow function when looked into deeper simply returns the results of $product->isVisibleInCatalog() && $product->isVisibleInSiteVisibility() the the product has loaded correctly.

Now this all seems to work well, good job Magento.

Review List

So let's see how the review list does it.

Well firstly it does not use the same helper, which is a bit odd as I would assume that this to limit a lot of duplicate code such as checking if a product can be displayed, which seems to be the issue we are looking at here :(

So we know what it does not do so let's check what it does do.

Well it classifies a product as allowed with the following check:

if (!$product->getId() || !$product->isVisibleInCatalog() || !$product->isVisibleInSiteVisibility()) {

Which we have seen before in the helper's canShow function, but sadly that is all it checks and so does not do a further check for websites. Now I am not sure if this is actually a bug or the desired results, but but it should be fairly simply to sort out.

Fix

To fix this it appears to be fairly simple, luckily there are two events that can be hooked onto. They are both fired in the Mage_Review_ProductController::_initProduct.

Mage::dispatchEvent('review_controller_product_init', array('product'=>$product));
Mage::dispatchEvent('review_controller_product_init_after', array(
    'product'           => $product,
    'controller_action' => $this
));

So I would suggest creating an observer that works with one of these events and checks the websites attached to a product and if it is not allowed to be shown on the current website simply call clearInstance

OTHER TIPS

go to admin catalog->manage product . now find that product seen in store 2 .. check product enable in both website enter image description here here in this screen see in website column only diamond store display so product see only in diamond store. in other store can't see this product

if you find multi sites in single product remove it . goto edit product ->website tab -> remove click to disable from other store . (select only store where you want to display).

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