techquity / aero-product-collections
此包最新版本(v0.1.18)没有可用的许可证信息。
Aero Store 的产品集合。
v0.1.18
2020-08-19 11:34 UTC
Requires
- aerocommerce/core: ^0
README
安装
使用以下 composer 命令将此包添加到您的 Aero 项目中
composer require techquity/aero-product-collections
然后通过迁移数据库添加数据库表
php artisan migrate
使用方法
要访问 Twig 文件中的集合
{% for product in product_collection("homepage-featured") %} <div class="product"> <div class="product__name">{{ product.name }}</div> </div> {% endfor %}
您还可以指定产品数量的限制、预加载产品关系并提供排序顺序
{% for product in product_collection("homepage-featured", 6, ["images", "manufacturer", "variants.prices"], ["name", "asc"]) %} <div class="product"> <div class="product__name">{{ product.name }}</div> </div> {% endfor %}
排序参数通常是一个数组,但您也可以传递一个字符串值 "random"
来以随机顺序获取集合
{% for product in product_collection("homepage-featured", 6, ["images", "manufacturer", "variants.prices"], "random") %} <div class="product"> <div class="product__name">{{ product.name }}</div> </div> {% endfor %}
您可以通过传递一个数组从多个集合中获取产品
product_collection(["main-collection", "another-collection"])
如果您想为组指定回退或细化集合中的产品
product_collection([ { "collection": "related-products", "product": product }, { "not_product": product, "manufacturer": product.manufacturer, "categories": product.categories }, { "not_product": product, "tag_name.en": "upsold-product" } ])