Ray UK Posted May 25 Share Posted May 25 (edited) I was in the process of updating products with their EAN numbers and noticed a big problem. If a product has multiple colour options and you enter the EAN for each of those combinations and go to the Google Snippets Testing tool, the EAN for the colour option is not show. It just shows the EAN for the main product entry instead. I have not altered any code for this to happen on this site so Id assume all Prestashop installs have this same issue. The same is happening for the SKU & MPN, so I assume that the snippets code needs changing via ajax the same as the datasheet does. Edited May 25 by Ray UK (see edit history) Link to comment Share on other sites More sharing options...
juanrojas Posted May 25 Share Posted May 25 Hello, if the product has combinations, then the product should not have an EAN, because each combination is recognized as a product. Link to comment Share on other sites More sharing options...
Ray UK Posted May 25 Author Share Posted May 25 But each product variant has a unique EAN or am I wrong there? Because when I scan product barcodes, each colour variant has a different EAN and are listed separately on the EAN database Link to comment Share on other sites More sharing options...
El Patron Posted May 28 Share Posted May 28 To address this, you need to modify your theme's JavaScript and template files to ensure that the EAN updates dynamically based on the selected combination. Here's a general approach: Update JavaScript: In your theme's product.js file, locate the updateDisplay function. Ensure that this function retrieves and updates the EAN (and other identifiers like SKU or MPN) based on the selected combination. You might need to extend the combination data to include the EAN.PrestaShopPrestaShop Modify Template: In your product.tpl (or equivalent) template file, add a placeholder where the EAN should be displayed. Use JavaScript to update this placeholder when a new combination is selected. here is example code, but you will need to customize based on your theme etc. In product.tpl: <p id="product-ean">EAN: <span id="ean-value">{$product.ean13}</span></p> In product.js: function updateDisplay() { // Existing code to update product details // New code to update EAN var selectedCombination = combinations[combinationId]; if (selectedCombination && selectedCombination.ean13) { document.getElementById('ean-value').textContent = selectedCombination.ean13; } } 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