Template query in S-Cart
(Last update: 2020-10-29 06:15:24)
I. List of model variables
II. Syntax used
III. List of shared functions
IV. Special functions
Each template file will have its own variables passed from the parent controller. Example(*)
In addition, S-Cart provides a list of global variables and global functions that can be called in any template file.
Purpose:
I. Model variables are initialized:
1. $modelProduct -> model Product
2. $modelCategory -> model Category
3. $modelBanner -> model Banner
4. $modelBrand -> model Brand
5. $modelNews -> model News
6. $modelPage -> model Page
7. $modelCmsCategory -> model CMS Category
8. $modelCmsContent -> model CMS Content
II. Syntax used:
$modelProduct->start()->getProductHot()->setLimit(20)->setPaginate()->setRandom()->getData();
Note:
- Group-query:
Essentially, many predefined queries
- Query:
Additional conditions. If it matches a query group-query, the following query will overwrite the previous query.
- getData | getSql
Equivalent to get () and toSql () functions in Laravel
- start()
To avoid returning unexpected results, you should use the start () function before you start processing data.
III. Functions that support common to all model variables:
IV. Special functions:
1. $modelProduct
II. Syntax used
III. List of shared functions
IV. Special functions
Each template file will have its own variables passed from the parent controller. Example(*)
In addition, S-Cart provides a list of global variables and global functions that can be called in any template file.
Purpose:
- Separate the template maker and the developer: No need to have much knowledge of code in models and controllers.
- The model variable and its functions are called in any view: No need to declare in each controller for each view
- Syntax uniformity
I. Model variables are initialized:
1. $modelProduct -> model Product
2. $modelCategory -> model Category
3. $modelBanner -> model Banner
4. $modelBrand -> model Brand
5. $modelNews -> model News
6. $modelPage -> model Page
7. $modelCmsCategory -> model CMS Category
8. $modelCmsContent -> model CMS Content
II. Syntax used:
Example:$variable_model->start()->(get)group-query->(set)query->getData()|getSql();
$modelProduct->start()->getProductHot()->setLimit(20)->setPaginate()->setRandom()->getData();
Note:
- Group-query:
Essentially, many predefined queries
- Query:
Additional conditions. If it matches a query group-query, the following query will overwrite the previous query.
- getData | getSql
Equivalent to get () and toSql () functions in Laravel
- start()
To avoid returning unexpected results, you should use the start () function before you start processing data.
III. Functions that support common to all model variables:
- start(): Start using the model functions. Make sure to always use it first so you don't get the desired results.
- setLimit(int) // The result limit is limited -> The following function replaces the previous one
- setSort([$key, ‘asc|desc’]) //ort returned results -> Used many times
- setRandom(0|1) // Activating random fetches results returns -> The following function replaces the previous function
- setPaginate() // Activate pagination mode
- setMoreWhere([$v1, ‘<|>|=|like|<=|>=|<>’, $v2]) // dditional where clause -> Used multiple times
- getSql() // Returns the query -> Called last.
- getData() // Returns the result data -> Called last.
- getFull() // Returns 1 model detailed results -> Called last.
IV. Special functions:
1. $modelProduct
- setKeyword($string) // Search for products with keywords: sku, name, description, keyword
- getProductHot() // List of discounted products
- getProductBuild() //List of products bundle
- getProductGroup() // List of products group
- getProductSingle() // List of products single
- getProductToCategory($arrCategory | int) // List of products by category
- getProductToBrand($arrBrand | int) // List of products by brand
- getProductLatest() // Top latest products
- getProductLastView() // List of recently viewed products
- getProductBestSell() // List of best selling products
- getFinalPrice() // Get the final selling price of the product (no tax)
- getFinalPriceTax() // Get the final selling price of the product (tax included)
- showPrice() //Displays product price details on product listing pages
- showPriceDetail() // Show product price details on product detail pages
- getDetail() // Get detailed information of a product through id, model, alias, ...
- getThumb() // Get the link of the product's thumb image
- getImage() // Get the main image link of the product
- getUrl() // Get the product link
- getPercentDiscount() // Discount rate
- renderAttributeDetails() // Display properties
- allowSale() // Check if the product has a discount
- getProductFromListID($arrID) // Get product list through array ID
- setParent(int) // Retrieve the category through the parent category ID
- getCategoryRoot() // Get original directory (with id = 0)
- getCategoryTop() // Get the first display category outside the homepage (top = 1)
- getDetail() // Get detailed information of the catalog
- getThumb() //Get the thumb image link of the catalog
- getImage() // Get the main image link of the catalog
- getUrl() // Get the cataloglink
- getParent() // Get parent catalog information
- getBanner() // Banner (type =banner)
- getBackground() // Background (type = background)
- getBreadcrumb() // Breadcrumb (type=breadcrumb)
- getDetail() // Banner detail
- getThumb() // Thumb của banner
- getImage() // Image banner
- getDetail() // Get detailed information of a brand through id
- getThumb() // Get the link of the brand 's thumb image
- getImage() // Get the main image link of the brand
- getUrl() // Get the brand link
- getDetail() // Get detailed information of a blog through id
- getThumb() // Get the link of the blog's thumb image
- getImage() // Get the main image link of the blog
- getUrl() // Get the blog link
- getDetail() // Get detailed information of a page through id
- getThumb() // Get the link of the page's thumb image
- getImage() // Get the main image link of the page
- getUrl() // Get the page link
- setParent(int) // Retrieve the category via the parent category ID
- getCategoryRoot() // Get original directory (with id = 0)
- getDetail() // Get detailed information of the catalog
- getThumb() // Get the thumb image link of the catalog
- getImage() // Get the main image link of the catalog
- getUrl() // Get the catalog link
- getParent() // Get parent catalog information
- getContentToCategory(array id) // List of entry under the category
- getDetail() // Entry detail
- getThumb() // Entry thumb
- getImage() // Entry image
- getUrl() // Entry url
