Skip to main content

You can face a needing of wishlists import after importing customers data to Magento. The way I did this is the simplest one but it requires manual “copy/paste” actions.

Step1. Data preparation. It is the most difficult point of importing process. It can happen that data were stored without validations and there are lots of duplicated or incorrect e-mails. Remove duplicated lines in your file (ask Google if you don’t know how to do it in the editor you use).

There is also a need to create array from the data, the array will be used in insertAction() method.

The first table we are going to fill is the wishlist. It has the following structure:

  • wishlist_id – unique value, it shouldn’t be duplicated
  • customer_id – users IDs that can be found at Customers -> Manage Customers -> ID;
  • shared – Sharing flag (0 or 1)
  • sharing_code – a unique encrypted code;
  • updated_at – the last update.

Step 2. Fill the table with the help of the module InsertCustomerWishlist (it will be deleted after everything is done). Create directory with this path app / code / local / Magenmagic / InsertCustomerWishlist.

Step 3. Insert Customer Wishlist module code

InsertCustomerWishlist / etc / config.xml

<?xml version="1.0"?>
app / etc / modules / Magenmagic_InsertCustomerWishlist.xml
<?xml version="1.0"?>
InsertCustomerWishlist / controllers / IndexController.php
class Magenmagic_InsertCustomerWishlist_IndexController extends Mage_Core_Controller_Front_Action
    protected $_existingIdCustomer = 'no';
    public function indexAction()
        $firstCustomerId = (int) $this->getRequest()->getParam('firstCustomerId');
        $lastCustomerId = (int) $this->getRequest()->getParam('lastCustomerId');
        if ($firstCustomerId == 0 || $lastCustomerId == 0) {
            echo "Check the entered data";
        } else {
            $wishLists = Mage::getModel('wishlist/wishlist')->getCollection();
            $customers = Mage::getModel('customer/customer')->load($lastCustomerId)->hasEntityId() ;
            foreach ($wishLists as $wishList) {
                if ($wishList->getCustomerId() == $firstCustomerId) {
                    $this->_existingIdCustomer = 'yes';
                    echo 'Such user is in the table wishlist </br>';
            if (!($customers)) {
                $this->_existingIdCustomer = 'yes';
                echo 'This user does not yet exist';
            if ($firstCustomerId > $lastCustomerId) {
                $this->_existingIdCustomer = 'yes';
                echo 'EndCustomerId can not be greater than lastCustomerId';
            if ($this->_existingIdCustomer == 'no') {
                for ($firstCustomerId; $firstCustomerId<=$lastCustomerId; $firstCustomerId++) {
                    $wishList = Mage::getModel('wishlist/wishlist');

Step 4. Run the module this way: put into the address bar http://Domain/index.php/mminsertcustomerwishlist?firstCustomerId=50&lastCustomerId=1350

  • firstCustomerId – the ID of the first imported customer;
  • lastCustomerId – the ID of the last imported customer (can be found in the admin area).

Then, fill the table wishlist_item:

  • wishlist_item_id – unique ID;
  • wishlist_id – from the table wishlist;
  • product_id – ID of the item (product) in the wishlist;
  • store_id – ID of the online shop;
  • added_at – the date of adding;
  • description – the comment;
  • qty – a number of items.

Step 5. Add the following method to InsertCustomerWishlist / controllers / IndexController.php:

public function insertAction()

    {           $product_id = ["подготовленный массив product_id"];
         $date = [...];
            $description = [...];
            $id_wishlist = […];
        $first_id = 0;
        $last_id = 3352;
            for ($first_id; $first_id<=$last_id; $first_id++) {
            $wishList = Mage::getModel('wishlist/item');
           if ($product_id[$first_id] == 'no') {
           if ($description[$first_id] != 'NULL') {
        echo 'Insert data table wishlist_item';

Step 6. Check the result. When the work is done, go to admin area and compare the data of customers wishlists at Magento with the initial data. If they are equal, you were successful to import data to your Magento store. It is important to add/check the data in array attentively to avoid mistakes.

Vladimir Repalo

Vladimir Repalo

Magento Developer at Mobecls, 8+ years of experience. Feel free to ask me anything about this post in the comments below.