Wednesday, 19 February 2014

USPS API update january 2014

Usps have updated their API on January 2014. You can find the details of it here

And for those who have registered for the USPS developer or production account you would have been received mail from Usps about the API update.

According to the new update the shipping method "Standard Post" has been eliminated for Zones      1 to 4

Usps separates zipcodes with their zones. You can find your zone from here. FIND USPS ZONES
Go to "Get Zone for ZIP Code Pair" tab and enter your Origin and Destination zip code.

If your zone is numbered from 1 to 4, the "Standard Post" shipping method will not be applicable for you zipcode. Exception is given when you ship hazardous materials, live animals or other ground only items.

You can find more info about the API changes. 2014 January Release Notes (RTF)

Thursday, 6 February 2014

Magento change product image on view page to associated product image

Magento's configurable product does not load its associated product image when we change the attribute value. To change the image of the product respective to the selected attribute value i have used this code. Magento website also offers a wiki to achieve this, but its pretty old and its written for magento version 1.5 and below. Link to wiki

I have tested this code in recent magento version which is 1.8 and the most famous 1.7.

Here is the code.

STEP 1:

Open template/catalog/product/view.phtml

and find the line var productAddToCartForm = new VarienForm('product_addtocart_form'); on the bottom of the page.

Add these code on top of that line.

var mainProductImgSrc = document.getElementById("image").src;
var assocIMG =

<?php
if ($_product->getTypeId() == "configurable") {
echo "{";
$associated_products = $_product->loadByAttribute('sku', $_product->getSku())->getTypeInstance()->getUsedProducts();
foreach ($associated_products as $assoc)
$dados[] = $assoc->getId().":'".($assoc->image == "no_selection" || $assoc->image == "" ? $this->helper('catalog/image')->init($_product, 'image', $_product->image)->resize(365,400) : $this->helper('catalog/image')->init($assoc, 'image', $assoc->image)->resize(365,400))."'";
} else {
$dados[] = "";
}
echo implode(',', $dados );
if ($_product->getTypeId() == "configurable") {
echo "}";
}

?>


STEP 2:

open js/varien/product.js and find the line

}.bind(this));
for (var i = 0; i < this.tierPrices.length; i++) {


and add the below given code above  this-> " }.bind(this)); " line.

//to change product image based on option select for configurable product
settings = $$('.super-attribute-select');
imgSrc = mainProductImgSrc;
settings.each(function(element)
 {
   attributeId = element.attributeId;
   if(element.options[element.selectedIndex].config)
   imgSrc = assocIMG[element.options[element.selectedIndex].config.products];
   $('image').src = imgSrc;
 });

//ends

Your are done now. Do remember to select the base image for the associated product. If there is no image set for the associated product and when you change the option the configurable product image will be used instead.

Saturday, 1 February 2014

Magento import products with custom product type via csv

I was assigned a job to import products with custom product types through CSV

Magento's default product types are
  1. simple
  2. configurable
  3. virtual
  4. grouped
But when you import products with new product type other than the above mentioned. you will get this error

Product Type is invalid or not supported in rows... 

To overcome this error and import products with your custom product type you must follow these two steps.

1. Now am going to assume you have created an extension. On the config.xml file of your extension place this code under <global> tag.

<importexport>
    <import_product_types>
         <YOUR_MODULE>yourModule/import_entity_product_type_
YOUR_MODULE</YOUR_MODULE>
    </import_product_types>

</importexport>

Replace YOUR_MODULE with you module name.

2. Create a new model class to do the import. For this create this folder structure inside your model structure
Import\Entity\Product\Type\NEW-PRODUCT-TYPE

In my case i have a new product type "subscription_simple". so my folder structure will be
Import\Entity\Product\Type\Subscription\

Inside the folder i have a model class Simple.php file extending the magneto import class.\

place this code inside Simple.php file.

class NAMESPACE_MODULE_Model_Import_Entity_Product_Type_Subscription_Simple
    extends Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract
{

}

Now you can do the import with your custom product type.

you can check out one of the inbuilt classes for an example Mage_ImportExport_Model_Import_Entity_Product_Type_Simple

INFO: http://stackoverflow.com/questions/8909405/product-type-is-invalid-or-not-supported-in-rows-for-custom-product-type

Monday, 2 December 2013

[SOLVED] Magento - fedex not showing all the shipping methods


I was wondering why all the Shipping methods in FedEx which i have selected is not shown on the frontend. Well here is the answer.

FedEx returns the list of shipping methods as a response for our API call. The response is based on the total products weight (sum of all the products weight in cart).

So if the total weight is upto 70lbs Ground Shipping will be shown. If the weight is more than 70lbs you can use Home delivery. And if the weight is above 150lbs you can use freight methods.

Friday, 8 November 2013

Magento- Fedex shipping methods service codes.

There is no proper documentation available for FedEx web services API. I wanted to know the different service codes for shipping. Took a long search, but its is not available even in Fedex website which has examples only with priority shipping methods. So i went on a deep search and found this.

These are the list of FedEx web services API service code values for different shipping methods.

'INTERNATIONAL_PRIORITY'
'EUROPE_FIRST_INTERNATIONAL_PRIORITY'
'INTERNATIONAL_ECONOMY'
'STANDARD_OVERNIGHT'
'FIRST_OVERNIGHT'
'PRIORITY_OVERNIGHT'
'FEDEX_2_DAY'
'FEDEX_GROUND'
        
'GROUND_HOME_DELIVERY'
'INTERNATIONAL_GROUND'
'FEDEX_EXPRESS_SAVER'
'FEDEX_FREIGHT'
    
'FEDEX_NATIONAL_FREIGHT'
'FEDEX_1_DAY_FREIGHT'
'FEDEX_2_DAY_FREIGHT'
'FEDEX_3_DAY_FREIGHT'
'INTERNATIONAL_ECONOMY_FREIGHT'
'INTERNATIONAL_PRIORITY_FREIGHT'
 'SMART_POST'

Tuesday, 13 August 2013

Allow specific tags in WYSIWYG editor.

By default magento WYSIWYG editor will strip certain tags from the editor. To allow your tags in WYSIWYG editor you must edit the file under the path 

js/adminhtml/wysiwyg/tiny_mice/setup.js

1. Find var settings = { line and 
2. Add extended_valid_elements : 'nav[style|id|class]'.

In my case i have allowed <nav> tag, and am allowing the attributes style, id etc. Now the nav tag wont be stripped when you add it in admin WYSIWYG editor.

Magento Remove secure url from database.

Removing http(s) by editing databse.

If you cant access your magento admin panel and you need to remove your https, go to 
core_config table 
change the value of web/secure/use_in_frontend to '0' and web/secure/use_in_adminhtml to '0' .

If it is set to '1' your site is https enabled.