How to find php version and php.ini file location path?

We can view the php settings by creating a php file in our web root with the following code: <?php phpinfo(); ?> Let the name of the file be phpinfo.php The file location will be: /var/www/phpinfo.php (For Linux) C://xampp/htdocs/phpinfo.php (For Windows with Xampp) C://wamp/www/phpinfo.php (For Windows with Wamp) Open http://localhost/phpinfo.php in your browser in your … Read more

print_r in Javascript

It’s a real headache when you have to work on objects and arrays in Javascript. It would be lot easier to detect elements of the Javascript objects/arrays if we have print_r function in Javascript like we have in PHP. I googled the web and have found a very efficient print_r Javascript function. Here is the … Read more

Magento: Get manufacturer name and id from product

Suppose, you have the product data, i.e. you have a loaded product information stored in a variable named ‘$_product‘. Now, when you type $_product->getManufacturer() , you will get the manufacturer ID. To get the manufacturer name, you have to use the following: $_product->getAttributeText(‘manufacturer’). Below is the complete code: Get Manufacturer Name and ID from Product … Read more

Magento: Get list of all manufacturers

Manufacturer is a core product attribute in Magento. This article shows how you can fetch the manufacturer attribute and all it’s option value and id. Here is the code to list all the option values of manufacturer attribute: /** * Get list of all manufacturers */ $_productId = 11; // Your Product ID $_product = … Read more

Magento: How to get controller, module, action and router name?

You can easily get controller name, action name, router name and module name in any template file or class file. IN TEMPLATE FILES $this->getRequest() can be used in template (phtml) files. Here is the code: /** * get Controller name */ $this->getRequest()->getControllerName(); /** * get Action name, i.e. the function inside the controller */ $this->getRequest()->getActionName(); … Read more

Magento: How to filter product collection using 2 or more category filters?

Suppose, you have a product collection and you want to filter it by category. Suppose, you want to filter it by more than one category. You can use addCategoryFilter if you have only one category. But, what if you want to filter by more than one category? Category ids are stored for product in a … Read more

Magento: Create, Read, Delete Cookie

Here is the code to create, read, and delete cookie in Magento. Mage_Core_Model_Cookie class contains functions to set, get and delete cookie. /** * set cookie * name and value are mandatory; other parameters are optional and can be set as null * $period = cookie expire date */ Mage::getModel('core/cookie')->set($name, $value, $period, $path, $domain, $secure, … Read more

WordPress: Create custom archive page

This article shows how to create a custom archive page for your wordpress blog. In the following archive page, I have displayed yearly archive, monthly archive, category wise archive and all post archive. So, the newly created archive page will be a kind of all-in-one archive page. Here is the step-by-step guide: 1) Create a … Read more