From 8400eb53e5f4f0b60e3fdfbba0afa6f8759ec0c9 Mon Sep 17 00:00:00 2001 From: anat Date: Mon, 11 Feb 2013 17:51:18 +0100 Subject: [PATCH] [+] WS : Add product bundle retrieval from Web services --- classes/Product.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/classes/Product.php b/classes/Product.php index eead74dc8..787e2d315 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -362,6 +362,10 @@ class ProductCore extends ObjectModel 'getter' => false, 'setter' => false ), + 'type' => array( + 'getter' => 'getWsType', + 'setter' => false, + ), ), 'associations' => array( 'categories' => array( @@ -414,7 +418,14 @@ class ProductCore extends ObjectModel 'required' => true, 'xlink_resource' => 'product'), ) - ), + ), + 'product_bundle' => array( + 'resource' => 'products', + 'fields' => array( + 'id' => array('required' => true), + 'quantity' => array(), + ), + ), ), ); @@ -5190,5 +5201,20 @@ class ProductCore extends ObjectModel return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query); } + + public function getWsType() + { + $type_information = array( + Product::PTYPE_SIMPLE => 'simple', + Product::PTYPE_PACK => 'pack', + Product::PTYPE_VIRTUAL => 'virtual', + ); + return $type_information[$this->getType()]; + } + + public function getWsProductBundle() + { + return Db::getInstance()->executeS('SELECT id_product_item as id, quantity FROM '._DB_PREFIX_.'pack where id_product_pack = '.(int)$this->id); + } }