TrynA Posted March 17, 2021 Share Posted March 17, 2021 Hi I want to show data from my added table. I was try add to ProductController this code <?php public function getHSH($id_product) { $id_product = (int)Tools::getValue('id_product'); $sql = 'SELECT kolumna1, kolumna2, id_product FROM '._DB_PREFIX_.'product_hsh where id_product='. $id_product . '' ; $result = Db::getInstance()->executeS($sql); $hsha=array(); foreach ($result as $row) { $hsha[] = array( "hsh1" => $row['kolumna1'], "hsh2" => $row['kolumna2'], ); } $this->context->smarty->assign("hsh", $hsha); and to product-details.tpl <section class="product-features"> <h3 class="h6">{l s='HSH' d='Shop.Theme.Catalog'}</h3> <dl class="data-sheet"> {foreach $hsh as $hsha} <dt class="name">{$hsha.hsh1}</dt> <dd class="value">{$hsha.hsh2}</dd> {/foreach} </dl> </section> and it not working. Can anybody help me ? Link to comment Share on other sites More sharing options...
Rhobur Posted March 18, 2021 Share Posted March 18, 2021 You probably will have to call your get function in initContent or postProcess methods of the controller class and assign there the result to smarty. But, this way of altering core classes is highly discouraged because on subsequent updates this modification will be lost. Instead use an override of the controller, also discouraged but less risky than the first. The optimal way would be a simple module with a controller of your own. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now