'cms_pack', 'primary' => 'id_pack', 'fields' => array( 'title' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), ), ); public function __construct($id = NULL, $id_lang = NULL, $id_shop = NULL) { parent::__construct($id, $id_lang, $id_shop); } public function deleteRelations() { return (bool) Db::getInstance()->delete('cms_pack_relation', 'id_pack = '. $this->id); } public function addRelation($id_relation) { return Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'cms_pack_relation` VALUES ( '.(int)$this->id.', '.(int)$id_relation.' ) '); } public function loadProducts($page_name = null) { $this->products = $this->getRelations(); } public function getRelations($page_name = null) { if(!Validate::isLoadedObject($this)) return array(); $array_tmp = array(); $sql = 'SELECT `id_product` FROM '._DB_PREFIX_.'cms_pack_relation WHERE id_pack = '.(int)$this->id.''; $infos = Db::getInstance()->executeS($sql); foreach($infos as $info) { $array_tmp[$info['id_product']] = $info['id_product']; } return $array_tmp; } public function getInfosWithValues() { $infos = $this->getRelations(); if(count($infos) == 0) return array(); $id_lang = Context::getContext()->language->id; $sql = ' SELECT p.id_product as id, pl.name as content FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product` AND pl.id_lang = '.$id_lang.' WHERE p.id_product IN ('.implode(',', $infos).')'; $res = Db::getInstance()->executeS($sql); return $res; } }