Generate EAN Barcodes for All Magento Products – Magento EAN Barcode Generator

created October 10, 2012, last updated June 23, 2014.

.
closeThis post was last updated 9 years 11 months 12 days ago, some of the information contained here may no longer be actual and any referenced software versions may have been updated!

Generate EAN Barcodes for All Magento Products

Following on from my post about mass exporting Magento data, I had the requirement to also mass generate EAN13 barcodes from scratch for all Magento products in a store.

The barcode graphic functionality came courtesy of Folke Ashberg and I simply added the functionality to my basic export php script.

The script creates the EAN code and checksum (currently programmed for EAN13) using the a 5 digit product number derived from the Magento product id and your registered manufacturer code. The barcode image is generated on the fly and cached locally.

My requirement was to generate the EAN code and not the barcode image so I am not 100% if the image is to the EAN standard, I think the font may need to be changed, however if you require EAN numbers and images, e.g. for Amazon etc. then this is a good place to start!

Magento EAN Generator

You can download a standalone version of my Magento EAN Generator from GitHub here. Install the code in a web accessible folder, or in your Magento installation folder. Open the application config file and configure the correct path to your Magento installation. Also configure your EAN prefix code.

Run the script by browsing to http://www.yoursite/eaninstallfolder/ean.php?export, this will generate a delimited txt file containing SKU and EAN13 code for all visible products in your store.

Or run the script from the command line using

php php.ean debug

< MAGENTO EAN -> D E B U G >
Exporting EAN data for 64 Magento product/s …
Data file created at /home/www/dev/magento/myexport/eanexporttest.csv
Export finished.

 

Configure a writeable folder for the data file in config.

The CSV file contains the EAN data

sku,ean
COOLSAUCE1,1234567001746
Honeypot-1,1234567001739
gaiterjones-1,1234567001715
HTC Touch Diamond,1234567001661
mycomputer,1234567001654
computer_fixed,1234567001647
computer,1234567001630
micronmouse5000,1234567001623
logidinovo,1234567001616
logitechcord,1234567001609
microsoftnatural,1234567001593

You can see an example of the scripts output here.

Auto Generated Magento Product EAN13 Barcode

 

You might want to validate the generated EAN codes, specifically to validate the 13th checksum code, do this here.

Comments

  1. Sean says:

    Hello,

    I used this to generate a CSV. How ever when I open it in excel it only shows
    sku ean
    IF-402303 1.23456E+11
    IF-402315 1.23456E+11
    IF-402300 1.23456E+11
    IF-402311 1.23456E+11

    Any ideas on how to get the barcodes to show up with product names.

  2. Steve Brown says:

    In order to use your scrip do I actually need to buy EAN codes from a legitimate source? Or can I just create/start with a random 13 digit number? I would like to use EAN codes on our Magento site in cooperation with Amazon integration plugin.

    On Magento Admin portal I keep getting an “Invalid EAN code” upon attempting to “Add to Marketplace” my product.

    http://www.amazon.com/gp/seller/asin-upc-isbn-info.html

    • PAJ says:

      You can generate dummy EAN numbers if you like with any prefix codes you want, for them to be valid your company needs to be registered and assigned a valid prefix code.

  3. willard says:

    Hi I installed your great script, but sadly it returns the following error. The paths are correct, I double ckecked.

    Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Product_Flat::getType() in /home/pannen/public_html/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php on line 445

    • andrei says:

      yes same error here: Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Product_Flat::getType() in C:\xampp2\htdocs\tibbis\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php on line 445

      I’m useing Magento 1.8.

      Any ideas?

      Thank you

  4. Paolo Gatti says:

    Hello, I have this error:

    Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Product_Flat::getType() in /home/pannen/public_html/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php on line 445

    I’m using Magento CE 1.9.0.1

    Can you help me please?

    Thank you, Paolo.

  5. Art van Delay says:

    Hi gaitorjones!
    Thank you for your code. It´s fantastic…Unfortunately I only get half of my product list.
    Any switches to export all products, despite activeted / deactivated, or any clue…

    thx

This site uses Akismet to reduce spam. Learn how your comment data is processed.