Перейти до основного вмісту

Методи

Базова функціональність

getProduct

Отримує товар на основі заданого ID та мови.

$product = sCommerce::getProduct(1, 'uk');

getProductByAlias

Отримує товар за його аліасом.

$product = sCommerce::getProductByAlias('my-product-alias');

getCategoryProducts

Отримує товари, що належать до певної категорії.

$products = sCommerce::getCategoryProducts(10, 'uk', 5);

getActiveCategoriesTree

Отримує дерево активних категорій.

$categories = sCommerce::getActiveCategoriesTree(10);

Технічна функціональність

documentListing

Отримує список товарів з кешу або встановлює його, якщо не знайдено.

$listing = sCommerce::documentListing();

moduleUrl

Отримує URL модуля.

$url = sCommerce::moduleUrl();

config

Отримує значення з конфігураційного файлу на основі заданого ключа.

$catalogRoot = sCommerce::config('basic.catalog_root');
$friendlyUrlSuffix = sCommerce::config('basic.friendlyUrlSuffix');

Додаткові методи

getTreeActiveCategories

Рекурсивно отримує дерево категорій з підкатегоріями.

$category = sCommerce::getTreeActiveCategories(10, 5);

getCurrencies

Отримує список всіх доступних валют.

$currencies = sCommerce::getCurrencies();

tabRender

Рендерить вкладку для адміністративної панелі.

$view = sCommerce::tabRender('mypage', 'template', $data, 'Title', 'icon', 'help');

Приклади використання

Отримання товарів категорії:

use Seiger\sCommerce\Facades\sCommerce;

class ProductController extends BaseController
{
public function index()
{
$categoryId = evo()->documentIdentifier;
$products = sCommerce::getCategoryProducts($categoryId, 'uk', 10);

return view('products.index', compact('products'));
}
}

Робота з конфігурацією:

// Отримання налаштувань
$catalogRoot = sCommerce::config('basic.catalog_root');
$mainCurrency = sCommerce::config('currencies.main', 'USD');

// Встановлення налаштувань
sCommerce::config('basic.friendlyUrlSuffix', '.html');

Робота з валютами:

// Отримання списку валют
$currencies = sCommerce::getCurrencies();

// Отримання конкретної валюти
$usd = $currencies->firstWhere('alpha', 'USD');
echo $usd['name']; // United States Dollar