Owl 轮播 - Magento 产品
Owl Carousel - Magento Products
我已经成功 Owl Carousel 使用 div 的图像在我的 Magento 主页上完美运行。
我的目标是让它与产品一起工作,但我很挣扎。
我想显示特定类别的产品并使用 Owl 轮播在主页上显示它们,但我通常使用 cms 块将产品调用到主页,代码如下:
{{block type="catalog/product_list" category_id="112" column_count="4" template="catalog/product/list.phtml"}}
这很明显不起作用 - 产品显示但它们有自己的布局,我认为是模板的缘故。
有没有人知道我可以使用什么 php 或 cms 块从类别中调用产品,以便它与 owl 轮播一起使用。
提前致谢。
首先假设您不打算将大量产品加载到 Owl 轮播中,并且您完全可以创建一个类别来存储想要的产品在滑块中。
<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 轮播标记中,因为除了 Magento 属性之外,我们还打印 Owl 标记。
phtml 文件并在 list.phtml 文件的帮助下显示您的产品并提供您自己的 css 类。在此之前创建一个小扩展并在扩展的块文件夹中创建一个 list.php 文件,并在您的 cms 页面或您现在编写的静态块中调用您自己的块和 phtml 文件
我已经成功 Owl Carousel 使用 div 的图像在我的 Magento 主页上完美运行。
我的目标是让它与产品一起工作,但我很挣扎。
我想显示特定类别的产品并使用 Owl 轮播在主页上显示它们,但我通常使用 cms 块将产品调用到主页,代码如下:
{{block type="catalog/product_list" category_id="112" column_count="4" template="catalog/product/list.phtml"}}
这很明显不起作用 - 产品显示但它们有自己的布局,我认为是模板的缘故。
有没有人知道我可以使用什么 php 或 cms 块从类别中调用产品,以便它与 owl 轮播一起使用。
提前致谢。
首先假设您不打算将大量产品加载到 Owl 轮播中,并且您完全可以创建一个类别来存储想要的产品在滑块中。
<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 轮播标记中,因为除了 Magento 属性之外,我们还打印 Owl 标记。
phtml 文件并在 list.phtml 文件的帮助下显示您的产品并提供您自己的 css 类。在此之前创建一个小扩展并在扩展的块文件夹中创建一个 list.php 文件,并在您的 cms 页面或您现在编写的静态块中调用您自己的块和 phtml 文件