Magento:如何在猫头鹰转盘上显示产品

Magento:如何在猫头鹰转盘上显示产品,magento,magento-1.9,owl-carousel-2,Magento,Magento 1.9,Owl Carousel 2,我使用的是magento 1.9.3,我想在owl转盘的主页上显示特色产品 我的模块块中有一个方法,它返回我想要在旋转木马中显示的集合。我从我的模板中这样调用它: $_productCollection=$this->getFeaturedProducts(); 我在stack overflow中发现了一个关于此的问题: 根据前面的问题,我在模板中得出了以下结论: <div class="owl-carousel"> <? $products =

我使用的是magento 1.9.3,我想在owl转盘的主页上显示特色产品

我的模块块中有一个方法,它返回我想要在旋转木马中显示的集合。我从我的模板中这样调用它:

$_productCollection=$this->getFeaturedProducts();
我在stack overflow中发现了一个关于此的问题:

根据前面的问题,我在模板中得出了以下结论:

<div class="owl-carousel">
    <?
        $products = $this->getFeaturedProducts();
        foreach ($products as $_product) { // iterate through the entire collection
            echo '<div class="item"><img src='.$this->helper('catalog/image')->init($_product, 'small_image')->keepFrame(false)->resize($_imgSize).'></div>'; // print the image url inside of the required Owl markup
        }
    ?>
</div>


请尝试此扩展名

希望对你有帮助

首先转到链接>>

创建以下答案的所有文件

然后打开featured.phtml

复制并粘贴下面的代码

<?php
    $_helper = $this->helper('catalog/output');
    $_productCollection = $this->getProductCollection();
?>
<div class="featured-products">
    <ol class="featured-products-list owl-carousel" id="featured-products-list">
    <?php foreach ($_productCollection as $_product): ?>
        <li><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(200) ?>"  alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></li>
    <?php endforeach; ?>
    </ol>
</div>
<script type="text/javascript">
    jQuery(document).ready(function(){
  jQuery(".owl-carousel").owlCarousel();
});
</script>

  • helper('catalog/image')->init($_product,'thumbnail')->调整大小(200)?>“alt=”“/>
  • jQuery(文档).ready(函数(){ jQuery(“.owl carousel”).owlCarousel(); });
    请不要忘记为产品创建属性和分配