Magento Shareasale Affiliate feed Import

Sometime back when I was blogging on my Dreamzaffiliate.com blog, I had written an article how to load shareasale affiliate data feed into Magento shopping setup.
I was unable to share the code at that time . I want to share the code as well as scripts I developed as part of my experiments with Magento store.

Magento works on a Modular architecture with a clearly defined MVC model.Magento defines parsers,importers,models as seperate classes and the view loaders simply load once everything is loaded into the Mage core.

Shareasale data actually consists of the below columns in the datafeed files

‘ProductID’,
‘Name’,
‘MerchantID’,
‘Merchant’,
‘Link’,
‘Thumbnail’,
‘BigImage’,
‘Price’,
‘RetailPrice’,
‘Category’,
‘SubCategory’,
‘Description’,
‘Custom1’,
‘Custom2’,
‘Custom3’,
‘Custom4’,
‘Custom5’,
‘LastUpdated’,
‘status’,
‘manufacturer’,
‘partnumber’,
‘merchantCategory’,
‘merchantSubcategory’,
‘shortDescription’,
‘ISBN’,
‘UPC ‘

We can create a Parser,saveLoader, and a DataImporter so that the columns are parsed into an array of records in Magento saved as a Record and Imported into the database.

But there exists some hidden difficulities whenloading data from SAS to Magento, ie Showing the imported data in the Shop.Well we need to define the level definition and layer definitions to load the data into the shop.

Actually the shop can be show in List,Grid,Gallery formats.To accompany all this we need to have the proper image loaded when we are in gallery or list mode so that the catalogue shows the proper image rather than blank image.

We open the file Layer.php where we actually add a line to load the image as shown.

In the function ” public function prepareProductCollection($collection) “
we need to add one line ” ->addAttributeToSelect(‘image_small’) ” just below addTaxpercents as below

/**
     * Initialize product collection
     *
     * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
     * @return Mage_Catalog_Model_Layer
     */
    public function prepareProductCollection($collection)
    {
        $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')
->getProductAttributes())
            ->addMinimalPrice()
            ->addFinalPrice()
            ->addTaxPercents()
            ->addAttributeToSelect('image_small')         //->addStoreFilter()
            ;

        Mage::getSingleton('catalog/product_status')
->addVisibleFilterToCollection($collection);
        Mage::getSingleton('catalog/product_visibility')
->addVisibleInCatalogFilterToCollection($collection);
        $collection->addUrlRewrite($this->getCurrentCategory()
->getId());

        return $this;
    }

We need to modify the files view.phtml,addtocart.phtml,media.phtml,list.phtml files to show the images,deeplink_url,thumbnail,small_image,large_image everything in the shop.

The item image can be accessed using the product configuration

getData('image_small'); ?>

getData can be used to access anydata that is configured but does not have a mapping with the product catalogue.

[[[dpm_formular]]]

  • bellir

    Hi Shreedhar,

    Does your code work also for Prestashop?
    tks
    bellir

    • Bellir, I have never worked on Prestashop before.Hence This code will not work with that.
      Also note that every cms package has its own coding structure.Prestashop is completely different from Magento

  • bellir

    Hi again,i Shreedhar,

    I am trying to incorporate your instructions on my Magento installation, but I have a doubt on the last part…

    The first part went ok, and I updated the layer.php, but the second part, I am in doubt about:

    ‘view.phtml,addtocart.phtml,media.phtml,list.phtml files to show the images,deeplink_url,thumbnail,small_image,
    large_image everything in the shop.

    The item image can be accessed using the product configuration getData(‘image_small’); ?>

    getData can be used to access anydata that is configured but does not have a mapping with the product catalogue.

    [[[dpm_formular]]]


    Do you mean that I should open each one of the above files and add “getData(‘image_small’); ?>”?

    If so where should I include that this code?

    It would be nice if could give an example like the first part.
    thank you very much for your help.
    bellir