Unable to create product in Magento using REST API

Some days back, we came across an issue. Products not being created in Magento using REST API. First we thought its something related to the hosting server and checked if the oAuth is installed properly which was working fine. Then tested locally with a php oAuth admin function and was a success and we could create a product.

The issue was rather simple. Someone has changed the admin url of the site which caused all those issues.

Normally, the the authentication URL reference will be as below.

$adminAuthorizationUrl = '<domain>/admin/oauth_authorize';

On changing the same to the following one, the issue got resolved.

$adminAuthorizationUrl = '<domain>/backend/oauth_authorize';

Posted in Magento Developer Notes | Leave a comment

How we can stop spam user creation on drupal website

Spam user creation is the main concern of drupal developers. This post assumes that you are not allowing anonymous user creation on your website. This is one method. You can use other methods depending on the spam user on your site.

I would only recommend to change drupal usually using module path and validation method.

1) quick way to stop spam user registrations is to change the user path using the Rename Admin Paths module. Once you install this module. Your website links to the user paths will dynamically change to point to the new path. Usually Spambots trying to access drupal default url, and it will redirect to 404 page.

2) Change the drupal default password validation format to another format is can also be used to prevent spam users.

Posted in Drupal Developer Notes | Leave a comment

Fontis_Australia-3.0.0 shipping method calculation issue

In the latest Australian post module of the font is (Fontis_Australia-3.0.0) did not display the shipping method details, when the weight of the product is below “1kg” and the zip code star with “0” digit.

For solving this issue,
Correct the integer type value in the collectRates()
app\code\community\Fontis\Australia\Model\Shipping\Carrier\Australoianpost.php

$fromPostcode = (int)Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$toPostcode = (int)$request->getDestPostcode();
$sheight = (int)$helper->getAttribute($request, 'height');
$slength = (int)$helper->getAttribute($request, 'length');
$swidth = (int)$helper->getAttribute($request, 'width');

To

$fromPostcode = (string)Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$toPostcode = (string)$request->getDestPostcode();
$sheight = (string)$helper->getAttribute($request, 'height');
$slength = (string)$helper->getAttribute($request, 'length');
$swidth = (string)$helper->getAttribute($request, 'width');

Also change the “type” integer to string in the below section:
app\code\community\Fontis\Australia\lib\vendor\fontis\auspost-api-php\src\Auspost\Postage\service.json
In “ListDomesticParcelServices” and in “CalculateDomesticParcelPostage” change the “type” to “string” in from_postcode, to_postcode, weight
And in “CalculateInternationalParcelPostage” change the “type” to “string” in weight

Posted in Drupal Developer Notes | Leave a comment

REST API in Magento Community Edition

REST API is the one of the web service in the magento C.E. Using this web service, developer can perform the request and receive the response. The below section describe about, how we can set the Rest API in magento C.E.
Before going to configuration, first install the php extension oAuth in your server.

For working with REST Api, do the following step

Configuring Magento REST

1. Create oAuth consumer

Magento rest service work only with oAuth authentication. For creating oAuth consumer

  • 1. Go to System -> Web Services -> REST oAuth Consumer
  • 2. Then click on the Add New button
  • 3. Add new consumer name in the Name field of the New Consumer page. Also we can see a disabled Key and Secret field, and we can copy that value to notepad.
  • 4. We can leave the Callback URL and Rejected Callback URL
  • 5. Then click on the Save button

2. Create REST Role

For getting the rest service, need to get the permission for user type, so we need to create the rest role.
W can create the rest role from
System -> Webservices ->REST Role.
Magento default have two rest role, these are Customer and Guest
For creating new rest role

  • 1. Go to System -> Webservices ->REST Role.
  • 2. Click on the “Add Admin Role”
  • 3. Add Role name in the Role Info tab of Add New role page
  • 4. Then click on the “Role API resources” and select the resources.

  • 5. Then click on the Save button in the right top corner.

3. Configure Resource Attribute

