New version 0.9 has been released! Jun 16, 2015
×

Catalog module

Description

Catalog module helps you to create live editable catalog on frontend.


Include

use yii\easyii\modules\catalog\api\Catalog;


Public functions

object Catalog::cat( $id_slug )
$id_slug integer / string Category identifier can be integer (id) or string (slug)
Returns CategoryObject or null if not found.

array Catalog::tree()
Returns array of categories in tree structure.

array Catalog::cats()
Returns array of categories in flat structure.

array Catalog::items( $options = [] )
$options array
  • where (mixed) - additional condition, details
  • filters (array) - filter by additional fields and price. Format:
    'field1' => 'value1' search field1 == 'value'
    'field2' => [1, 100] search field2 between 1 and 100
    'field3' => [100, 0] search field3 > 100
    'field4' => [0, 100] search field4 < 100
  • pagination (array) - properties for Pagination object.
Returns array of ItemObject

object Catalog::get( $id_slug )
$id_slug mixed Item identifier can be integer (id) or string (slug
Returns ItemObject or null if not found.

array Catalog::last( $limit = 1, $where = [] )
$limit integer Count of last photos
$where mixed additional condition, details
Returns array of ItemObject

string Catalog::plugin()
Apply Fancybox plugin on all photos, called as box() function.

string Catalog::pages()
Returns pagination html generated by yii\widgets\LinkPager widget.

object Catalog::pagination()
Returns yii\data\Pagination object.

CategoryObject

Public Properties

$title string Category title
$slug string Category slug
$image string Path to image attached to category
$fields array Additional fields of category
$model yii\db\ActiveRecord Category ActiveRecord object

Public Functions

string thumb( $width, $height = null, $crop = true )
$width int Thumbnail width
$height int Thumbnail height
$crop boolean Crop or resize image to thumbnail sizes
Returns path to image thumbnail

Public Functions

array items( $options = [] )
$options array
  • where (mixed) - additional condition, details
  • filters (array) - filter by additional fields and price. Format:
    'field1' => 'value1' search field1 == 'value'
    'field2' => [1, 100] search field2 between 1 and 100
    'field3' => [100, 0] search field3 > 100
    'field4' => [0, 100] search field4 < 100
  • pagination (array) - properties for Pagination object.
Returns array of ItemObject

array fieldOptions( $name, $firstOption = '' )
$name string Field name
$firstOption string First empty option if needed, for example "Select city"
Returns array of possible options of category field.

string pages()
Returns pagination html generated by yii\widgets\LinkPager widget.

object pagination()
Returns yii\data\Pagination object.


ItemObject

Public Properties

$title string Item title
$description string Item full text
$slug string Item slug
$category_id integer Item category id
$cat object Item category
$image string Path to image attached to item
$data array Additional fields
$available integer Count of available items
$discount integer Discount between 0 and 100
$price integer Item price with discount
$oldPrice integer Old item price if discount > 0
$photos array Array of PhotoObject
$time int Item create unix time
$date string Item create formatted date
$model yii\db\ActiveRecord Item ActiveRecord object

Public Functions

string thumb( $width, $height = null, $crop = true )
$width int Thumbnail width
$height int Thumbnail height
$crop boolean Crop or resize image to thumbnail sizes
Returns path to image thumbnail


PhotoObject

Public Properties

$image string Path to image
$description string Photo description

Public Functions

string box( $width, $height )
$width int Thumbnail width
$height int Thumbnail height
Returns Fancybox scripted image thumbnail