[TomatoCart] Show a brand column in the products grid

In this article, I will teach you how to show a brand column in the products grid like shown below:

Snip20141221_1

It’s easy to apply the same change for your store admin panel. Please complete the following steps to achieve it.

Step 1. Open products.php under admin > includes > jsons fold and then find following code snippet:

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_sku, p.products_quantity, p.products_price, 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_sku, p.products_quantity, p.products_price, 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');
      }

Replace it with:

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_sku, m.manufacturers_name, p.products_quantity, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from :table_products p left join :table_manufacturers m on p.manufacturers_id = m.manufacturers_id, :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_sku, m.manufacturers_name, p.products_quantity, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from :table_products p left join :table_manufacturers m on p.manufacturers_id = m.manufacturers_id, :table_products_description pd where p.products_id = pd.products_id and pd.language_id = :language_id');
      }

Find following code:

$Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);

Add following code after it:

$Qproducts->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);

Find following code:

'products_sku'	=> $Qproducts->value('products_sku'),

Add following code after it:

'products_brand'   => $Qproducts>value('manufacturers_name') ? $Qproducts->value('manufacturers_name') : '--',

Step2. Open products_grid.php under admin > includes > extmodules > products fold.

Find following code:

{name: 'products_sku'},

Add following code after it:

{name: 'products_brand'},

Find following code:

{header: "<?php echo $osC_Language->get('table_heading_sku'); ?>", align: 'center', sortable: true, dataIndex: 'products_sku', width: 80},

Add following code after it:

{header: "<?php echo $osC_Language->get('table_heading_brand'); ?>", align: 'center', sortable: true, dataIndex: 'products_brand', width: 80},

Step 3. Open products.php under admin > includes > languages > en_US fold.

Find following code:

table_heading_sku = SKU

Add following code after it:

table_heading_brand = Brand

Note: if you are using the other language rather than English, please just open the same file under the language file to add above code.

Okay now. When you access the products module in the admin panel, you will see a brand column shown in it.

Looking for quality TomatoCart hosting? Check out Arvixe Web Solutions.

Tags: , , , , | Posted under TomatoCart | RSS 2.0

Author Spotlight

Jack Yin

TomatoCart Developer & Co Founder - Arvixe Web Hosting / TomatoCart Community Liaison

One Comment on [TomatoCart] Show a brand column in the products grid

  1. Annette says:

    if it does not work for you there is a small error sin the code

    ‘products_brand’ => $Qproducts>value(‘manufacturers_name’) ? $Qproducts->value(‘manufacturers_name’) : ‘–‘,

    replace with

    ‘products_brand’ => $Qproducts->value(‘manufacturers_name’) ? $Qproducts->value(‘manufacturers_name’) : ‘–‘,

    and it will work fine.

    great addition

Leave a Reply

Your email address will not be published. Required fields are marked *