For configuring resource attribute, go to System -> Webservices ->REST – Attribute.
In the REST Attributes list page, we can see list of the user type:

  • • Admin
  • • Customer
  • • Guest

Click on the Admin and select the Resources under the User Type Resources

4. Assign the Admin Rest Role to Admin user

For using the magento rest rule service, assign the admin rest role to existing admin user. For doing this;

  • 1. Go to System -> Permissions ->User
  • 2. Click on the admin user
  • 3. Then select the REST Role tab from the Edit user page
  • 4. Select the newly created REST Role radio button and click on the save user button.

After complete above process, you have successfully use the REST Resource. Then we can test the REST resource

Test with REST Client plug-in.

We can simply test the rest resource with firefox browser. If firefox have rest plug-in,

  • 1. Open the Rest Client plug-in
  • 2. Enter the http://yourdomain.com/api/rest/products in the URL field and click on the “SEND” button.

Then try with below solution,

  • 1. Go to the System -> Webservices -> REST Role and select the Guest
  • 2. From the Roles Resources, select the resource and save

Then

  • 1. Go to the System -> Webservices -> REST Attributes and select the Guest
  • 2. From the User Type Resources, select the resource and save

After complete this process check the above process again.
Note:: By default, only 10 are return during the response. We can limit the return response by
http://yourdomain.com/api/rest/products?limit=15.

Test with PHP program

Retrieve product with PHP program

<?php
$callbackUrl = "http:// yourdomain.com /oauth_customer.php";
$temporaryCredentialsRequestUrl = "http:// yourdomain.com /oauth/initiate?oauth_callback=" . urlencode($callbackUrl);
$adminAuthorizationUrl = 'http:// yourdomain.com /oauth/authorize';
$accessTokenRequestUrl = 'http:// yourdomain.com /oauth/token';
$apiUrl = 'http:// yourdomain.com /api/rest';
$consumerKey = 'yourconsumerkey';
$consumerSecret = 'yourconsumersecret';
 
session_start();
if (!isset($_GET['oauth_token']) && isset($_SESSION['state']) && $_SESSION['state'] == 1) {
$_SESSION['state'] = 0;
}
try {
$authType = ($_SESSION['state'] == 2) ? OAUTH_AUTH_TYPE_AUTHORIZATION : OAUTH_AUTH_TYPE_URI;
$oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $authType);
$oauthClient->enableDebug();
 
if (!isset($_GET['oauth_token']) && !$_SESSION['state']) {
$requestToken = $oauthClient->getRequestToken($temporaryCredentialsRequestUrl);
$_SESSION['secret'] = $requestToken['oauth_token_secret'];
$_SESSION['state'] = 1;
header('Location: ' . $adminAuthorizationUrl . '?oauth_token=' . $requestToken['oauth_token']);
exit;
} else if ($_SESSION['state'] == 1) {
$oauthClient->setToken($_GET['oauth_token'], $_SESSION['secret']);
$accessToken = $oauthClient->getAccessToken($accessTokenRequestUrl);
$_SESSION['state'] = 2;
$_SESSION['token'] = $accessToken['oauth_token'];
$_SESSION['secret'] = $accessToken['oauth_token_secret'];
header('Location: ' . $callbackUrl);
exit;
} else {
$oauthClient->setToken($_SESSION['token'], $_SESSION['secret']);
$resourceUrl = "$apiUrl/products";
$oauthClient->fetch($resourceUrl);
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);
}
} catch (OAuthException $e) {
print_r($e);
}

Save the above code. When we call that file then list all the products in the xml format.
If you get any error like below:

          Invalid auth/bad request (got a 403, expected HTTP/1.1 20X or a redirect)
          {"messages":{"error":[{"code":403,"message":"Access denied"}]}}

Then try with below solution and check once again
Open the file https.php in the lib\Zend\Controller\Request in the magento directory and find the function
public function getHeader($header)

