Jump to content

Show product's EAN13 depending on combination


Wigbert

Recommended Posts

Hi,

 

in my front office, I want to display the EAN13 number. To do this, it worked fine just adding the line:

{if !empty($product->ean13)}<p>{l s='EAN:'} {$product->ean13}</p>{/if}

into the file "products.tpl".

 

Now I have introduced colors as attributes and try to reduce the number of products in the shop. For my product with let's say 6 colors, I do have 6 different EAN numbers. However, the change above will always point to the same product EAN (the one inserted in BO in the product information tab).

 

Is there any way to dynamically show the EAN entered in the combinations tab of BO? I have tried to use the $combination variable, put this doesn't provide the ean13 member.

 

Thanks for your help

 

Link to comment
Share on other sites

Hi doekia,

 

thank your for your reply. Could you give me some more details about it? Also I'm an IT specialist, I'm pretty new to Prestashop and have yet no overview about which file is doing what. The product.js contains large pieces of script code, but where do they end?

 

Wouldn't it be also a good idea to change product.tpl as I already did to show the EAN? The only think is that the $combination variable (array) misses the ean13 field (there are pretty much all other combination data available there). My idea was adding the ean13 field to the $combination(s) variable, so that the product.tpl can show it.

 

Best regards

 

Link to comment
Share on other sites

Absolutlty, if you need EAN per combinations you need off cause to collect ean and populate the javascript array to be able to achieve what you want.

Most code is in js/product.js inside your theme
You basically need to either change the addCombination() and the updateDisplay()
Or make some sort of

<script>
  var fullCombs = {$combinations|@json_encode}
</script>

and adapt the updateDisplay() or implement some external change handler

 

Choose whatever fits best to you

 

PS: <pre>{$combinations|@print_r:1}</pre> can helps figuring out the structure of the combinations array

Link to comment
Share on other sites

OK, I see your point. I'm using almost the default theme, where the addCombination() method in js/prodcut.js is called only from product.tpl with all the variables but not the EAN. I believe it makes sense to query the DB only once an retrieve all the fields. But I couldn't figure out where the actual SQL query to ps_product_attribute is executed. Could you give me an hint on this?

Link to comment
Share on other sites

  • 1 year later...

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