Saturday, September 24, 2011

Case Study: Connect Magento with ChannelAdvisor


This blog is again on different topic. It will not have single line of code. It's a case study on Synchronizing magento with leading eCommerce platforms.

Magento is very popular eCommerce platform widely used across the globe. eBay is acquiring magento and magento framework will be core part of eBay soon. eBay, Magento and Paypal are going to launch new eCommerce platform called xCommerce.

Sometimes it would be difficult to manage everything for those who sell their stuff online and using Magento and other sites like eBay and Amaozn. Because you have magento orders in magento admin. You can view eBay orders in eBay seller account and same way for Amazon orders. So seller have to process all the orders at different place. Same way it would be difficult to manage inventory.

To resolve this problems, magento should be synchronized with other platforms so that all the process like inventory management and order processing can be done at one place. Since last few months, I am working Magento synchronization with those platforms and I would like to share that experience here as a case study.

So this blog is about ChannelAdvisor

ChannelAdvisor provides you multiple channel for eBay and Amazon. ChannelAdvisor provides set of API to access ChhanelAdvisor account from outside. Those API can be used  synchronize it with Magento.

Inventory API

Inventory API is used to manage inventory. It gives various functions like

-Add item
-Delete item
-Update item
-Set quantity
-Set price and much more.

And it provides ability to send set of attributes for products so that all the magento attributes can be sent to CA. So basically on magento we need to set a cron job which runs every specified time interval and send updates in inventory to CA.

Order API

It gives an order api using which we can retrieve order details and using those details we can insert those orders in magento via code and process them in admin. You can retrieve orders based on specific date range. Also various filters can be applied like get all the pending orders, get all unshipped orders etc. We can control detail level of information. If you want all the information about order or only selected information, this can be controlled in API. Same way one can control number of orders returned by API. If you specify 100 orders, it will return information about 100 orders in one API call. It also gives you full details about customer, so that can be used in Magento to create customer and assign that order to him. Orders can be synchronized by setting a cron job in magento which runs on specified time interval and fetch those orders and create them in Magento.

Also after processing orders tracking information can be sent back to ChannelAdvisor using order API.

This makes complete integration of CA with Magento.

I hope this post helps you and if you are looking for such solution let me know.


Tuesday, September 6, 2011

Sencha touch charts remove decimal values on axes


If you have used sencha touch charts, you might have faced this issue. If you set minimum and maximum to chart axes, you might have decimal values in numeric axes. See the image below.

This occurs if you specify maximum and minimum on axes. See the code below.

minimum: 0,
maximum: 100,
majorTickSteps :5,
minorTickSteps :5

Here minimum defines minimum allowed value and maximum defines maximum allowed value on axes. Axes will not have value more than maximum. majorTickSteps defines number of steps on axes for example if you specify minimum to 0 and maximum to 100, 0 to 100 are divided in equal five steps according to axes data.

So if you have data in store which can not be distributed equally on axes. It will display decimal values with 10 decimal points. This is annoying when you are crating an application like dashboard and you are displaying more than one charts at a time in panel.

To overcome this problem, override Ext.chart.axis.Axis class method drawAxis as follow.

Ext.override(Ext.chart.axis.Axis, {
    drawAxis: function (init) {

Search code of this function in touch-charts-debug.js and paste the same code here and do the following modifications.

Search for the following line in code

me.labels.push(+(me.labels[me.labels.length - 1] + step).toFixed(10));

Change parameter in toFixed function to 0

me.labels.push(+(me.labels[me.labels.length - 1] + step).toFixed(0));

That's it and you will have integer values in charts.

Sunday, September 4, 2011

Sencha Touch Working with Models, Proxies, Stores

Data package is the important core part of sencha touch 1.x package. It enables application to persist data through application using models and proxies.

Model defines your business entity and proxy allows you to create CRUD (create, read, update, delete) functions for the models. Model is assigned to store. Here in this blog I am going to explain how to use models and proxy with store.

First define a proxy."myProxy",
    Ext.extend(, {
        create: function (operation, callback, scope) {
             //Here goes your create logic
        read: function (operation, callback, scope) {
             //Here goes your read logic
        update: function (operation, callback, scope) {
             //Here goes your update logic
        destroy: function (operation, callback, scope) {
             //Here goes your delete logic

This will create a new proxy with a name my proxy. Now create a model and assign proxy to it.

Ext.regModel('myModel', {
    fields: [
        {name : 'field1' , type : 'int'},
        {name : 'field2' , type : 'datetime'},
        {name : 'field3' , type : 'string'}    ],
    proxy: {
        type: "myProxy"

Now assign model to a store.

var myStore= new{
    model: 'myModel'

Now to call the read function of proxy you can call store load method.


To call create function of proxy you can add new item in store and call sync method.

var newModel = Ext.ModelMgr.create({ 'field1': value1,
            'field2': value2,
            'field3': value3
        }, 'myModel');



To call update function of proxy you can update item in store as follow.

var updateModel = Ext.ModelMgr.create({ 'field1': value1,
            'field2': value2,
            'field3': value3
        }, 'myModel');


To call destroy method you have to explicitly call proxy destroy function since destroy method is not yet implemented for the store as follow.

var deleteModel= Ext.ModelMgr.create({ 'field1': value1,
            'field2': value2,
            'field3': value3
        }, 'myModel');

deleteModel.getProxy().destroy(new{ action: 'destroy',}));