|
|
Add product code in TC Control Panel Products window 11 Months, 3 Weeks ago
|
Karma: 2
|
|
Hello TC Lovers
Has someone already added the product code column in products window from Control Panel or know whats the easy way to do it?
With the product code visable is easy to do stock without edit the product each time. [if you done have the exact name as the product from the stock list]
|
|
|
|
|
|
|
Re:Add product code in TC Control Panel Products window 11 Months, 3 Weeks ago
|
Karma: 2
|
I have modifie the file in admin/includes/extmodules/products/products_grid.php and now it shoews the heading in products but no data for each product.
{name: 'products_sku'},
and
{header: "<?php echo $osC_Language->get('table_heading_sku'); ?>", dataIndex: 'products_sku', sortable: true, width: 100, align: 'right'},

|
|
|
|
|
|
|
Re:Add product code in TC Control Panel Products window 11 Months, 3 Weeks ago
|
Karma: 19
|
Hi Elfbebe
I am assuming from your post that you just want to display the products SKU, is this what you wanted to do! If yes then modify the following script:
admin/includes/json/products.php
Go to the listProducts function in the json file and replace it with this code below:
| Code: |
function listProducts() {
global $toC_Json, $osC_Database, $osC_Language, $osC_Currencies;
require_once('../includes/classes/currencies.php');
$osC_Currencies = new osC_Currencies();
$start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
$limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
$current_category_id = end(explode( '_' ,(empty($_REQUEST['categories_id']) ? 0 : $_REQUEST['categories_id'])));
if ( $current_category_id > 0 ) {
$osC_CategoryTree = new osC_CategoryTree_Admin();
$osC_CategoryTree->setBreadcrumbUsage(false);
$in_categories = array($current_category_id);
foreach($osC_CategoryTree->getTree($current_category_id) as $category) {
$in_categories[] = $category['id'];
}
$Qproducts = $osC_Database-
>query('select distinct p.products_id, p.products_type, pd.products_name, p.products_quantity, p.products_price, p.products_sku, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from :table_products p, :
table_products_description pd, :table_products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = :language_id and p.products_id = p2c.products_id and p2c.categories_id in (:categories_id)');
$Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
$Qproducts->bindRaw(':categories_id', implode(',', $in_categories));
} else {
$Qproducts = $osC_Database-
>query('select p.products_id, p.products_type, pd.products_name, p.products_quantity, p.products_price, p.products_sku, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from :table_products p, :
table_products_description pd where p.products_id = pd.products_id and pd.language_id = :language_id');
}
if ( !empty($_REQUEST['search']) ) {
$Qproducts->appendQuery('and pd.products_name like :products_name');
$Qproducts->bindValue(':products_name', '%' . $_REQUEST['search'] . '%');
}
if ( !empty($_REQUEST['sort']) && !empty($_REQUEST['dir']) ) {
$Qproducts->appendQuery('order by :sort :dir');
$Qproducts->bindRaw(':sort', $_REQUEST['sort']);
$Qproducts->bindRaw(':dir', $_REQUEST['dir']);
} else {
$Qproducts->appendQuery(' order by pd.products_id desc');
}
$Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
$Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
$Qproducts->bindInt(':language_id', $osC_Language->getID());
$Qproducts->setExtBatchLimit($start, $limit);
$Qproducts->execute();
$records = array();
while ($Qproducts->next()) {
$products_price = $osC_Currencies->format($Qproducts->value('products_price'));
$products_sku = $Qproducts->value('products_sku');
if ($Qproducts->valueInt('products_type') == PRODUCT_TYPE_GIFT_CERTIFICATE) {
$Qcertificate = $osC_Database->query('select open_amount_min_value, open_amount_max_value from :table_products_gift_certificates where gift_certificates_amount_type = :gift_certificates_amount_type and products_id = :products_id');
$Qcertificate->bindTable(':table_products_gift_certificates', TABLE_PRODUCTS_GIFT_CERTIFICATES);
$Qcertificate->bindInt(':gift_certificates_amount_type', GIFT_CERTIFICATE_TYPE_OPEN_AMOUNT);
$Qcertificate->bindInt(':products_id', $Qproducts->value('products_id'));
$Qcertificate->execute();
if ($Qcertificate->numberOfRows() > 0) {
$products_price = $osC_Currencies->format($Qcertificate->value('open_amount_min_value')) . ' ~ ' . $osC_Currencies->format($Qcertificate->value('open_amount_max_value'));
}
}
$Qstatus = $osC_Database->query('select products_id from :table_products_frontpage where products_id = :products_id');
$Qstatus->bindInt(':products_id', $Qproducts->value('products_id'));
$Qstatus->bindTable(':table_products_frontpage', TABLE_PRODUCTS_FRONTPAGE);
$Qstatus->execute();
if ($Qstatus->numberOfRows() > 0) {
$products_frontpage = 1;
} else {
$products_frontpage = 0;
}
$records[] = array(
'products_id' => $Qproducts->value('products_id'),
'products_name' => $Qproducts->value('products_name'),
'products_frontpage' => $products_frontpage,
'products_status' => $Qproducts->value('products_status'),
'products_price' => $products_price,
'products_sku' => $products_sku,
'products_quantity' => $Qproducts->value('products_quantity')
);
}
$response = array(EXT_JSON_READER_TOTAL => $Qproducts->getBatchSize(),
EXT_JSON_READER_ROOT => $records);
echo $toC_Json->encode($response);
}
|
admin/includes/extmodules/products/products_grid.php
Then in the products_grid page, replace the products grids config section with this below:
| Code: |
Toc.products.ProductsGrid = function(config) {
config = config || {};
config.border = false;
config.region = 'center';
config.viewConfig = {emptyText: TocLanguage.gridNoRecords};
config.animCollapse = false;
config.enableDragDrop = true;
config.ddGroup = 'productDD';
config.ds = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'products',
action: 'list_products'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
id: 'products_id'
}, [
{name: 'products_id'},
{name: 'products_name'},
{name: 'products_frontpage'},
{name: 'products_status'},
{name: 'products_price', type: 'string'},
{name: 'products_sku', type: 'string'},
{name: 'products_quantity', type: 'int'}
]),
remoteSort: true
});
renderStatus = function(status) {
if(status == 1) {
return '<img class="img-button" src="images/icon_status_green.gif" /> <img class="img-button btn-status-off" style="cursor: pointer" src="images/icon_status_red_light.gif" />';
}else {
return '<img class="img-button btn-status-on" style="cursor: pointer" src="images/icon_status_green_light.gif" /> <img class="img-button" src= "images/icon_status_red.gif" />';
}
};
config.rowActions = new Ext.ux.grid.RowActions({
actions:[
{iconCls: 'icon-edit-record', qtip: TocLanguage.tipEdit},
{iconCls: 'icon-delete-record', qtip: TocLanguage.tipDelete},
{iconCls: 'icon-copy-record', qtip: '<?php echo $osC_Language->get('action_duplicate') ?>'}],
widthIntercept: Ext.isSafari ? 4 : 2
});
config.rowActions.on('action', this.onRowAction, this);
config.plugins = config.rowActions;
config.sm = new Ext.grid.CheckboxSelectionModel();
config.cm = new Ext.grid.ColumnModel([
config.sm,
{id:'products_name', header: "<?php echo $osC_Language->get('table_heading_products'); ?>", sortable: true, dataIndex: 'products_name'},
{header: "<?php echo $osC_Language->get('table_heading_frontpage'); ?>", align: 'center', renderer: renderStatus, dataIndex: 'products_frontpage', width: 90},
{header: "<?php echo $osC_Language->get('table_heading_status'); ?>", align: 'center', renderer: renderStatus, sortable: true, dataIndex: 'products_status', width: 80},
{header: "<?php echo $osC_Language->get('table_heading_price'); ?>", dataIndex: 'products_price', sortable: true, width: 80, align: 'right'},
{header: "<?php echo $osC_Language->get('table_heading_sku'); ?>", dataIndex: 'products_sku', sortable: true, width: 80, align: 'right'},
{header: "<?php echo $osC_Language->get('table_heading_quantity'); ?>", dataIndex: 'products_quantity', sortable: true, width: 80, align: 'right'},
config.rowActions
]);
config.autoExpandColumn = 'products_name';
config.txtSearch = new Ext.form.TextField({
width:160,
paramName: 'search'
});
config.tbar = [
{
text: TocLanguage.btnAdd,
iconCls:'add',
handler: this.onAdd,
scope: this
},
'-',
{
text: TocLanguage.btnDelete,
iconCls:'remove',
handler: this.onBatchDelete,
scope: this
},
'-',
{
text: TocLanguage.btnRefresh,
iconCls:'refresh',
handler: this.onRefresh,
scope: this
},
'->',
config.txtSearch,
' ',
{
iconCls : 'search',
handler : this.onSearch,
scope : this
}
];
var thisObj = this;
config.bbar = new Ext.PageToolbar({
pageSize: Toc.CONF.GRID_PAGE_SIZE,
store: config.ds,
steps: Toc.CONF.GRID_STEPS,
btnsConfig:[
{
text: TocLanguage.btnActivate,
iconCls:'publish',
handler: function(){
thisObj.onBatchStatusClick(1);
}
},
{
text: TocLanguage.btnDeactivate,
iconCls:'unpublish',
handler: function(){
thisObj.onBatchStatusClick(0);
}
}
],
beforePageText : TocLanguage.beforePageText,
firstText: TocLanguage.firstText,
lastText: TocLanguage.lastText,
nextText: TocLanguage.nextText,
prevText: TocLanguage.prevText,
afterPageText: TocLanguage.afterPageText,
refreshText: TocLanguage.refreshText,
displayInfo: true,
displayMsg: TocLanguage.displayMsg,
emptyMsg: TocLanguage.emptyMsg,
prevStepText: TocLanguage.prevStepText,
nextStepText: TocLanguage.nextStepText
});
Toc.products.ProductsGrid.superclass.constructor.call(this, config);
};
|
|
|
|
|
|
|
|
Re:Add product code in TC Control Panel Products window 11 Months, 3 Weeks ago
|
Karma: 19
|
Please note: that the Tomatocart forums code feature is ommiting the php echo's from the script, I dont know why it is doing this...
eg: look at the following section of code:
config.cm = new Ext.grid.ColumnModel([
config.sm,
{id:'products_name', header: "", sortable: true, dataIndex: 'products_name'},
{header: "", align: 'center', renderer: renderStatus, dataIndex: 'products_frontpage', width: 90},
{header: "", align: 'center', renderer: renderStatus, sortable: true, dataIndex: 'products_status', width: 80},
{header: "", dataIndex: 'products_price', sortable: true, width: 80, align: 'right'},
{header: "", dataIndex: 'products_sku', sortable: true, width: 80, align: 'right'},
{header: "", dataIndex: 'products_quantity', sortable: true, width: 80, align: 'right'},
config.rowActions
]);
The header titles should be showing this below:
config.cm = new Ext.grid.ColumnModel([
config.sm,
{id:'products_name', header: "<?php echo $osC_Language->get('table_heading_products'); ?>", sortable: true, dataIndex: 'products_name'},
{header: "<?php echo $osC_Language->get('table_heading_frontpage'); ?>", align: 'center', renderer: renderStatus, dataIndex: 'products_frontpage', width: 90},
{header: "<?php echo $osC_Language->get('table_heading_status'); ?>", align: 'center', renderer: renderStatus, sortable: true, dataIndex: 'products_status', width: 80},
{header: "<?php echo $osC_Language->get('table_heading_price'); ?>", dataIndex: 'products_price', sortable: true, width: 80, align: 'right'},
{header: "<?php echo $osC_Language->get('table_heading_sku'); ?>", dataIndex: 'products_sku', sortable: true, width: 80, align: 'right'},
{header: "<?php echo $osC_Language->get('table_heading_quantity'); ?>", dataIndex: 'products_quantity', sortable: true, width: 80, align: 'right'},
config.rowActions
]);
Ok, because there is a problem posting the code on the forum, I am adding the code in a text file for you to copy from. Just backup your two products files you'll be changing, before making the changes...
Hope this helps!
Regards
Grant
File Attachment: File Name: sku.txtFile Size: 10622
|
|
|
|
Last Edit: 2012/06/01 13:07 By grantporter.
|
|
|
Re:Add product code in TC Control Panel Products window 11 Months, 2 Weeks ago
|
Karma: 2
|
|
Nice work porter..i have implemened and it works fine.. i've forgoten to edit products.php from json.
Sorry for the late reply..
|
|
|
|
|
|
|
Re:Add product code in TC Control Panel Products window 11 Months, 1 Week ago
|
Karma: 19
|
|
You're welcome, glad I could help!
|
|
|
|
|
|
|