ademus Posted October 7, 2012 Share Posted October 7, 2012 dans le cadre de développement d'un moduie, je cherche à obtenir la liste complète des catégories et des produits pour l'afficher dans l'admin, dans la page de configuration de mon module. J'ai déjà quleques pistes pour ce faire : d'aprés http://www.prestasho...__1#entry941601 : [/font] include_once(PS_ADMIN_DIR.'/../classes/Product.php'); [font=arial, helvetica, sans-serif]$product_list = Product::getProducts ($cookie-> id_lang, 0,0, 'id_product', 'ASC', 60, true); ou include_once(PS_ADMIN_DIR.'/../classes/CategoryCore.php'); $c=new CategoryCore(); $c->recurseLiteCategTree (); ou utiliser les fonctions d' AdminProducts ou d'une autre classe Admin..., par exemple include(PS_ADMIN_DIR.'/tabs/AdminProducts.php'); $p = new AdminProducts (); $product_list=$p->getList([font=arial, helvetica, sans-serif]$cookie-> id_lang[/font]); ou faire mon propre script ou une solution déjà existante que je ne connaitrais pas Savez vous quelle est la meilleure méthode, considérant également la possibilité de mise à jour de versions ultérieures, pour obtenir la liste des catégories et produit ? Link to comment Share on other sites More sharing options...
ademus Posted October 10, 2012 Author Share Posted October 10, 2012 (edited) private function _displayProductsList() { global $cookie; $req = ' SELECT p.`id_product`, p.`reference`, pl.`name`, IFNULL(( SELECT SUM(pa.`quantity`) FROM `'._DB_PREFIX_.'product_attribute` pa WHERE pa.`id_product` = p.`id_product`), p.`quantity`) quantity FROM `'._DB_PREFIX_.'product` p INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$cookie->id_lang.') '.((int)$cookie->id_category ? 'LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)' : '').' WHERE p.active = 1 '.((int)$cookie->id_category ? ' AND cp.`id_category` = '.(int)$cookie->id_category.' GROUP BY p.`id_product`' : '').' ORDER BY pl.`name`'; return ( Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($req)); } Edited October 10, 2012 by ademus (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now