alex-km Posted February 26, 2014 Share Posted February 26, 2014 Bonjour, je cherche à dupliquer la fonction accessoires afin de combiner différents produits pour un même article et de les disposer différemment sur la fiche produit. J'ai chercher dans la classe Product.php pour trouver ce morceau de code: /** * Webservice getter : get product accessories ids of current product for association * * @return array */ public function getWsAccessories() { $result = Db::getInstance()->executeS( 'SELECT p.`id_product` AS id FROM `'._DB_PREFIX_.'accessory` a LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = a.id_product_2) '.Shop::addSqlAssociation('product', 'p').' WHERE a.`id_product_1` = '.(int)$this->id ); return $result; } /** * Webservice setter : set product accessories ids of current product for association * * @param $accessories product ids */ public function setWsAccessories($accessories) { $this->deleteAccessories(); foreach ($accessories as $accessory) Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'accessory` (`id_product_1`, `id_product_2`) VALUES ('.(int)$this->id.', '.(int)$accessory['id'].')'); return true; } Pour la partie backoffice admin/themes/default/template/controllers/products/associations.tpl <tr> <td class="col-left"><label>{l s='Accessories:'}</label></td> <td style="padding-bottom:5px;"> <input type="hidden" name="inputAccessories" id="inputAccessories" value="{foreach from=$accessories item=accessory}{$accessory.id_product}-{/foreach}" /> <input type="hidden" name="nameAccessories" id="nameAccessories" value="{foreach from=$accessories item=accessory}{$accessory.name|escape:'htmlall':'UTF-8'}¤{/foreach}" /> <div id="ajax_choose_product"> <p style="clear:both;margin-top:0;"> <input type="text" value="" id="product_autocomplete_input" /> {l s='Begin typing the first letters of the product name, then select the product from the drop-down list.'} </p> <p class="preference_description">{l s='(Do not forget to save the product afterward)'}</p> <!--<img onclick="$(this).prev().search();" style="cursor: pointer;" src="../img/admin/add.gif" alt="{l s='Add an accessory'}" title="{l s='Add an accessory'}" />--> </div> <div id="divAccessories"> {* @todo : donot use 3 foreach, but assign var *} {foreach from=$accessories item=accessory} {$accessory.name|escape:'htmlall':'UTF-8'}{if !empty($accessory.reference)}{$accessory.reference}{/if} <span class="delAccessory" name="{$accessory.id_product}" style="cursor: pointer;"> <img src="../img/admin/delete.gif" class="middle" alt="" /> </span><br /> {/foreach} </div> </td> </tr> Je suppose que si je crée un fonction semblable dans la classe product cela devrait marcher, mais j' ai du mal à comprendre ce qu il se passe dans la base de donnée... Pouvez vous m' aider ? Link to comment Share on other sites More sharing options...
Mykhailo Posted August 10, 2014 Share Posted August 10, 2014 Hi! I'm working on the same problem. Have you already found a solution? 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