猫头鹰旋转木马- Magento产品


Owl Carousel - Magento Products

我已经设法让Owl Carousel在我的Magento主页上使用div的图像完美地工作。

我的目标是让它与产品一起工作,但我很挣扎。

我想显示特定类别的产品,并使用Owl Carousel在主页上显示它们,但我通常使用cms块将产品调用到主页上,代码如下:

{{block type="catalog/product_list" category_id="112" column_count="4" template="catalog/product/list.phtml"}}

这显然是行不通的-产品显示,但他们有自己的布局,我认为是由于模板。

有没有人知道我可以使用什么php或cms块来调用类别中的产品,以便它与owl carousel一起工作。

首先假设您不打算将大量产品加载到Owl Carousel中,并且您完全可以创建一个类别来存储打算在滑块中显示的产品。

<div class="owl-carousel">
<?php
   $categoryId = 15; // this is the category holding your products  
   $products = Mage::getSingleton('catalog/category')->load($categoryId) // load the category
               ->getProductCollection() // and the products
               ->addAttributeToSelect('image'); // tell Magento which attributes to get
   foreach ($products as $product) { // iterate through the entire collection
        echo '<div class="item"><img src='.$product->getImageUrl().'></div>'; // print the image url inside of the required Owl markup
   }
?>
</div>

上面的代码也应该被正确地组织起来,你将调用的变量出现在代码块的顶部,foreach只出现在代码块的Owl部分。

foreach应该在 Owl Carousel标记内的,因为除了Magento属性外,我们还打印了Owl标记。

php文件,并借助list。并显示您的产品,并给出您自己的CSS类。在此之前,创建一个小扩展并创建一个list。php文件在扩展的block文件夹中调用你自己的block和php文件在你的CMS页面或你现在写的静态block中