This article is related to the Amazon products manager Magento extension


Implement Special Price if there is a price and list price attributes in the Amazon API response.

Many products available through Affiliate Amazon API has the ListPrice attribute which is usually higher than the actual Price. Which means the product is sold with a discount.

And you can use this feature to create Price and Special Price in Magento.

We would check the example product ASIN B00NBOYRNS.

This is the Sony Xperia Z3 smartphone.

1. So, we search the product by ASIN, set Default Condition to New value, Default price to Lowest available.

After the product is found, click Edit button for this product and get to the Additional Attributes tab just to make sure that the attribute {{var attr="ListPrice/Amount"}} is there.

It is there:

Check the product attribute in Magento

 

2. Now we need to alter the custom php function in this file

app/code/local/WP/Amazonimportproductsaddon/Model/Observers.php 

If you do not have that file, get to your original extension package and upload amazonimportproductsaddon.zip file content to the root of your magento folder.

Open the file Observers.php and find the function attributesMappingAfter()

Replace the function with the following code:

Check the code carefully, how did we get the ListPrice value from the API:

$listPrice = ($apiResponseItemData->ItemAttributes->ListPrice->Amount) / 100;

Remember the attribute value:

{{var attr="ListPrice/Amount"}}, it was converted to ListPrice->Amount. We need now to add $apiResponseItemData->ItemAttributes-> before the attribute 

and get

$apiResponseItemData->ItemAttributes->ListPrice->Amount

Since the value was 62999, and there was the attribute {{var attr="ListPrice/FormattedPrice"}} near by with value of 629.99, we might figure out, that we need to divide the listPrice value by 100 in order to get the right price.

In the same manner you can use any other API attribute.

3. Save the file, flush the cache and import the product (or sync it if it was already imported)

Now we have such product with a Special Price:

product example with a special price


How to change SKU using any attribute delivered by the Amazon API

Changing SKU is quite simple. Basic code would set Model from Amazon API to the product SKU:

This code should be applied to the attributesMappingAfter function in this file app/code/local/WP/Amazonimportproductsaddon/Model/Observers.php


How to alter description with Feature options

Amazon API sometimes retreive array data which can not be used in the attributes mapping, it is too complex to use arrays in a simple attributes mapping functionality. It is possible to use array data in the php function.

That is the array data we are talking about, you can find them in the Additional attributes tab

Features attributes

Many products over Amazon keep empty description with only those Features fields filled

Here is the code to place features to the description

In this code we define which attribute to change by placing the attribute code to this line

->updateAttributes(array($product->getId()), array('description' => $html), Mage_Core_Model_App::ADMIN_STORE_ID);

You can easily replace it to short_description or any other data attribute you want to use.


Amazon Products Manager Magento Extension allows you to easily import Amazon products into Magento.

Please write comments to this article with your questions and/or recommendations.

Back