Magento: Authorize.net not displayed in Payment Information section while Checkout

Scenario: I have enabled Authorize.net payment method but it is not displayed in Payment Information section while Checkout. Problem: In the class Mage_Paygate_Model_Authorizenet, you will find the following variable:- protected $_allowCurrencyCode = array('USD'); It means, the allowed currency for Authorize.net is only US Dollar (USD). You have to add the currency code to the above … Read more

PHP: How to get integer or decimal from a string?

Suppose, I have a string with text and number and I only want the number. I don’t want the characters and text of the string. Here is the way out:- In this example, you will get only integer. It will omit all characters and text from the string. $string = 'Nrs 89,994,874.0098'; echo preg_replace("/[^0-9]/", '', … Read more

Magento: Enable Cookies Problem

Problem: When I try to add products to shopping cart, I get redirected to enable-cookies CMS page. Similarly, when I try to login as customer from customer account login, I get redirected to the same (enable-cookies) page. The enable-cookies page asks me to enable cookies in my browser. The message says: Please enable cookies in … Read more

Magento: How to get most viewed products?

Here, I will show you the code to get the most viewed products in Magento. The function addViewsCount() filters the products with their views count. Here is the code:- Get overall Most viewed products public function getMostViewedProducts() { /** * Number of products to display * You may change it to your desired value */ … Read more

PHP: Simple and easy way to format URL string

Here, I will be showing you a simple and easy one line code to format URL string with PHP. By URL string, I mean the url key in any Search Engine Friendly URL. I have used preg_replace function to do so. preg_replace($pattern, $replacement, $string) preg_replace function performs a regular expression search and replace. This will … Read more

Magento: Get Product Collection by Type

Products can be of different types in Magento. The different product types are Simple Product, Configurable Product, Bundle Product, Grouped Product, Downloadable Product, and Virtual Product. For example: Chair can be a Simple Product. Shoes can be of different color and size. So, shoes falls under Configurable product. A downloadable mp3 music file will fall … Read more

Magento: Setup multiple currency shop

You can easily setup a multiple currency shop in Magento. By multiple currency shop, I mean giving the user to browse products in different currencies. Magento will provide a currency dropdown in category and product listing page. When you select your desired currency, the entire products price will be changed to your selected currency. Here … Read more