Jump to content

Plusieurs Fabricants pour un produit ?


LeGhe

Recommended Posts

  • 7 months later...
  • 3 months later...

Un début de solution, qui pourrait être propre :

J'ai inséré une nouvelle table qui s'appelle ps_productXmanufacturer selon la structure suivante :

id_product id_manufacturer
3107 1159
3108 2345
3108 2346
....

Dans classes/manufacturer.php, on trouve, vers la ligne 249 des requêtes SQL que je n'arrive pas à modifier :

/* Return only the number of products */
       if ($getTotal)
       {
           $sql = '
               SELECT p.`id_product`
               FROM `'._DB_PREFIX_.'product` p
               WHERE p.id_manufacturer = '.intval($id_manufacturer)
               .($active ? ' AND p.`active` = 1' : '').'
               AND p.`id_product` IN (
                   SELECT cp.`id_product`
                   FROM `'._DB_PREFIX_.'category_group` cg
                   LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                   WHERE cg.`id_group` '.(!$cookie->id_customer ?  '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').'
               )';
           $result = Db::getInstance()->ExecuteS($sql);
           return intval(sizeof($result));
       }
       $sql = '
       SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name, t.`rate`
       FROM `'._DB_PREFIX_.'product` p
       LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($id_lang).')
       LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
       LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.intval($id_lang).')
       LEFT JOIN `'._DB_PREFIX_.'tax` t ON t.`id_tax` = p.`id_tax`
       LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.intval($id_lang).')
       LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
       WHERE p.`id_manufacturer` = '.intval($id_manufacturer).($active ? ' AND p.`active` = 1' : '').'
       AND p.`id_product` IN (
                   SELECT cp.`id_product`
                   FROM `'._DB_PREFIX_.'category_group` cg
                   LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                   WHERE cg.`id_group` '.(!$cookie->id_customer ?  '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').'
               )
       ORDER BY '.(($orderBy == 'id_product') ? 'p.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).' 
       LIMIT '.((intval($p) - 1) * intval($n)).','.intval($n);
       $result = Db::getInstance()->ExecuteS($sql);
       if (!$result)
           return false;
       if ($orderBy == 'price')
           Tools::orderbyPrice($result, $orderWay);
       return Product::getProductsProperties($id_lang, $result);
   }

   public function getProductsLite($id_lang)
   {
       return Db::getInstance()->ExecuteS('
       SELECT p.`id_product`,  pl.`name`
       FROM `'._DB_PREFIX_.'product` p
       LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($id_lang).')
       WHERE p.`id_manufacturer` = '.intval($this->id));
   }



Plutôt que d'interroger la base product, comment peut-on le faire interroger la base productXmanufacturer ?
On aurait en ce cas une solution pas trop moche pour avoir plusieurs manufacturers, ou plusieurs suppliers pour un même produit, non ?
Ou je m'égare ?

Link to comment
Share on other sites

  • 6 months later...

Bonjour,

j'ai eu le même cas, et j'ai trouvé une solution "satisfaisante". J'ai créé une catégorie que j'ai désactivée pour la rendre invisible et j'ai utilisé l'astuce d'Amaury pour que produit reste actif. (http://www.prestashop.com/forums/viewthread/65700/integration/rendre_invisible_le_produits_tout_en_gardant_sa_fiche_accessible/ ).

Ainsi, j'ai dupliqué l'article en choisissant un autre fabricant, et j'ai fait un robot.txt pour ne pas que cette page dupliquée soit référencée.

C'est mieux que rien non ?

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...