- Показ наличия товара в категории и карточке товара в virtuemart 2
- Virtuemart product view php
- Public Member Functions
- Static Public Member Functions
- Public Attributes
- Static Public Attributes
- Protected Member Functions
- Private Member Functions
- Private Attributes
- Additional Inherited Members
- Constructor & Destructor Documentation
- Member Function Documentation
Показ наличия товара в категории и карточке товара в virtuemart 2
Показ наличия или отсутствия товара на складе — это составляющая любого серьезного (и не очень 🙂 ) интернет-магазина.
В этой статье рассмотрим простейший вариант показа наличия товара на складе. Если товар есть на складе, то выведем надпись «В наличии» (так же можно будет указать точное количество оставшегося товара). Если товара нет — то надпись «Нет в наличии».
Есть два варианта решения:
- использование настраиваемого поля
- автоматический вывод надписей в зависимости от количества товара на складе
Первый вариант хотя и гораздо проще, но из-за отсутствия автоматизации можно просто забыть сменить надпись. Для второго варианта конечно тоже нужно постоянно вносить остатки товаров при поступлении их на склад, но эту задачи можно автоматизировать с помощью импорта.
Количество каждого конкретного товара указывается в его карточке во вкладке Статус.
Так же для показа наличия в категории в настройках Virtuemart во вкладке Внешний вид активируем Отображать уровень запаса.
После этого на странице категории у нас получится что-то вроде этого.
Заменим красную картинку на «Нет в наличии», а зеленую на «В наличии», а так же уберем лишние надписи.
Для этого в файле components\com_virtuemart\views\category\tmpl\default.php заменим
Virtuemart product view php
Public Member Functions
Static Public Member Functions
Public Attributes
Static Public Attributes
Protected Member Functions
Private Member Functions
Private Attributes
Additional Inherited Members
Constructor & Destructor Documentation
constructs a VmModel setMainTable defines the maintable of the model
Member Function Documentation
Check if the product has any children
Author RolandD Max Milbers Parameters
int | $virtuemart_product_id | Product ID |
Returns bool True if there are child products, false if there are no child products
This function creates a child for a given product id
Author Max Milbers Patrick Kohl Parameters
int | id of parent id |
Creates a clone of a given product id
Author Max Milbers Parameters
int | $virtuemart_product_id |
This fills the empty properties of a product todo add if(!empty statements
Author Max Milbers Parameters
unknown_type | $product |
unknown_type | $front |
This function retrieves the «neighbor» products of a product specified by $virtuemart_product_id Neighbors are the previous and next product in the current list
Author Max Milbers Parameters
object | $product | The product to find the neighours of |
Returns array
Get the Order By Select List
notice by Max Milbers html tags should never be in a model. This function should be moved to a helper or simular.
Author Kohl Patrick, Max Milbers public Parameters
$fieds | from config Back-end |
Returns $orderByList Order,order By, manufacturer and category link List to echo Out
Gets the price for a variant
VirtueMartModelProduct::getProduct | ( | $virtuemart_product_id = NULL , |
$front = TRUE , | ||
$withCalc = TRUE , | ||
$onlyPublished = TRUE , | ||
$quantity = 1 , | ||
$virtuemart_shoppergroup_ids = 0 | ||
) |
This function creates a product with the attributes of the parent.
Parameters
int | $virtuemart_product_id | |
boolean | $front | for frontend use |
boolean | $withCalc | calculate prices? |
boolean | published | |
int | quantity | |
boolean | load customfields |
Load the product category
Author Max Milbers Returns array list of categories product is in
VirtueMartModelProduct::getProductListing | ( | $group = FALSE , |
$nbrReturnProducts = FALSE , | ||
$withCalc = TRUE , | ||
$onlyPublished = TRUE , | ||
$single = FALSE , | ||
$filterCategory = TRUE , | ||
$category_id = 0 , | ||
$filterManufacturer = TRUE , | ||
$manufacturer_id = 0 | ||
) |
Loads different kind of product lists. you can load them with calculation or only published onces, very intersting is the loading of groups valid values are latest, topten, featured, recent.
The function checks itself by the config if the user is allowed to see the price or published products
VirtueMartModelProduct::getProducts | ( | $productIds, |
$front = TRUE , | ||
$withCalc = TRUE , | ||
$onlyPublished = TRUE , | ||
$single = FALSE | ||
) |
Returns products for given array of ids
Author Max Milbers Parameters
int | $productIds |
boolean | $front |
boolean | $withCalc |
boolean | $onlyPublished |
VirtueMartModelProduct::getProductShoppersByStatus | ( | $product_id, |
$states, | ||
$filter_order = ‘ou.email’ , | ||
$filter_order_Dir = ‘ASC’ | ||
) |
Get the products in a given category
Parameters
int | $virtuemart_category_id | the category ID where to get the products for |
Returns array containing product objects Deprecated:
VirtueMartModelProduct::getProductSingle | ( | $virtuemart_product_id = NULL , |
$front = TRUE , | ||
$quantity = 1 , | ||
$withParent = false , | ||
$virtuemart_shoppergroup_ids = 0 , | ||
$prices = true | ||
) |
VirtueMartModelProduct::getProductsListing | ( | $group = FALSE , |
$nbrReturnProducts = FALSE , | ||
$withCalc = TRUE , | ||
$onlyPublished = TRUE , | ||
$single = FALSE , | ||
$filterCategory = TRUE , | ||
$category_id = 0 , | ||
$filterManufacturer = TRUE , | ||
$manufacturer_id = 0 , | ||
$omit = 0 | ||
) |
VirtueMartModelProduct::getRawProductPrices | ( | & | $product, |
$quantity, | |||
$virtuemart_shoppergroup_ids, | |||
$front, | |||
$withParent = 0 | |||
) |