Modify the getHeader($header) function in Zend_Controller_Request_Http class
Replace:
$temp = 'HTTP_' . strtoupper(str_replace('-', '_', $header));
With:
$temp = ($header == 'Authorization') ? $header : 'HTTP_' . strtoupper(str_replace('-', '_', $header));

After correctly configure magento REST API, that allow managing number of features like;
Managing customers, managing products, list the sale order, managing inventory etc.

Posted in Magento Developer Notes | Leave a comment

Upcoming Release of the Magento 2 C.E

After a success of the magento in the last 5-6 years, magento team planning to release of the new version of magento Ie, magento 2. Within these 5- 6 years of magento, different versions are released and the last released magento version is 1.9.0.1. Each version have its own features and fixes of bug.

Magento 2 is developed to attain the goal of the merchants need. It enable the merchants to set up the online selling, download and services etc. Also it has different changes when compare with the previous version. It upgraded the technologies, changed the directory structure, Architecture Changes, backend changes and also improved the platform look for supporting the mobile versions.

One of the main advantage to the customers is, can purchase the products easily through the mobile in everywhere as we done the purchase through the desktop/laptop.

This article gives a quick overview about the magento2, magento2 new features, core changes in the magento2 etc.

Upgraded Technologies:

With the help of the improved technology, it will attain the performance improvement, more security features.

System Requirements are:

  • 1. P.H.P 5.4 + with following extension
    a. PDO/MySQL
    b. MySQLi
    c. Mbstring
    d. Mcrypt
    e. Mhash
    f. Simplexml
    g. DOM (this is included by default in PHP 5.4)
    h. Curl
    i. gd2 or ImageMagick 6.3.7 (or newer) or both
    j.soap
  • 2. Mysql version 5.6
  • 3. Zend Framework 1.x
  • 4. JavaScript: jQuery
  • 5. HTML5 and CSS3 : Increased performance, improved the layout design, responsive web design

Code Quality
Magento2 focused on the improvement of the Code quality. For that, many of the testing frameworks are included. The testing frameworks integrated with the magento 2 are the following:

  •  Integration Testing(framework)
  •  Unit Testing
  •  Static Testing
  •  Performance Testing
  •  JavaScript Testing

These techniques helps the merchant to achieve a desired result and increase the run of their business.

Frontend and Backend Changes

FRONTEND

Changes from Magento1.x to magento2:

Directory structure changes

  •  Directory structure of the magento 2 is more than little but different to the magento1.x directory structure
  •  Newly created directives are pub. Moved the js, skin, error folders from root to this folder
  •  Another one is dev , containing tools for migration tools and test
  •  Directory structure of magento 2 is like below.

Directory structure comparison.

