mnemos Posted April 28, 2014 Share Posted April 28, 2014 Hi, I'm trying to get a few queries to show results on the product pages. I have a custom table, that has data uploaded offsite. I need to display in the product page some of the fields in this table (loc_address, loc_address2, postal_code, city) For the moment this would suffice. How would this be achieved in the simplest way? An example would be most appreciated. Thanks. The table structure is as follows: CREATE TABLE IF NOT EXISTS `ps_loc_address` ( `id_loc_address` int(10) NOT NULL AUTO_INCREMENT, `id_product` int(11) NOT NULL, `loc_address` varchar(128) CHARACTER SET utf8 NOT NULL, `loc_address2` varchar(128) CHARACTER SET utf8 NOT NULL, `postal_code` varchar(10) CHARACTER SET utf8 NOT NULL, `city` varchar(128) CHARACTER SET utf8 NOT NULL, `id_country` int(11) NOT NULL, `phone` varchar(50) CHARACTER SET utf8 NOT NULL, `mobile` varchar(50) CHARACTER SET utf8 NOT NULL, `email` varchar(128) CHARACTER SET utf8 NOT NULL, `lat` float NOT NULL, `lng` float NOT NULL, PRIMARY KEY (`id_loc_address`) Link to comment Share on other sites More sharing options...
mnemos Posted April 29, 2014 Author Share Posted April 29, 2014 Update: I've actually managed to get some info on the product page, using this method: in classes/Product.php I added public static function tralala($loc_address){ $sql = 'SELECT `loc_address` FROM ps_loc_address WHERE id_product = 109'; $result = Db::getInstance()->getRow($sql); return $result['loc_address']; } And in product.tpl I've added {Product::tralala(Tools::getvalue('loc_address'))} 109 is an id_product. The problem I have right now is how can I get the displayed product's id? I've tried $sql = 'SELECT `loc_address` FROM ps_loc_address WHERE id_product = '.(int)$this->id; bit this query gives me no result. Any help please? Link to comment Share on other sites More sharing options...
vekia Posted April 29, 2014 Share Posted April 29, 2014 use function with this argument: tralala($id_product) and in .tpl file use: {Product::tralala(Tools::getvalue('id_product'))} and in sql query in where clause use: id_product = '.(int)$id_product; Link to comment Share on other sites More sharing options...
mnemos Posted April 29, 2014 Author Share Posted April 29, 2014 (edited) Genius My tralala function is now a happy camper. Will be followed by all kinds of singing functions )) Edited April 29, 2014 by mnemos (see edit history) 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