猫头鹰传送带-Magento产品 [英] Owl Carousel - Magento Products

查看:79
本文介绍了猫头鹰传送带-Magento产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功地使 Owl Carousel 使用div的图像在我的Magento主页上完美工作.

I have managed to get Owl Carousel working perfectly on my Magento home page using div's of images.

我的目标是使它与产品混为一谈,但我一直在努力.

My aim is to get it wortking with products but I am struggling.

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

I want to display the products from a particular category and show them on the home page using the Owl Carousel but I usually call products on to the home page using a cms block with code such as:

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

这种麻烦不起作用-产品显示出来,但由于模板的原因,它们具有自己的布局.

This obvioulsy is not working - the products show but they have their own layout I think due to the template.

有人对我可以用来从类别中调用产品的php或cms块有任何想法吗,以便与猫头鹰轮播一起使用.

Does anyone have any ideas on what php or cms block I can use to call produts from a cateogry so it works with owl carousel.

谢谢.

推荐答案

首先假定您不打算将大量产品加载到Owl Carousel中,并且您完全可以创建一个类别只是用来存储要放在滑块中的产品.

Start off with the assumption that you don't intend to load a massive amount of products into the Owl Carousel and that you're perfectly fine with creating a category just to store the products intended to be in the slider.

<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部分.

The above should be organized properly, as well, with the variables you'll be calling appearing at the top of your block and the foreach only appearing within the Owl portion of the block.

foreach应该在猫头鹰轮播"标记内 内,因为除了Magento属性外,我们还在打印猫头鹰"标记.

The foreach should go within the Owl Carousel markup, as in addition to the Magento attribute we are also printing the Owl markup.

这篇关于猫头鹰传送带-Magento产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