Powered By

Displaying Products without Duplication in Zen cart for multiple Language

In Zen cart, if multiple languages are enabled. In the front end the product name and its descriptions changes depending upon the language chosen. To achieve that the shop owner must add product name and description for each language enabled. By that each entry gets updated in the database as a new product. So when observed in the front end, single product is shown multiple time depending upon the languages enabled.


To avoid this and show only only entry for each image and change the description on changing the language the database query must be modified. Let me explain changing the 'New Products module'. Edit the file zencart installation -> includes -> modules -> your template -> new product.php. In that file there will be a database query similar to

$new_products_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, p.products_date_added, pd.products_description from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where p.products_status = 1 " . $display_limit;

Replace that code with this query

$new_products_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, p.products_date_added, pd.products_description from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id inner join " . TABLE_LANGUAGES . " l on pd.language_id = l.languages_id where p.products_id = pd.products_id and l.name = '" . $_SESSION['language'] . "' and p.products_status = 1 " . $display_limit;

Changes made in the Query:

In $_SESSION the language chosen by user will be stored depending on that, from the language table the language id is retrieved and the products are displayed with reference to the language id.

Output for French:
Output for German:

Please Feel free to comment on this post.

Related Posts by Categories