To create a support ticket, start a search

Orders Grid: adding 'Image' field


Target

We would like to add a column displaying the product Image within the order interface.

 

Setup

To add the field to the list of available fields for your grids, click on the in the 'Add a field' panel and enter the following information:

What is the field ID?: image

 

Sc creates the field, you now need to populate the grid with:

Field name: Image
Table: Another table
Type: only display

 

From the Advanced Properties panel on the right handside:

- select the menu SQL Select and enter:

return ' ,i.id_image';

 

- select the menu SQL Left Join and enter:

return " LEFT JOIN "._DB_PREFIX_."image i ON (i.id_product= p.id_product AND i.cover=1) ";

 

- select the menu PHP Get Row Data and enter:

if ($col == 'image' && !empty($orderrow['id_image'])) {
    $tmp = explode('-', $orderrow['product_id']);
    $id_product = (int)$tmp[0];
    $url = SC_PS_PATH_REL . 'img/p/' . getImgPath((int)$id_product, (int)$orderrow['id_image'], _s('CAT_PROD_GRID_IMAGE_SIZE'));
    if (file_exists($url)) {
        $orderrow[$col] = '<img src="' . $url . '" />';
    }
}

 

Exit the editing window.

The new field is now present in the list of available fields and you can add it to your Order grids.
 




Related articles