Product & Data Fetching Helpers
These helpers fetch product, category, and store data and return them as arrays or objects for use in Blade templates. All return data that was previously available via Twig tags in the legacy system.
Product Listing Helpers
These helpers return arrays of product arrays/objects that share a common structure.
Product Object Structure
All product listing helpers return an array of items with the following keys:
{
"name": "Product Name",
"itemNo": "SKU-001",
"normalPrice": "100.00",
"specialPrice": "90.00",
"availability": "15",
"image": "/files/s232/assets/image.jpeg",
"pImage": "/files/s232/assets/image.jpeg",
"description": "<p>Product description HTML...</p>",
"productPermalink": "product-slug",
"subtitle": "A short subtitle",
"demoCount": false,
"addToCartUrl": "/cart/add?id=1",
"detailUrl": "/product-slug",
"askQuestionUrl": "/product-slug?qaTab=true",
"reviewUrl": "/review/product-slug",
"reviewLabel": "<span>Review This Product</span>",
"reviewDisplay": "<span class='fa fa-star'></span>...",
"reviewCount": 3,
"discountPercent": 10.5,
"addTowishlistUrl": "/product/managewishlist/add?id=1&pplink=product-slug",
"removeFromwishlistUrl": "/product/managewishlist/remove?id=1&pplink=product-slug",
"combinationCount": 0,
"cId": 5,
"productId": 1,
"shippingMode": "FSI",
"url": "/SKU-001",
"dpId": null,
"discountPeriod": null,
"pCount": 4
}
Field Reference
| Field | Type | Description |
|---|---|---|
name |
string | Product display name |
itemNo |
string | SKU / item number |
normalPrice |
string | The regular price |
specialPrice |
string | The sale/special price (may equal normalPrice) |
availability |
int/bool | Stock quantity; false or 0 = out of stock |
image |
string | Path to primary product image |
pImage |
string | Same as image (legacy alias) |
description |
string | HTML product description |
productPermalink |
string | URL slug for the product |
detailUrl |
string | Absolute URL to the product detail page |
addToCartUrl |
string | URL to add item to cart |
askQuestionUrl |
string | URL to the Q&A tab on product page |
reviewUrl |
string | URL to write a review |
reviewDisplay |
string | Pre-rendered HTML star rating |
reviewCount |
int | Number of reviews |
discountPercent |
float | Discount percentage (0 if no discount) |
addTowishlistUrl |
string | URL to add to wishlist |
removeFromwishlistUrl |
string | URL to remove from wishlist |
productId |
int | Internal product ID |
cId |
int | Category ID |
shippingMode |
string | Shipping mode code (e.g., 'FSI', 'CS') |
featureProducts(int $limit = 25): array
Returns featured products. Products must have the "featured" flag enabled in the admin panel.
@php $featured = featureProducts(8); @endphp
<div class="row">
@foreach($featured as $product)
<div class="col-md-3 mb-4">
<div class="card">
<a href="{{ $product['detailUrl'] }}">
<img src="{{ $product['image'] ?? noproductimage() }}"
alt="{{ getAlt($product['image'], $product['name']) }}"
class="card-img-top">
</a>
<div class="card-body">
<h6>{{ $product['name'] }}</h6>
<p class="text-muted">${{ tagPrice($product['specialPrice']) }}</p>
@if(!$page->settings->catalogMode && $product['availability'] > 0)
<a href="{{ $product['addToCartUrl'] }}" class="btn btn-sm btn-primary">Add to Cart</a>
@endif
</div>
</div>
</div>
@endforeach
</div>
latestProducts(): array
Returns the most recently added products. A product must: 1. Have a category assigned and that category must be enabled 2. Have at least one image 3. Have been created within the last 30 days
@foreach(latestProducts() as $product)
<div class="product-card">
<img src="{{ $product['image'] ?? noproductimage() }}" alt="{{ $product['name'] }}">
<p>{{ $product['name'] }}</p>
<a href="{{ $product['detailUrl'] }}">View Details</a>
</div>
@endforeach
seasonsBestProduct(int $limit = 6): array
Returns the "Season's Best" products — the most-ordered products in recent history.
@foreach(seasonsBestProduct(4) as $product)
<div class="best-seller">
<img src="{{ $product['image'] }}" alt="{{ $product['name'] }}">
<strong>{{ $product['name'] }}</strong>
<span>${{ tagPrice($product['normalPrice']) }}</span>
</div>
@endforeach
discountedProducts(int $limit = 5): array
Returns products that are currently on sale (have a special price lower than normal price).
<h3>Special Offers</h3>
@foreach(discountedProducts(6) as $product)
<div class="sale-product">
<img src="{{ $product['image'] }}" alt="{{ $product['name'] }}">
<span class="text-muted text-decoration-line-through">${{ tagPrice($product['normalPrice']) }}</span>
<span class="text-danger">${{ tagPrice($product['specialPrice']) }}</span>
<span class="badge bg-danger">-{{ number_format($product['discountPercent'], 0) }}% OFF</span>
</div>
@endforeach
getVisitedProducts(): array
Returns recently viewed products for the currently logged-in customer. Returns an empty array for guests.
@php $recentProducts = getVisitedProducts(); @endphp
@if(count($recentProducts))
<h4>Recently Viewed</h4>
@foreach($recentProducts as $product)
<div class="recent-item">
<img src="{{ $product['image'] }}" alt="{{ $product['name'] }}" width="80">
<a href="{{ $product['url'] }}">{{ $product['name'] }}</a>
</div>
@endforeach
@endif
videoList(?int $limit = null): array
Returns video assets associated with the store. These are configured in the admin panel.
@foreach(videoList(6) as $video)
<div class="video-item">
<video src="{{ $video['videoUrl'] ?? '' }}" controls width="300"></video>
<p>{{ $video['name'] ?? '' }}</p>
</div>
@endforeach
getProductDiscountInfo(): array
Returns aggregate discount information for the store (e.g., current promotion data).
getHomePageContent(): array
Returns a merged array of homepage-specific content settings from the theme and admin panel, including logo image paths.
@php $homeContent = getHomePageContent(); @endphp
@if(isset($homeContent['logo_image']))
<img src="{{ $homeContent['logo_image'] }}" alt="Store Logo">
@endif
getCategory() — Category Tree
Fetches a categorized tree structure. Most useful for building navigation menus or category pages.
Signature:
Parameters:
| Param | Description |
|---|---|
$name |
Filter categories by name/permalink. Empty = all categories |
$searchType |
'exact' for exact name match, otherwise partial match on permalink |
$status |
'active', 'disabled', 'all', or a numeric status code |
Returns an object:
{
count: int, // Total matching categories
categories: [
{
id: int,
hasChild: 0|1,
category: { name, permalink, ... },
child: [
{
id: int,
hasChild: 0|1,
category: { ... },
child: [ ... ] // sub-subcategories
}
]
}
]
}
Usage — Build a Category Dropdown:
@php $catData = getCategory('', null, 'active'); @endphp
<ul class="category-nav">
@foreach($catData->categories as $cat)
<li class="{{ $cat->hasChild ? 'has-children' : '' }}">
<a href="/category/{{ $cat->category['permalink'] ?? '' }}">
{{ $cat->category['name'] ?? '' }}
</a>
@if($cat->hasChild)
<ul class="submenu">
@foreach($cat->child as $sub)
<li>
<a href="/category/{{ $sub->category['permalink'] ?? '' }}">
{{ $sub->category['name'] ?? '' }}
</a>
</li>
@endforeach
</ul>
@endif
</li>
@endforeach
</ul>
getCategoryData(): object
Returns a dummy category object. Used in some legacy integrations where an empty category placeholder is needed.
Returns:
Brochure Helpers
getCategoryBrochure(int $categoryId, bool $mimeType = false): ?string
Returns the URL of a category's brochure/PDF file, or its MIME type if $mimeType = true.
hasCategoryBrochure(int $categoryId): bool
Returns true if a category has a brochure file attached.
getProductBrochure(int $productId, bool $mimeType = false): ?string
Returns the URL of a product's brochure/PDF file.
hasProductBrochure(int $productId): bool
Returns true if a product has a brochure file attached.
@if(hasCategoryBrochure($categoryId))
<a href="{{ getCategoryBrochure($categoryId) }}" target="_blank">
Download Brochure
</a>
@endif
Inventory Check
tagCheckInventory(int $productId, bool $getStock = false): bool|int
Checks real-time stock from the warehouse for a product.
| Parameter | Description |
|---|---|
$productId |
The product's ID |
$getStock |
If false, returns a boolean. If true, returns the actual stock count as an int. |
@php $inStock = tagCheckInventory($product['productId']); @endphp
@if($inStock)
<span class="text-success">In Stock</span>
@else
<span class="text-danger">Out of Stock</span>
@endif
{{-- Get actual quantity --}}
@php $stockQty = tagCheckInventory($product['productId'], true); @endphp
<small>{{ $stockQty }} units available</small>