简体   繁体   中英

Magento view related products in list.phtml

I have the following requirement;

I want to show a products configured on the category listing page (list.phtml). I figured I could make some call on the list.phtml inbetween the for each loop for each product using the [b]$_product[/b] variable but I can't seem to populate the relatedProductCollection sorry new to all this is it even possible.

<?php foreach ($_productCollection as[b] $_product[/b]):?>
    <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?>last<?php endif; ?>" >
        <div class="product-shop">
            <div class="f-fix">


                     <?php  $product->getRelatedProductCollection(); ?>


    </li>
<?php endforeach; ?>

$product has been used to call the getRelatedProductCollection function.

but,

In that foreach loop you have taken it as $_product .

Can you see the difference ??

Underscore is missing. This is taken from your code. Make the variable same in both the places and try.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM