Jump to content

A few custom fields


mnemos

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...