I am editing "You may also be interested" section (Up-sells products section) in the Product Detail page. I need to remove the current product from "You may also interested" section.

Up-sells products section displays the current product of category product (which most viewed). But I have issue when I go to "You may also be interested" section on product detail page; the current product is also getting displayed on this. I just need to remove the current product from "You may also be interested" section.

Example: I have 4 products in Up-sells section:

Test1, Test2, Test3, Test4

I am getting this but when I go to Test1 product detail page, then I need to not display Test1 under "You may also be interested" section.

Here is the code I've used so far:

$products = Mage::getResourceModel('reports/product_collection')
    //->addAttributeToFilter('entity_id', array('neq' => $product_id))
    ->addAttributeToFilter('category_id', array('in' => $category_ids ));


The methodaddIdFilter() of the product collection has a second parameter "exclude" that inverts the filter:

$collection->addIdFilter([$product->getId()], true);
| improve this answer | |

I am Getting answer Without change Query of Magento.

foreach ($products as $_item) {

    $myid =  $_item->getId();

    if ($myid !=  $product_id) {
        <?php echo $_item->getProductUrl() ?>

I found this solution here: most view product

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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