- Posts: 12
- Thank you received: 0
populate variants in product object
12 years 10 months ago #133275
by vu-ittc
populate variants in product object was created by vu-ittc
code taken from your "dev" section:
$prodClass = hikashop_get('class.product');
$prod=$prodClass->get($id);
the resulting object doesn't contain any information about product variants, like it should, according to object reference provided on your website, the class methods are too abstract and there is no method suitable for extracting this data (at least i failed to found one). how can i get product variants (in the way they are displayed on your product object reference page) by product id?
$prodClass = hikashop_get('class.product');
$prod=$prodClass->get($id);
the resulting object doesn't contain any information about product variants, like it should, according to object reference provided on your website, the class methods are too abstract and there is no method suitable for extracting this data (at least i failed to found one). how can i get product variants (in the way they are displayed on your product object reference page) by product id?
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
12 years 10 months ago #133290
by Mohamed Thelji
Replied by Mohamed Thelji on topic populate variants in product object
Hi,
Note that you'll also be able to do it like this :
Note that you'll also be able to do it like this :
Code:
$this->database = JFactory::getDBO();
$query='SELECT * FROM '.hikashop_table('product').' WHERE product_parent_id ='.$YOURPRODUCTID;
$this->database->setQuery($query);
$variants = $this->database->loadObjectList();
Please Log in or Create an account to join the conversation.
12 years 9 months ago #135708
by vu-ittc
Replied by vu-ittc on topic populate variants in product object
Hi,
thanks, however the product doesn't have prices and taxes arrays included, so it returns incorrect prices, is there a way to do it by using hikashop framework?
Link - parduotuve.joomlatvs.lt/joomla/
Regards,
Arminas
thanks, however the product doesn't have prices and taxes arrays included, so it returns incorrect prices, is there a way to do it by using hikashop framework?
Link - parduotuve.joomlatvs.lt/joomla/
Regards,
Arminas
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
12 years 9 months ago - 12 years 9 months ago #135719
by Mohamed Thelji
Replied by Mohamed Thelji on topic populate variants in product object
Hi,
the problem is coming from the fact that the price is in the "hikashop_price" table, this kind of code will probably do the job :
the problem is coming from the fact that the price is in the "hikashop_price" table, this kind of code will probably do the job :
Code:
$this->database = JFactory::getDBO();
$query='SELECT * FROM '.hikashop_table('product').' AS product LEFT JOIN '.hikashop_table('price').' AS price ON product.product_id=price.price_product_id WHERE product.product_id = '. $this->element->product_id .' GROUP BY product.product_id ORDER BY price.price_min_quantity ASC';
$this->database->setQuery($query);
$product = $this->database->loadObjectList();
Last edit: 12 years 9 months ago by Mohamed Thelji.
Please Log in or Create an account to join the conversation.
12 years 9 months ago #135728
by vu-ittc
Replied by vu-ittc on topic populate variants in product object
ok, better, now i just need the taxes and the price_with_tax in this object, how do i do that?
Please Log in or Create an account to join the conversation.
12 years 9 months ago #135776
by nicolas
Replied by nicolas on topic populate variants in product object
You need to do something like that:
Code:
$currencyClass = hikashop_get('class.currency');
foreach($product as $k => $v){
$product[$k]->price_with_tax = $currencyClass->getTaxedPrice($v,hikashop_getZone(),$v->product_tax_id);
$product[$k]->taxes = $currencyClass->taxRates;
}
Please Log in or Create an account to join the conversation.
Time to create page: 0.208 seconds