Database Access From Product Details Page

Hi there,

I need to list the ingredients of our product on the product details page. My idea was to create 2 tabs for that. However, how can I access the database from there? plain PHP code does not help.

Any ideas or could somebody do it for me quickly?

Thanks in advance.

You’d be best served to add your info as product features and then use the existing tabs or blocks to present them.


If you need to have special data the you can retrieve it and put the data into a template variable.

What about idea to use Short description and Promo text? In this case you can export/import these fields without additional changes. All you need is to remove this data from default product template and create 2 tabs with SMARTY blocks

The data which needed to be displayed is in a separate table in the database. Using product features or short description does not work since I then have to copy the content of the table. It has to stay in this table, since we need those information with another application as well.

Lets say the tables name is "item_details" and the field is "ingredients". What should the smarty code look like to retrieve the info from the database? The shared key is the product SKU (code).

Thanks

The data which needed to be displayed is in a separate table in the database. Using product features or short description does not work since I then have to copy the content of the table. It has to stay in this table, since we need those information with another application as well.

Lets say the tables name is "item_details" and the field is "ingredients". What should the smarty code look like to retrieve the info from the database? The shared key is the product SKU (code).

Thanks

Bad style:

{"SELECT ingredients FROM ?:item_details WHERE product_code = ?s"|db_get_field:$product.product_code nofilter}

Good style:

Use hooks in the fn_get_product_data function to retrieve necessary data from the database and show it in smarty block in the following way

{$product.ingredients nofilter}

You can write an updater that will convert your foreign data into features. The advantage is that there is a lot of built-in support for features so you have more options on what to do with them.