Jump to content

Get Product Supplier price by ID in Front Office


hootersam

Recommended Posts

I associated 3 suppliers with one product. Then I associated supplier prices for that product under Product->Suppliers tab, so each supplier has its own different price.

 

My question is: what method should I use to get price of supplier for that product by supplier id?

 

Is there any method like GetSupplierPriceById(product_id,supplier_id) ?

 

I just want to have all prices available at front office on product page. I'm already passing all suppliers information, but i just noticed that prices aren't there. So i guess its different object than Suppliers.

 

I'm on Prestashop 1.5.6.1.

 

Thanks in advance.

 

Edit: Just to be clear, i just want to display those supplier prices. It has not to do with real product price adding to cart etc.

Edited by hootersam (see edit history)
Link to comment
Share on other sites

Any help on this please?

 

What is the use of supplier price for product anyway? There has to be some method that reads it from database. Please show me which object type owns that method.

 

Is there any classes/methods full documentation for prestashop 1.5.6.1 ?

Link to comment
Share on other sites

  • 2 weeks later...

I found it. ProductSupplier.php

 

/**
* For a given product and supplier, gets the product supplier unit price
*
* @param int $id_product
* @param int $id_product_attribute
* @param int $id_supplier
* @param bool $with_currency Optional
* @return array
*/
public static function getProductSupplierPrice($id_product, $id_product_attribute, $id_supplier, $with_currency = false)
{
// build query
$query = new DbQuery();
$query->select('ps.product_supplier_price_te');
if ($with_currency)
$query->select('ps.id_currency');
$query->from('product_supplier', 'ps');
$query->where('ps.id_product = '.(int)$id_product.'
AND ps.id_product_attribute = '.(int)$id_product_attribute.'
AND ps.id_supplier = '.(int)$id_supplier
);


if (!$with_currency)
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);


$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
if (isset($res[0]))
return $res[0];


return $res;
}
Edited by hootersam (see edit history)
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...