2

I am working on Magento custom module admin grid I want to show product id and related product id and other product information.

Please help me to do this.

2
  • Can you provide more info about this? – Sukeshini Feb 7 '14 at 5:39
  • @Sukeshini i want a page in Admin where I can enter product ID, I can see all related products associated with it and edit the list(add and delete the related produts). – Mani Dev Feb 7 '14 at 5:43
8

You can try on this.

Assume you want to find the related products of $product_id.

$model = Mage::getModel('catalog/product');
$product = $model->load($product_id);

// Get all related product ids of $product.
$allRelatedProductIds = $product->getRelatedProductIds();

foreach ($allRelatedProductIds as $id) {
            $relatedProduct = $model->load($id);

            // get Product's name
            echo $relatedProduct->getName();

            // get product's short description
            echo $relatedProduct->getShortDescription();

            // get Product's Long Description
            echo $relatedProduct->getDescription();

            // get Product's Regular Price
            echo $relatedProduct->getPrice();

            // get Product's Special price
            echo $relatedProduct->getSpecialPrice();

            // get Product's Url
            echo $relatedProduct->getProductUrl();

            // get Product's image Url
            echo $relatedProduct->getImageUrl();

        }
0

Its very simple add the below code in your custom module tab.php file.

 $this->addTab('related', array(
            'label'     => Mage::helper('catalog')->__('Related Products'),
            'url'       => $this->getUrl('*/*/related', array('_current' => true)),
            'class'     => 'ajax',
 ));

and run your module.

Hope you got the solutions.

0
<?php  
$RelProduct = Mage::getModel('catalog/product')->load($p_id)->getRelatedProductIds();
echo "<div class='product clearfix'>";
foreach ($RelProduct as $id) {
    $Product = Mage::getModel('catalog/product')->load($id);
    echo "<div class='product__item' style='float: left;'>"."<a href='#' class='product__link'>";
    echo "<img src=".$relatedProduct->getImageUrl()." width='200' height='200' />"."</br>";
    echo $Product->getName()."</br>";
    echo $Product->getDescription()."</br>";
    echo $Product->getPrice()."</br>";
    echo "</a></div>";
    }
echo "</div>";
?>

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.