I have different affiliate products with almost same name in database, how can we do a price comparison of those products in product details page? Can anyone help me with the shortest way?
I tried this
$product_id = Mage::registry('current_product')->getId();
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id);
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToFilter('name', ['like' => $_product->getName().'%']);
That seems like a good way to go about it to me, but you could probably simplify your code to just:
$_product = Mage::registry('current_product');
$_collection = $_product->getCollection()->addAttributeToFilter('name', ['like' => $_product->getName() . '%']);
Finally, the code below is working for me:
$productName = Mage::registry('current_product')->getName();
$categoryId = Mage::registry('current_product')->getCategoryId();
$manufacturerId = Mage::registry('current_product')->getManufacturer();
$products = Mage::getModel('catalog/category')->load($categoryId);
$productslist = $products->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('manufacturer',$manufacturerId)
->addAttributeToFilter('name', ['like' => $productName . '%'])
->setOrder('price', 'ASC');