Comment obtenir les produits correspondants dans la grille d'administration du module personnalisé?
-
16-10-2019 - |
Question
Je travaille sur Magento grille d'administration du module personnalisé Je veux montrer id produit et id produits connexes et d'autres informations sur les produits.
S'il vous plaît aidez-moi à le faire.
La solution
Vous pouvez essayer cela.
Supposons que vous voulez trouver les produits connexes de $ 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();
}
Autres conseils
Son très simple add le dessous du code dans votre fichier module tab.php personnalisé.
$this->addTab('related', array(
'label' => Mage::helper('catalog')->__('Related Products'),
'url' => $this->getUrl('*/*/related', array('_current' => true)),
'class' => 'ajax',
));
et exécutez votre module.
Je espère que vous avez les solutions.
<?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>";
?>
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange