techquity/aero-product-collections

There is no license information available for the latest version (v0.1.18) of this package.

Product collections for your Aero Store.

v0.1.18 2020-08-19 11:34 UTC

README

Install

Add to your Aero project using the following composer command:

composer require techquity/aero-product-collections

Then add the database tables by migrating your database:

php artisan migrate

Usage

To access the collection in your Twig files:

{% for product in product_collection("homepage-featured") %}
	<div class="product">
		<div class="product__name">{{ product.name }}</div>
	</div>
{% endfor %}

You can also specify a limit on the number of products, eager load product relationships, and provide a sort order:

{% 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 %}

The sort argument usually takes an array, but you can also pass a string value of "random" to get the collection in a random order:

{% 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 %}

You may pull in products from multiple collections by passing in an array:

product_collection(["main-collection", "another-collection"])

If you wish to specify a fallback for the group, or refine the products in the 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"
	}
])