...
 
Commits (2)
<?php
/******************************************************************************
*
* Subrion E-commerce Software
* Copyright (C) 2018 Intelliants, LLC <https://intelliants.com>
*
* This file is part of Subrion E-commerce Software.
*
* This program is a commercial software and any kind of using it must agree
* to the license, see <https://subrion.pro/license.html>.
*
* This copyright notice may not be removed from the software source without
* the permission of Subrion respective owners.
*
*
******************************************************************************/
class iaBackendController extends iaAbstractControllerModuleBackend
{
protected $_name = 'brands';
protected $_helperName = 'brand';
protected $_gridColumns = ['title', 'description', 'date_added', 'status'];
protected $_gridFilters = ['title' => self::LIKE, 'status' => self::EQUAL];
protected $_gridQueryMainTableAlias = 'b';
protected $_activityLog = ['item' => 'brand'];
protected $iaCategory;
public function init()
{
$this->iaCategory = $this->_iaCore->factoryItem('brand');
}
protected function _gridQuery($columns, $where, $order, $start, $limit)
{
$sql = 'SELECT :columns'
. 'FROM `:table_brands` b '
. 'WHERE :where :order '
. 'LIMIT :start, :limit';
$sql = iaDb::printf($sql, [
'lang' => $this->_iaCore->language['iso'],
'table_brands' => $this->_iaDb->prefix . $this->getTable(),
'columns' => $columns,
'where' => $where,
'order' => $order,
'start' => (int)$start,
'limit' => (int)$limit
]);
return $this->_iaDb->getAll($sql);
}
protected function _update(array $entryData, $entryId)
{
return $this->getHelper()->update($entryData, $entryId);
}
protected function _delete($entryId)
{
return (bool)$this->getHelper()->delete($entryId);
}
protected function _setDefaultValues(array &$entry)
{
$entry = [
'date_added' => date(iaDb::DATETIME_FORMAT),
'slug' => '',
'status' => iaCore::STATUS_ACTIVE
];
}
protected function _assignValues(&$iaView, array &$entryData)
{
parent::_assignValues($iaView, $entryData);
$tree = $this->getHelper()->getTreeVars($entryData);
$tree['url'] .= '&data';
$iaView->assign('datetime', true);
$iaView->assign('relations', $this->_fetchFieldRelations());
$iaView->assign('statuses', $this->getHelper()->getStatuses());
}
protected function _preSaveEntry(array &$entry, array $data, $action)
{
parent::_preSaveEntry($entry, $data, $action);
$entry['slug'] = $this->_slug(empty($data['slug']) ? $data['title'][iaLanguage::getMasterLanguage()->code] : $data['slug']);
if (!$entry['slug']) {
$this->addMessage(iaLanguage::getf('field_is_empty', ['field' => iaLanguage::get('slug')]), false);
} elseif ($this->_iaDb->exists(
'`category_id` = :category AND `slug` = :slug AND `id` != :id',
['category' => $entry['category_id'], 'slug' => $entry['slug'], 'id' => $this->getEntryId()]
)) {
$this->addMessage('product_with_similar_slug_exists_in_category');
}
return !$this->getMessages();
}
protected function _getJsonSlug(array $params)
{
return ['data' => $this->_url($params['title'])];
}
private function _slug($title)
{
return strtolower(iaSanitize::alias($title));
}
private function _url($title)
{
$storefrontPage = $this->_iaCore->factory('page', iaCore::ADMIN)->getByName('storefront');
$path = '';
$path.= $this->_slug($title);
return IA_CLEAR_URL . $storefrontPage['alias'] . $path . '.html';
}
private function _fetchFieldRelations()
{
$subQuery = 'SELECT `id` FROM `' . iaField::getTable(true) . '` WHERE `item` = :item';
$this->_iaDb->bind($subQuery, ['item' => $this->getItemName()]);
$where = '`field_id` IN (' . $subQuery . ')';
return $this->_iaDb->all(['element', 'child'], $where, null, null, iaField::getTableRelations());
}
}
\ No newline at end of file
......@@ -27,6 +27,11 @@ class iaBackendController extends iaAbstractControllerModuleBackend
protected $_activityLog = ['item' => 'product'];
protected $_gridSorting = [
'brand' => ['title', 'b', 'brand'],
'category' => ['title', 'c', 'category']
];
protected $iaCategory;
......@@ -45,9 +50,10 @@ class iaBackendController extends iaAbstractControllerModuleBackend
protected function _gridQuery($columns, $where, $order, $start, $limit)
{
$sql = 'SELECT :columns, c.`title_:lang` `category` '
$sql = 'SELECT :columns, c.`title_:lang` `category`, b.`title_:lang` brand '
. 'FROM `:table_products` p '
. 'LEFT JOIN `:table_categories` c ON (c.`id` = p.`category_id`) '
. 'LEFT JOIN `:table_brands` b ON (b.`id` = p.`brand_id`)'
. 'WHERE :where :order '
. 'LIMIT :start, :limit';
......@@ -55,6 +61,7 @@ class iaBackendController extends iaAbstractControllerModuleBackend
'lang' => $this->_iaCore->language['iso'],
'table_products' => $this->_iaDb->prefix . $this->getTable(),
'table_categories' => $this->_iaDb->prefix . iaCategory::getTable(),
'table_brands' => $this->_iaDb->prefix . 'brands',
'columns' => $columns,
'where' => $where,
'order' => $order,
......@@ -67,6 +74,12 @@ class iaBackendController extends iaAbstractControllerModuleBackend
protected function _gridModifyParams(&$conditions, &$values, array $params)
{
if (!empty($params['brand'])) {
$conditions[] = 'b.`title_' . $this->_iaCore->language['iso'] . '` LIKE :brand';
$values['brand'] = '%' . $params['brand'] . '%';
}
if (!empty($params['parent_category'])) {
$conditions[] = sprintf('p.`category_id` IN (SELECT `child_id` FROM `%s` WHERE `parent_id` = %d)',
$this->iaCategory->getTableFlat(true), $params['parent_category']);
......@@ -112,6 +125,7 @@ class iaBackendController extends iaAbstractControllerModuleBackend
$entry = [
'member_id' => iaUsers::getIdentity()->id,
'category_id' => 0,
'brand_id' => 0,
'date_added' => date(iaDb::DATETIME_SHORT_FORMAT),
'slug' => '',
'price' => 0,
......@@ -125,6 +139,8 @@ class iaBackendController extends iaAbstractControllerModuleBackend
{
parent::_preSaveEntry($entry, $data, $action);
$entry['brand_id'] = (int)$data['brand_id'];
$entry['category_id'] = (int)$data['tree_id'];
//$entry['snippet'] = iaSanitize::snippet($entry['description'], 2000);
$entry['slug'] = $this->_slug(empty($data['slug']) ? $data['title'][iaLanguage::getMasterLanguage()->code] : $data['slug']);
......@@ -147,11 +163,15 @@ class iaBackendController extends iaAbstractControllerModuleBackend
protected function _assignValues(&$iaView, array &$entryData)
{
parent::_assignValues($iaView, $entryData);
$iaBrands = $this->_iaCore->factoryItem('brand', iaCore::FRONT);
$tree = $this->getHelper()->getTreeVars($entryData);
$tree['url'] .= '&data';
$iaView->assign('brands_list', $iaBrands->getBrands());
$iaView->assign('relations', $this->_fetchFieldRelations());
$iaView->assign('statuses', $this->getHelper()->getStatuses());
$iaView->assign('tree', $tree);
......
<?php
/******************************************************************************
*
* Subrion E-commerce Software
* Copyright (C) 2018 Intelliants, LLC <https://intelliants.com>
*
* This file is part of Subrion E-commerce Software.
*
* This program is a commercial software and any kind of using it must agree
* to the license, see <https://subrion.pro/license.html>.
*
* This copyright notice may not be removed from the software source without
* the permission of Subrion respective owners.
*
*
******************************************************************************/
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$iaView->display('brands');
$iaBrand = $iaCore->factoryItem('brand');
switch ($iaView->name()) {
case 'index_brand':
$brands = $iaBrand->getBrands();
$iaView->assign('brands', $brands);
$iaView->title(iaLanguage::get('brands'));
break;
case 'view_brand':
$iaProduct = $iaCore->factoryItem('product');
$pagination = [
'total' => 0,
'limit' => $iaCore->get('brands_number_perpage', 4),
'start' => 0,
'url' => IA_SELF . '?page={page}'
];
$page = isset($_GET['page']) && is_numeric($_GET['page']) ? max((int)$_GET['page'], 1) : 1;
$pagination['start'] = ($page - 1) * $pagination['limit'];
$alias = end($iaCore->requestPath);
$brand_id = $iaBrand->getBrandsBySlug($alias);
$brand = $iaBrand->getById($brand_id);
$iaView->title($brand['title']);
$products = $iaProduct->getByBrand($brand_id, $pagination['start'],$pagination['limit'], null);
$pagination['total'] = $iaProduct->getFoundRows();
$iaView->assign('products', $products);
$iaView->assign('pagination', $pagination);
break;
}
}
\ No newline at end of file
<?php
/******************************************************************************
*
* Subrion E-commerce Software
* Copyright (C) 2017 Intelliants, LLC <https://intelliants.com>
*
* This file is part of Subrion E-commerce Software.
*
* This program is a commercial software and any kind of using it must agree
* to the license, see <https://subrion.pro/license.html>.
*
* This copyright notice may not be removed from the software source without
* the permission of Subrion respective owners.
*
*
******************************************************************************/
class iaBrand extends abstractModuleAdmin
{
protected static $_table = 'brands';
protected $_moduleName = 'commerce';
protected $_itemName = 'brand';
protected function getUrl(array $entryData)
{
$base = $this->getInfo('url');
$category = empty($entryData['category_slug']) ? '' : $entryData['category_slug'];
$path = $category . $entryData['slug'];
return $base . $path . '.html';
}
public function getSitemapEntries()
{
$sql = 'SELECT p.`slug`, c.`slug` `category_slug` '
. 'FROM `:table_products` p '
. 'LEFT JOIN `:table_categories` c ON (p.`category_id` = c.`id`) '
. 'WHERE p.`status` != "hidden" '
. 'ORDER BY p.`title ';
$sql = iaDb::printf($sql, [
'table_products' => self::getTable(true),
'table_categories' => $this->iaDb->prefix . 'categories'
]);
$result = [];
if ($rows = $this->iaDb->getAll($sql)) {
foreach ($rows as $row) {
$result[] = $this->getUrl($row);
}
}
return $result;
}
public function insert(array $itemData)
{
$itemData['date_added'] = date(iaDb::DATE_FORMAT);
$itemData['date_modified'] = date(iaDb::DATE_FORMAT);
return parent::insert($itemData);
}
public function updateCounters($itemId, array $itemData, $action, $previousData = null)
{
$this->_checkIfCountersNeedUpdate($action, $itemData, $previousData,
$this->iaCore->factoryItem('category'));
}
public function getTreeVars(array $entryData)
{
$iaCategory = $this->iaCore->factoryItem('category');
$category = empty($entryData['category_id'])
? $iaCategory->getRoot()
: $iaCategory->getById($entryData['category_id']);
$nodes = $iaCategory->getParents($category['id'], true);
return [
'url' => IA_ADMIN_URL . 'commerce/categories/tree.json?noroot',
'nodes' => implode(',', $nodes),
'id' => $category['id'],
'title' => $category['title']
];
}
}
<?php
/******************************************************************************
*
* Subrion E-commerce Software
* Copyright (C) 2017 Intelliants, LLC <https://intelliants.com>
*
* This file is part of Subrion E-commerce Software.
*
* This program is a commercial software and any kind of using it must agree
* to the license, see <https://subrion.pro/license.html>.
*
* This copyright notice may not be removed from the software source without
* the permission of Subrion respective owners.
*
*
******************************************************************************/
class iaBrand extends abstractModuleFront
{
protected static $_table = 'brands';
protected $_moduleName = 'commerce';
protected $_itemName = 'brand';
const COLUMN_ID = 'id';
const COLUMN_URL = 'url';
public $coreSearchEnabled = true;
public $coreSearchOptions = [
'regularSearchFields' => ['title', 'description']
];
protected $_foundRows = 0;
public function getUrl(array $data)
{
return $this->url('view', $data);
}
public function getFoundRows()
{
return $this->_foundRows;
}
public function url($action, array $item, $relativeToRoot = false)
{
$patterns = [
'default' => ':action/:id/',
'view' => 'view/brands/:alias/',
'my' => 'profile/commerce/'
];
$baseUrl = ('my' == $action) ? IA_URL : $this->getInfo('url');
$categorySlug = isset($item['category_slug']) ? $item['category_slug'] : '';
$productSlug = isset($item['slug']) ? $item['slug'] : '';
$uri = iaDb::printf(
isset($patterns[$action]) ? $patterns[$action] : $patterns['default'],
[
'action' => $action,
'alias' => $categorySlug . $productSlug,
'id' => isset($item[self::COLUMN_ID]) ? $item[self::COLUMN_ID] : ''
]
);
return $baseUrl . $uri;
}
public function coreSearch($stmt, $start, $limit, $order)
{
$rows = $this->getAll($stmt, iaDb::STMT_CALC_FOUND_ROWS . $stmt, $start, $limit);
$count = $this->getFoundRows();
return [$count, $rows];
}
public function getBrands(){
$sql = <<<SQL
SELECT * FROM :brand_table WHERE `status` = ':status';
SQL;
$sql = iaDb::printf($sql, [
'brand_table' => self::getTable(true),
// 'prefix' => $this->_iaDb->getPrefix(),
// 'brand_table' => 'brands',
'status' => iaCore::STATUS_ACTIVE
]);
$rows = $this->iaDb->getAll($sql);
$this->_processValues($rows);
return $rows;
}
public function getBrandsBySlug($slug){
$sql = <<<SQL
SELECT `id` FROM :brand_table WHERE `slug` = ':slug';
SQL;
$sql = iaDb::printf($sql, [
'brand_table' => self::getTable(true),
'slug' => $slug
]);
$rows = $this->iaDb->getAll($sql);
return array_shift($rows);
}
}
......@@ -87,6 +87,13 @@ class iaProduct extends abstractModuleFront
return $baseUrl . $uri;
}
public function getFavorites(array $ids)
{
$where = 'p.id IN (' . implode(',', $ids) . ')';
return $this->_get($where, 0, 1000);
}
public function coreSearch($stmt, $start, $limit, $order)
{
$rows = $this->_get($stmt, $start, $limit, $order);
......@@ -127,6 +134,17 @@ class iaProduct extends abstractModuleFront
return $this->_get($where, $start, $limit, $order);
}
public function getByBrand($brand_id, $start, $limit, $order)
{
$brand_id = $brand_id['id'];
$where = 'p.`status` != :approval';
$this->iaDb->bind($where, ['approval' => iaCore::STATUS_APPROVAL]);
return $this->_get("p.brand_id = $brand_id",$start, $limit, $order);
}
public function getBySlug($slug)
{
$where = 'p.`slug` = :slug';
......
......@@ -16,6 +16,7 @@
<items>
<item table_name="products" payable="0" pages="storefront,categories,product_details">product</item>
<item table_name="categories" pages="storefront,categories" payable="0">category</item>
<item table_name="brands" payable="0" pages="storefront,product_details">brand</item>
<item table_name="orders" payable="0">order</item>
</items>
......@@ -25,6 +26,9 @@
<action name="products_list" url="commerce/products/" icon="list" pages="commerce_stats,products:add,products:edit">List</action>
<action name="products_add" url="commerce/products/add/" icon="plus-alt" pages="products,products:edit">New Product</action>
<action name="brands_list" url="commerce/brands/" icon="list" pages="commerce_stats,brands:add,brands:edit">List</action>
<action name="brands_add" url="commerce/brands/add/" icon="plus-alt" pages="brands,brands:edit">New Brand</action>
</actions>
<groups>
......@@ -37,6 +41,7 @@
<page group="commerce" name="orders" url="commerce/orders/" filename="orders" menus="menu">Orders</page>
<page group="commerce" menus="menu">Content</page>
<page group="commerce" name="products" url="commerce/products/" filename="products" menus="menu">Products</page>
<page group="commerce" name="brands" url="commerce/brands/" filename="brands" menus="menu">Brands</page>
<page group="commerce" name="categories" url="commerce/categories/" filename="categories" menus="menu">Categories</page>
</adminpages>
......@@ -45,6 +50,10 @@
<page group="commerce" name="add_product" url="|PACKAGE|add/" menus="main" filename="manage" action="add" parent="view_product" fields_item="product">Add Product</page>
<page group="commerce" name="edit_product" url="|PACKAGE|edit/" filename="manage" action="edit" parent="view_product" fields_item="product">Edit Product</page>
<page group="commerce" name="delete_product" url="|PACKAGE|delete/" filename="manage" action="delete" parent="view_product" service="1">Delete Product</page>
<page group="commerce" name="index_brand" url="|PACKAGE|brands/" filename="brands" menus="main" action="read">Brands</page>
<page group="commerce" name="view_brand" url="|PACKAGE|view/brands/" filename="brands" action="read">Brand View</page>
<page group="commerce" name="products_index_member" url="profile/products/" menus="account" nofollow="1" parent="profile" fields_item="product">My Products</page>
<page group="commerce" name="categories" url="|PACKAGE|categories/" menus="main">Categories</page>
<page group="commerce" name="view_product" url="|PACKAGE|product/" filename="view" readonly="1">Product Details</page>
......@@ -57,6 +66,10 @@
<object meta_object="admin_page" id="products" action="add" access="1">Add product</object>
<object meta_object="admin_page" id="products" action="edit" access="1">Edit product</object>
<object meta_object="admin_page" id="brands" access="1">Manage brands</object>
<object meta_object="admin_page" id="brands" action="add" access="1">Add brand</object>
<object meta_object="admin_page" id="brands" action="edit" access="1">Edit brand</object>
<object id="cart" action="add" access="1">Add product to cart</object>
<object id="cart" action="delete" access="1">Delete product from cart</object>
</permissions>
......@@ -205,6 +218,12 @@
<field item="product" group="seo" name="meta_description" type="textarea" length="255" adminonly="1" editable="0" multilingual="1" page="add_product,edit_product">Meta-Description</field>
<field item="product" group="seo" name="meta_keywords" type="text" length="255" adminonly="1" editable="0" multilingual="1" page="add_product,edit_product">Meta-Keywords</field>
<field item="brand" group="general" name="title" type="text" required="1" searchable="1" link_to="1" multilingual="1" length="255" page="add_brand,edit_brand">Title</field>
<field item="brand" group="general" name="description" type="textarea" editor="1" editable="0" multilingual="1" searchable="1" page="add_brand,edit_brand">Description</field>
<field item="brand" group="pictures" name="pictures" type="pictures" thumb_width="320" thumb_height="180" width="1600" height="900" length="12" folder_name="brands" mode="fit" page="add_brand,edit_brand">Logo</field>
<field item="brand" group="seo" name="meta_description" type="textarea" length="255" adminonly="1" editable="0" multilingual="1" page="add_brand,edit_brand">Meta-Description</field>
<field item="brand" group="seo" name="meta_keywords" type="text" length="255" adminonly="1" editable="0" multilingual="1" page="add_brand,edit_brand">Meta-Keywords</field>
<field item="category" group="general" name="title" type="text" required="1" length="255" multilingual="1">Title</field>
<field item="category" group="general" name="description" type="textarea" editor="1" editable="0" searchable="1" multilingual="1">Description</field>
<field item="category" group="seo" name="meta_description" type="textarea" length="255" adminonly="1" editable="0" multilingual="1">Meta-Description</field>
......@@ -240,6 +259,9 @@
<phrase category="common" key="hidden">Hidden</phrase>
<phrase category="common" key="price">Price</phrase>
<phrase category="common" key="product">Product</phrase>
<phrase category="common" key="brand">Brand</phrase>
<phrase category="common" key="brands">Brands</phrase>
<phrase category="common" key="no_brands">No brands.</phrase>
<phrase category="common" key="products">Products</phrase>
<phrase category="common" key="quantity">Quantity</phrase>
<phrase category="common" key="subtotal">Sub-Total</phrase>
......@@ -347,6 +369,7 @@ CREATE TABLE `{prefix}products` (
`id` int(9) unsigned NOT NULL auto_increment,
`member_id` mediumint(8) unsigned NOT NULL,
`category_id` mediumint(7) unsigned NOT NULL,
`brand_id` mediumint(8) unsigned NULL,
`date_added` datetime NOT NULL,
`date_modified` datetime NOT NULL,
`status` enum('active', 'approval', 'out_of_stock', 'hidden') NOT NULL default 'approval',
......@@ -366,6 +389,21 @@ CREATE TABLE `{prefix}products` (
) {mysql_version};
]]>
</sql>
<sql>
<![CDATA[
CREATE TABLE `{prefix}brands` (
`id` int(9) unsigned NOT NULL auto_increment,
`date_added` datetime NOT NULL,
`date_modified` datetime NOT NULL,
`status` enum('active', 'approval', 'out_of_stock', 'hidden') NOT NULL default 'approval',
`slug` varchar(96) NOT NULL,
PRIMARY KEY (`id`),
KEY `SLUG` (`slug` (96)),
UNIQUE `UNIQUE` (`slug`)
) {mysql_version};
]]>
</sql>
<sql>
<![CDATA[
CREATE TABLE `{prefix}categories` (
......@@ -449,7 +487,7 @@ $iaCore->factoryModule('category', 'commerce')->setupDbStructure();
<uninstall>
<sql>
<![CDATA[
DROP TABLE IF EXISTS `{prefix}products`, `{prefix}categories`, `{prefix}categories_flat`,
DROP TABLE IF EXISTS `{prefix}products`,`{prefix}brands`, `{prefix}categories`, `{prefix}categories_flat`,
`{prefix}cart`, `{prefix}cart_items`, `{prefix}orders`, `{prefix}orders_items`;
]]>
</sql>
......
Ext.onReady(function () {
if (Ext.get('js-grid-placeholder')) {
var grid = new IntelliGrid({
columns: [
'selection',
{name: 'title', title: _t('title'), width: 1, editor: 'text'},
{name: 'date_added', title: _t('date_added'), width: 180},
'status',
'update',
'delete'
],
sorters: [{property: 'date_modified', direction: 'DESC'}],
statuses: ['active', 'approval', 'out_of_stock', 'hidden'],
texts: {
delete_multiple: _t('do_you_want_to_delete_selected_products'),
delete_single: _t('do_you_want_to_delete_this_product')
}
}, false);
grid.toolbar = new Ext.Toolbar({
items: [
{
emptyText: _t('field_brand_title'),
listeners: intelli.gridHelper.listener.specialKey,
name: 'title',
width: 150,
xtype: 'textfield'
},{
id: 'fltStatus',
displayField: 'title',
editable: false,
emptyText: _t('status'),
name: 'status',
store: grid.stores.statuses,
typeAhead: true,
valueField: 'value',
width: 100,
xtype: 'combo'
},{
handler: function() {
intelli.gridHelper.search(grid)
},
id: 'fltBtn',
text: '<i class="i-search"></i> ' + _t('search')
},{
handler: function() {
intelli.gridHelper.search(grid, true)
},
text: '<i class="i-close"></i> ' + _t('reset')
}]
});
grid.init();
}
});
intelli.titleCache = '';
intelli.fillUrlBox = function () {
var slug = $('#input-slug').val();
var title = slug || $('#field_brand_title').val();
var category = $('#input-tree').val();
var cache = title + '%%' + location + '%%' + category;
if (title && intelli.titleCache !== cache) {
var params = {title: title, category: category};
if (slug) params.slug = 1;
$.get(intelli.config.admin_url + '/commerce/brands/slug.json', params, function(response) {
console.log(response);
if (response.data) {
$('#js-url-preview').html('<a href="' + response.data + '" target="_blank">' + response.data + '</a>');
}
});
}
intelli.titleCache = cache;
};
$(function () {
$('#field_brand_title').keyup(function () {
$('#field-slug').show();
});
$('#field_brand_title, #input-slug').blur(intelli.fillUrlBox).blur();
// category-dependent fields
var $relationsData = $('#js-input-field-relations');
var relations = {
fields: String($relationsData.data('children')).split(','),
values: String($relationsData.data('values')).split(',')
};
$('#js-tree').on('changed.jstree', function(e, data){
var node = data.instance.get_node(data.selected);
for (var i = 0; i < relations.fields.length; i++) {
var $fieldZone = $('#' + relations.fields[i] + '_fieldzone');
if (node.id == relations.values[i]) {
$fieldZone.show();
break;
}
else $fieldZone.hide();
}
});
});
\ No newline at end of file
......@@ -8,6 +8,7 @@ Ext.onReady(function () {
}},
{name: 'title', title: _t('title'), width: 1, editor: 'text'},
{name: 'category', title: _t('category'), width: 1},
{name: 'brand', title: _t('brand'), width: 1},
{name: 'price', title: _t('price'), width: 100, editor: 'number'},
{name: 'date_added', title: _t('date_added'), width: 180},
'status',
......
......@@ -17,6 +17,7 @@
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$iaProduct = $iaCore->factoryItem('product');
$iaBrand = $iaCore->factoryItem('brand');
$iaCategory = $iaCore->factoryItem('category');
$iaUtil = $iaCore->factory('util');
......@@ -62,7 +63,6 @@ if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
}
$iaField = $iaCore->factory('field');
$iaPlan = $iaCore->factory('plan');
$plans = $iaPlan->getPlans($iaProduct->getItemName());
......@@ -83,6 +83,10 @@ if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$messages[] = iaLanguage::get('confirmation_code_incorrect');
}
if (isset($_POST['brand_id'])){
$item['brand_id'] = $_POST['brand_id'];
}
if (empty($_POST['category_id']) || !is_numeric($_POST['category_id'])) {
$error = true;
$messages[] = iaLanguage::getf('field_is_not_selected', ['field' => iaLanguage::get('category')]);
......@@ -123,7 +127,6 @@ if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$messages[] = iaLanguage::get('product_successfully_added');
} else {
$item['id'] = $product['id'];
$result = $iaProduct->update($item, $item['id']);
$messages[] = iaLanguage::get('product_successfully_updated');
}
......@@ -202,6 +205,7 @@ if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$iaView->assign('children', $categoryPath);
$iaView->assign('item', $product);
$iaView->assign('categories', $iaCategory->getByLevel(1));
$iaView->assign('brands_list', $iaBrand->getBrands());
$iaView->assign('plans', $plans);
$iaView->assign('sections', $sections);
......
<form method="post" enctype="multipart/form-data" class="sap-form form-horizontal">
{preventCsrf}
{capture name='title' append='field_after'}
<div class="row" id="field-slug">
<label class="col col-lg-2 control-label" for="input-slug">{lang key='slug'}</label>
<div class="col col-lg-4">
<input type="text" name="slug" id="input-slug" value="{$item.slug|escape}">
<p class="help-block text-break-word">{lang key='page_url_will_be'}: <span class="text-danger" id="js-url-preview">{$smarty.const.IA_CLEAR_URL}{$item.slug|escape}</span></p>
</div>
</div>
<input type="hidden" id="js-input-field-relations"{if $relations} data-children="{foreach $relations as $entry}{$entry.child}{if !$entry@last},{/if}{/foreach}"
data-values="{foreach $relations as $entry}{$entry.element}{if !$entry@last},{/if}{/foreach}"{/if}>
{/capture}
{ia_hooker name='smartyAdminSubmitItemBeforeFields'}
{include 'field-type-content-fieldset.tpl' isSystem=true exceptions=['category_id']}
</form>
{ia_hooker name='smartyAdminSubmitItemBeforeFooter'}
{ia_add_media files='js:_IA_URL_modules/commerce/js/admin/brands'}
\ No newline at end of file
......@@ -10,6 +10,18 @@
</div>
</div>
<div class="row" id="field-brand">
<label class="col col-lg-2 control-label" for="input-brand">{lang key='brand'}</label>
<div class="col col-lg-4">
<select class="form-control" name="brand_id" id="field_brand">
<option value="">{lang key='_select_'}</option>
{foreach $brands_list as $optionKey => $optionValue}
<option value="{$optionValue.id}" {if $item.brand_id && $item.brand_id == $optionValue.id } selected {/if} {if !empty($smarty.post) && $smarty.post.brand_id && $smarty.post.brand_id == $optionValue.id } selected {/if} > {$optionValue.title}</option>
{/foreach}
</select>
</div>
</div>
<input type="hidden" id="js-input-field-relations"{if $relations} data-children="{foreach $relations as $entry}{$entry.child}{if !$entry@last},{/if}{/foreach}"
data-values="{foreach $relations as $entry}{$entry.element}{if !$entry@last},{/if}{/foreach}"{/if}>
{include 'tree.tpl'}
......
{if 'index_brand' == $core.page.name}
{if !empty($brands)}
<div class="row ia-brands" style="margin-bottom: 30px;">
{foreach $brands as $brand}
<div class="col-md-3">
<div class="brand" style="text-align: center;">
<a href="{$brand.link}" class="brand__image" >
{ia_image file=$brand.pictures[0] type='thumbnail' width=150 title=$brand.title}
</a>
<div class="brand__body">
<div class="brand__body__title" style="margin-top: 10px;"><a href="{$brand.link}">{$brand.title|escape}</a></div>
</div>
</div>
</div>
{if $brand@iteration % 4 == 0 && !$brand@last}
</div>
<div class="row ia-brands">
{/if}
{/foreach}
</div>
{else}
<div class="alert alert-info">{lang key='no_brands'}</div>
{/if}
{/if}
{if 'view_brand' == $core.page.name}
{if !empty($products)}
<div class="row ia-products" style="margin-bottom: 30px;">
{foreach $products as $product}
<div class="col-md-3">
<div class="cards products" style="text-align: center;">
<a href="{$product.link}" class="brand__image" >
{if !empty($product.pictures)}
{ia_image file=$product.pictures[0] type='thumbnail' width=150 title=$product.title}
{else}
{ia_image type='thumbnail' width=150 }
{/if}
</a>
<div class="card__body">
<div class="card__body__title" style="margin-top: 10px;"><a href="{$product.link}">{$product.title|escape}</a></div>
<div class="card__body__snippet">{$product.snippet|truncate:50:'...':true}</div>
<div class="card__body__price">{$product.price_formatted}</div>
<div class="card__body__actions">
<a href="#" class="js-cmd-quick-view" data-id="{$product.id}"><span class="fa fa-search"></span></a>
<button type="button" class="js-cmd-add-cart" data-id="{$product.id}">{lang key='add_to_cart'}</button>
{accountActions item=$product itemtype=$commerce.itemName classname='btn-info pull-left'}
</div>
</div>
</div>
</div>
{if $product@iteration % 4 == 0 && !$product@last}
</div>
<div class="row ia-products">
{/if}
{/foreach}
</div>
<div class="row">
<div class="col-md-12" style="text-align: center;">
{navigation aTotal=$pagination.total aTemplate=$pagination.url aItemsPerPage=$pagination.limit aIgnore=true}
</div>
</div>
{else}
<div class="alert alert-info">{lang key='no_products'}</div>
{/if}
{/if}
\ No newline at end of file
......@@ -29,6 +29,21 @@
</div>
{/capture}
{capture name='title' append='field_after'}
<div class="form-group fieldzone regular" id="title_fieldzone">
<label for="field_brand_title">{lang key='brand'}:</label>
<div class="form-group">
<select class="form-control" name="brand_id" id="field_brand">
<option value="">-- select --</option>
{foreach $brands_list as $optionKey => $optionValue}
{_v($optionValue)}
<option value="{$optionValue.id}" {if $optionValue.id && $item.brand_id == $optionValue.id } selected {/if} {if !empty($smarty.post) && $smarty.post.id && $smarty.post.id == $optionValue.id } selected {/if}> {$optionValue.title}</option>
{/foreach}
</select>
</div>
</div>
{/capture}
{include 'item-view-tabs.tpl' exceptions=['category_id']}
<div class="ia-form__after-tabs">
......