October 25, 2020


Thinking Magento

DPD API Login Using Zend Framework

Now I'm posting this because I don't want someone else to go through the same hardship as I did when it came getting the geosession from the DPD api. It may look easy enough, but if you've not had a whole lot of experience with using Zend_Http_Client (POST) it may be a bit of a nightmare taking that initial first step. Once you have the geosession, you can start using more POST and GET calls to get the information that you require.

$method = '/user/?action=login';
$url = $base.$method;
$client = new Zend_Http_Client($url);
$client->setHeaders('Host', 'api.dpd.co.uk');
$client->setHeaders(Zend_Http_Client::CONTENT_TYPE, 'application/json');
$client->setHeaders('Accept', 'application/json');
$client->setHeaders('Authorization', 'Basic '. base64_encode('username:password'));
$client->setHeaders('GEOClient', 'account name/account number');
$client->setHeaders('Content-Length', '0');
$response = $client->request();
$body = Zend_Json::decode($response->getBody());
$geoSession = $body['data']['geoSession'];


Error in the Ess M2ePro Extension!

Are you receiving the following error in your M2ePro Multichannel extension?

Call to a member function getData() on a non-object in app/code/community/Ess/M2ePro/Model/Mysql4/Ebay/Order.php on line 32

Now this error is actually fixed in the most recent version of ebay, but if you don't want to go through the process of upgrading, you can update this file.

Open up the file and you'll find

$itemIdSql = $readConnection->quoteInto('?', $orderItem->getData('item_id'));

Update it with the following

$itemIdSql = $readConnection->quoteInto('?', $orderItem['item_id']);
$transactionIdSql = $readConnection->quoteInto('?', $orderItem['transaction_id']);
$whereSql[] = "(item_id = {$itemIdSql} AND transaction_id = {$transactionIdSql})";

M2Epro Multi Channel Extension - Ebay Channel Url

You maybe using the M2Epro Multi Channel extension and realise that when you are viewing an order, there is no direct link to the order details on ebay. There is a link provided for Amazon orders.

To fix this issue so you can go straight from your Magento order to your ebay order requires the following change.

Open up Ess_M2ePro_Block_Adminhtml_Magento_Payment_Info

Add the following function

public function getChannelSalesRecord() {
    $order = Mage::getModel('M2ePro/ebay_order')->getCollection()
    ->addFieldToFilter('ebay_order_id', $this->getAdditionalData('channel_order_id'))
    return $order->getSellingManagerId();

Find the following function getChannelOrderUrl()

Change it so that Buy and Play stop so the URL is blank.

case Ess_M2ePro_Helper_Component_Ebay::NICK:
if ($this->getOrder())
$itemId = substr( $this->getChannelOrderId(), 0, strrpos( $this->getChannelOrderId(), '-' ) );
$transId = substr( $this->getChannelOrderId(), strrpos( $this->getChannelOrderId(), '-' )+1 );

$url = "http://k2b-bulk.ebay.co.uk/ws/eBayISAPI.dll?EditSalesRecord&;transid=".$transId."&urlstack=".$this->getChannelSalesRecord()."|Period_Last122Days|currentpage_SCSold|&itemid=".$itemId;

Then add the following code so that the URL for ebay is no longer blank

Save. Job complete.

You can either save this in the corresponding directory in local, or overwrite it in community, however any updates until this is fixed will be overwritten with each upgrade.

M2Epro Multi Channel Extension - How To Add Information To Sales_Order_Grid

If you're running M2EPro's Multi Channel Extension for ebay, play, amazon extension and you would like to add some of that information to your Sales_Order_Grid to save time navigating through the M2EPro menus and grids, the following information may prove to be useful for you.

In this instance we are going to add the ebay username to the Sale_Order_Grid so that we can perform lookups by ebay username

Copy from your core files Mage_Adminhtml_Block_Sales_Order_Grid into local 

Find function _prepareCollection()

Under $collection = Mage::getResourceModel($this->_getCollectionClass());

Addd the following code


What we are doing here is joinging 3 tables in the databse together. 

The first table we join is m2epro_order and match it up to the order_id of our magento orders. From m2epro_order the data we want to get is the id column.

Then we join m2epro_order_item but comparing the m2epro_order.id with m2epro_order_item.order_id. From m2epro_order_item the data we want to get is the order_id column.

Using the above 2 joins you now have access to the m2epro orders, which can perform look ups in ebay, amazon, play.

For this example we only require ebay usernames, but you could perform a CONCAT on amazon and ebay usernames together.

The final join is looking in m2epro_ebay_order joining m2epro_ebay_order.order_id to m2epro_order_item.order_id. This gives us the data we require to place the usernames on the grid.

Now adding your column to the grid, go down to function _prepareColumns()

$this->addColumn('buyer_user_id', array(
'header' => Mage::helper('sales')->__('User Id'),
'index' => 'buyer_user_id',

Save. Job complete

Changing Base URL and path of an installation (Moving to Production Server)

When you change the base URL of a Magento installation. You may think that this is a simple thing and forget to do some of the basics.

If you have changed the URL but now receive a weird error that your JS and CSS files are using the absolute path to those files, it will be because you have left on Merge CSS and Merge JS.

So.. What to do to get this right the first time

- In the admin turn off merge CSS and JS in the configuration
- Remove media/css and media/js directories (if exists)
- Check for fooman_speedster.xml in modules/etc and rename to fooman_speedster.disable
- In the admin check your Base URLs on default, website and store level. If you update the base URL, but it's set in the website or store level, it is not going to update.
- If you are locked out of your admin, update Core_Config_Data in the database for base urls (check website and store level)
- Delete var/cache
- Delete var/full_page_cache (Normally for Enterprise)