File Structure

  • 1. app/design//base become app/code///view
  • 2. app/locale/en_US/template/email/*.html become app/code///view/email/*.html
  • 3. errors become pub/errors,
  • 4. js become pub/js,
  • 5. media become pub/media,
  • 6. shell become dev/shell

-> In magento2, a new folder named “view” under the app/code/core/Mage/module_name. It is the replacement of the design package.

Architecture Changes

Module Activation

In older magento versions, we activated the modules by using the module.xml file in app/etc/module. But in the magento2, we use the config.xml for module activation

File Structure: app/code/company_name/module_name/etc/config.xml

<config>
<modules>
<Mage_Catalog>
<version>1.6.0.0.20</version>
<active>true</active>
<codePool>core</codePool>
</Mage_Catalog>
</modules>
……………..

-> Factory name removed

Meaning that, we can reference the classes just by using their name below.
Eg: instead of calling Mage::getModel(‘catalog/product’) need to call

Mage::getModel(‘mage_catalog_model_product’)
o Calling of helper class will be
Mage::helper(‘Mage_Catalog_Helper_Product_View’)
o Calling of block type
<block type="Mage_Catalog_Block_Product_Compare_Sidebar" before="cart_sidebar“ name="catalog.compare.sidebar" template="product/compare/sidebar.phtml"/>

Java script Library changes

It uses the JQuery library as the default Java script Library, so it rid the prototype and jQuery conflict.

Magento Switchability

In the current version of magento1.x all the main modules like, catalog, cms, customer, order reports are interrelated. When we disabled any one of the module form the config.xml, it always through an exception as the module you have disabled is depend to another module.

But in magento 2, magento have flexibility to switch and disable. And modules are not interrelated on configuration level.

BACKEND

Major Changes

  •  In magento 1.x, we called the URL of the admin section is default_url/admin
    But in magento2, URL will be default_url/backend
  •  Redesign of the backend section
  •  Then the next one is the several menu items have been merged and whole admin area has much nice look and feel
    • New visual of the admin section

      One of the biggest changes of the admin section is the new visual

       1. Login section and dashboard

       2. Introduction of the Visual Design Editor

      •  Another biggest change in the admin system is the new visual design editor. It represents the website pages and page type.
      •  It is available under System -> Design-> Editor.
      •  Then you must select the theme you wish to modify and click the launch button.

      •  This takes you to the editor view
      •  Where you can select the type of page layout you wish to edit in your selected theme.

      As the Magento theme developer will know, layout changes for the theme have previously been implemented by hand in magento layout.xml file.

      But in magento 2, Visual Design Editor solve this issue by giving us simple Drag & Drop interface for rearranging standard magento block.

       2. Product Management Changes

      •  When create an new product in magneto1.x, we need to select the product attribute set and product type , after the selection then continue the process. Then it will go to the product management page.
        But in magento 2, product type selection has a useful new dropdown menu for quickly adding new product of any type

      •  Also have two main tabs, Basic Settings And Advanced Settings

      •  The Image and Category selection goes to the General Section (under the Basic Settings).Also removed the category tree from create a product page.
      •  Also can change the attribute set while creating or editing the product.

       3. Tax Management Changes

      •  There are some new featured for tax management is
        The System > Import menu include a new additional tab for importing/exporting the tax rates.
      •  New menu named Tax selection under the system. That allow you to manage the tax zones and the manage the tax zone rates

      Based on the above changes, we can conclude the upcoming release of the magento version will be the next level of the magento platform also the e-commerce platform.

Posted in Magento Developer Notes | Leave a comment

Mobile App Development – Framework expectations

Mobile App Development – Framework expectations
One of of our potential clients asked the following question recently:
Weed to know what you plan to use to develop the application. What type of framework expectations should we have for both iOS and Android?

The following was portion of the response from the development Team

1. Technology stack

Android app
Programming language: Native Android SDK
Development Environment: Eclipse IDE + ADT
Local database: SQLite DB

iPhone app
Programming language: Native iOS SDK
Development Environment: XCode
Local database: SQLite DB

Remote Database
Database: MySQL DB

Web Services
PHP web services transaction as JSON record set
Slim framework based REST APIs for CRUD services

2. Design

FluidUI – for UI prototype design
Adobe Illustrator – for UI design

3. Development

Android ADT Bundle
iPhone XCODE
Facebook API
Google Maps API
Weather API

4. Database

Local DB – SQLite
Remote DB - MySQL

5. Testing

Testing – Manual testing
Testing – Multiple device form factor testing

6. Overall project management

Trello dashboard

Posted in General | Leave a comment

How to change the label of “shipping & handling” in cart page of Magento

In this blog we are explaining how to change the label of shipping & handling in cart page of Magento.

 

We can done this in two ways.
 
 By changing the core files.

    a. Go to app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php on line no.184, there is a fetch() function.
    b. In that change the value of “$title = Mage::helper(‘sales’)->__(‘Shipping & Handling’);” with the custom text. Eg: $title = Mage::helper(‘sales’)->__(‘Shipping & Delivery’);
    c. Then save the file.

By changing translate.csv file. We can avoid the core change of the file by this method.

    a. Open app/design/frontend/default/yourtheme/locale/en_US(depending on your locale settings)/translate.csv
    b. Then add the following, “Shipping & Handling”,”Shipping”
    c. After that save the file.
Posted in Magento Developer Notes | Leave a comment

Some of the useful extension links in Magento

We are working in Magento platform for couple of years. In the developing stage of websites we used many of the 3rd party modules. We can find many of the extensions for a single requirement. But we have to choose the right and good from that. The extension that we mostly used and its links are listed below. We recommended following due its friendly coding style, helpful support, and bug free features.

Top menu

http://www.magentocommerce.com/magento-connect/WebAndPeople/extension/5765/wp_custom_menu
http://www.magentocommerce.com/magento-connect/OlivertAr/extension/657/navigation-bar-administrator
http://www.magentocommerce.com/magento-connect/mgs-mega-menu.html

Left Navigation

http://www.magentocommerce.com/magento-connect/sidebar-navigation-menu-professional.html
http://www.magentocommerce.com/magento-connect/Rico+Neitzel/extension/763/vertical-navigation-with-css-classes

Advanced Layered Navigation

http://www.magentocommerce.com/magento-connect/drop-down-list-for-layered-navigation.html
http://www.magentocommerce.com/magento-connect/layered-navigation-pro.html
http://www.magentocommerce.com/magento-connect/multiple-select-in-layered-navigation-filters.html
http://www.mangoextensions.com/ajax-layered-navigation-dropdowns-for-magento.html
http://www.magentocommerce.com/magento-connect/improved-layered-navigation-by-amasty.html
http://www.magentocommerce.com/magento-connect/ajax-layered-navigation-pro.html

Advanced Search

http://ecommercesoftwaresolutionsonline.com/services-pricing/magento-extensions/product-attribute-filter-module.html

Color Swatches

http://www.magentocommerce.com/magento-connect/pre-select-colors-plus-swatches.html

Enquiry modules

http://ecommercesoftwaresolutionsonline.com/magento-enquiry-feedback-form-module.html
http://ecommercesoftwaresolutionsonline.com/magento-enquiry-feedback-form-with-attachment-extension.html

Catalog Permissions

http://ecommerce.aheadworks.com/magento-extensions/catalog-permissions.html

FLike (Face book Like Button)

http://www.magentocommerce.com/magento-connect/facebook-like-button-free-magento-extension.html
https://developers.facebook.com/docs/plugins/like-button
http://magento-development-firm.blogspot.in/2011/04/magento-how-to-place-facebook-like-and.html

Twitter posts display

http://www.magentocommerce.com/magento-connect/creare-latest-tweets-from-twitter.html
http://www.magentocommerce.com/magento-connect/latest-twitter-tweets.html

Social Login

http://www.magentocommerce.com/magento-connect/social-login-1.html

Quick Contact Extension

http://www.magentocommerce.com/magento-connect/quick-contact-2.html

Related Products Manager

http://www.magentocommerce.com/magento-connect/related-products-manager.html

QuickBooks

http://www.magentocommerce.com/magento-connect/webgility/extension/1202/ecc-quickbooks-integration-for-magento
http://www.magentocommerce.com/magento-connect/quickbooks-integration.html
http://www.magentocommerce.com/magento-connect/quickbooks-integration-addon-for-store-manager-for-magento.html

Product Out of Stock Subscription

http://www.magentocommerce.com/magento-connect/product-out-of-stock-subscription.html

Price Countdown

https://www.magentocommerce.com/magento-connect/price-countdown.html
http://www.magentocommerce.com/magento-connect/countdown-by-aheadworks.html

Advanced custom option extension

http://www.magentocommerce.com/magento-connect/dependent-custom-options.html
Demo URL: http://hottons.com/demo/od/electronics/cell-phones/htc-touch-diamond.html
http://www.magentocommerce.com/magento-connect/advanced-product-options.html

Gift Card

http://www.magentocommerce.com/magento-connect/gift-cards-10026.html

Payment Logo

http://www.magentocommerce.com/magento-connect/payment-method-logo.html

One step Checkout

http://www.magentocommerce.com/magento-connect/one-step-checkout-v4.html
http://www.magentocommerce.com/magento-connect/express-checkout-one-step-checkout.html

For Adding surcharge to Credit Cards

http://www.magentocommerce.com/magento-connect/surcharge.html

Add Order Comment in magento checkout

http://www.magentocommerce.com/magento-connect/brainvire-order-comment-order-comment-magento-extension.html
http://www.magentocommerce.com/magento-connect/magemaven-ordercomment.html

Loyalty Program

http://www.magentocommerce.com/magento-connect/sweet-tooth-customer-rewards.html

Blog

http://www.magentocommerce.com/magento-connect/aheadworks/extension/1516/blog-extension-by-aheadworks
http://www.magentocommerce.com/magento-connect/magento-wordpress-integration.html

To delete test orders

http://www.magentocommerce.com/magento-connect/asperience-deleteorders.html
http://www.magentocommerce.com/magento-connect/seamless-delete-order.html

Maintenance Page

http://www.magentocommerce.com/magento-connect/maintenance-page-artson-it.html

Order Import & Export

http://www.magentocommerce.com/magento-connect/site-management/import-export/dataflow-batch-import-export-orders-to-csv-xml.html
http://www.aitoc.com/en/magentomods_orders_export_and_import.html

Order Export

http://www.xtento.com/magento-extensions/magento-order-export-module.html
http://www.magentocommerce.com/magento-connect/site-management/import-export/webshopapps-orderexport.html

Inventory Report

http://www.magentocommerce.com/magento-connect/inventory-report-4705.html
http://www.magentocommerce.com/magento-connect/catalog/product/view/id/16124/

eBay Integration

http://www.magentocommerce.com/magento-connect/ebay-magento-integration-order-import-and-stock-level-synchronization-also-supports-amazon-rakuten-and-play-com.html

Mailchimp

http://www.magentocommerce.com/magento-connect/ebizmarts-magemonkey-official-mailchimp-and-mandrill-integration.html

eWay Recurring Payment

http://ecommercesoftwaresolutionsonline.com/magento-services-pricing/magento-extensions/eway-recurring-payment.html

Posted in Magento Developer Notes | 1 Comment

Creating your own responsive slider in Magento 1.9 RWD theme using the in-built slider in CMS page

RWD theme is the Magento’s first step in responsive web design and development. The theme offers a lot of responsive and multi-device adaptive features.HTML 5 and CSS3 is used to make this possible and with its’ introduction, the rwd theme is taken to next level. After installing the Magento you will notice that Home page, which is a CMS page, contains a beautiful responsive slider. This slider can be used anywhere else on the CMS pages. Here in this article, we are going one more step forward by implementing this responsive slider in non-CMS pages i.e. anywhere and if required, everywhere on our e-commerce site.

At first take a look at the home page under CMS pages in Magento Admin.Go to CMS>Pages>Madison Island and check the content. We can see the following code:

<div class="slideshow-container">
                <ul class="slideshow">
                                <li><a href="{{config path="web/secure/base_url"}}accessories/eyewear.html"><img src="{{media url="wysiwyg/slide-1.jpg"}}" alt="An eye for detail - Click to Shop Eye Wear" /></a></li>
                                <li><a href="{{config path="web/secure/base_url"}}women.html"><img src="{{media url="wysiwyg/slide-2.jpg"}}" alt="Style solutions - covet-worthy styles in travel-friendly fabrics - Click to Shop Woman" /></a></li>
                                <li><a href="{{config path="web/secure/base_url"}}men.html"><img src="{{media url="wysiwyg/slide-3.jpg"}}" alt="Wing man - hit the runway in stylish separates and casuals - Click to Shop Man" /></a></li>
        </ul>
<div class="slideshow-pager">&nbsp;</div>
<span>&nbsp;</span> <span class="slideshow-next">&nbsp;</span></div>

PHTML file contains both the script, which is PHP code and HTML code. Usually the output of .phtml file will be an html code which will be a part of our website. Copy the code described in the above paragraph and paste it into the new phtml file created in a text editor. We can see cms directives {{ }} in the code of responsive slider which will not work in our phtml file and we need to change that.CMS pages are used here to get the url/uri of the required html pages. For that purpose, we can use PHP script. We need to get the base url and media url of the magento for that we can use the magento functions:

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)
Mage::getBaseUrl()

After storing the base url and media url to a variable they can be called instead of the cms directives. Our phtml file can be modified as:

<?php   
    $base_url=Mage::getBaseUrl();
    $media_url=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
?>
 
<div>
                <ul class="slideshow">
               <?php echo '<li><a href="'.$base_url.'accessories/eyewear.html"><img src="'.$media_url.'wysiwyg/slide-1.jpg" alt="An eye for detail - Click to Shop Eye Wear" /></a></li>'; ?>
               <?php echo '<li><a href="'.$base_url.'women.html"><img src="'.$media_url.'wysiwyg/slide-2.jpg" alt="Style solutions - covet-worthy styles in travel-friendly fabrics - Click to Shop Woman" /></a></li>'; ?>    
               <?php echo '<li><a href="'.$base_url.'men.html"><img src="'.$media_url.'wysiwyg/slide-3.jpg" alt="Wing man - hit the runway in stylish separates and casuals - Click to Shop Man" /></a></li>'; ?>
        </ul>
<div class="slideshow-pager">&nbsp;</div>
<span class="slideshow-prev">&nbsp;</span> <span class="slideshow-next">&nbsp;</span></div>

Important: Please check syntax before copy –pasting.

Now our template file is ready. Save it under ../design/../page/ folder giving a name slider.phtml or the name you like.
After that, call the slider.phtml in any xml file like page.xml under any references or block as shown below:

Now clear the cache and look for changes. We can see a beautiful responsive slider in our e-commerce site.
Thank you for reading and Please share your valuable comments.

Posted in Magento Developer Notes | Leave a comment

Adding Style to Price Elements in Magento

One of our client’s requirements was to display the price as separate 3 elements (currency symbol, price value before decimal & after decimal, as separate). For that we adopted the following method and solved the issue. Here is the screenshot of my work


 

The procedure we adopted in this work is as follows..

In price.phtml mainly there are 4 condition checking, such as

      1.Whether the product is grouped or not.
      2.Is there any discount/ Special price.
      3.Show both price (include and exclude tax) or any one only.
      4.Finally the FPT (fixed product tax or ecological tax) display type (FPT again include 4 condition but it’s normally not in use for most of the countries, So most probably we proceed with its else condition).

The price format is displayed by calling the method formatPrice($price, $includeContainer = true) from class Mage_Core_Helper_Data in the price template.

Here we are includluding a new method separateformatPrice($price, $includeContainer = true) in class Mage_Core_Helper_Data
as
var $pro;
public function separateformatPrice($price, $includeContainer = true)
{
$this->pro= array();
$this->pro[0]= Mage::app()->getLocale()->currency(Mage::app()->getStore()
->getCurrentCurrencyCode())->getSymbol();
$num_price= Mage::app()->getLocale()->getNumber($price);
$pri=explode('.',$num_price);
$this->pro[1]=$pri[0];
$this->pro[2]= ".";
if($pri[1]!=0):
$this->pro[3]=$pri[1];
else:
$this->pro[3]="00";
endif;
return $this->pro;
}

and this method is called in the places where you want to display the separated price in the price.phtml template file.

For that now call the function separateformatPrice($price, $includeContainer = true) by replacing
formatPrice($_price, false) ?>
with

<?php $prices = $_coreHelper->separateformatPrice($_price, false) ?>
$i=1;
foreach ($prices as $pric):      { ?>
<span id="price-element<?php echo $i; ?>">
<?php echo $pric;?>
</span>
<?php $i++;
}
endforeach;
?>

Note: the variable $_price may change as the condition fails.

Thank you for your time to read this and wish you the best to solve your challenges

Posted in Magento Developer Notes | Leave a comment