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

How to Reset Google Apps Admin password?

Scenario: You have set up google apps for your domain. Let the link be:- https://www.google.com/a/domain.com/ Now, you forgot the admin password. Solution: – Go to https://www.google.com/a/domain.com/ForgotAdminAccountInfo – Submit the Captcha. – The password reset instruction will be sent to the secondary email which you kept while creating the google app for your site. That’s all. … Read more