php.ini : Most commonly used php directives

Below are the most commonly used php directives. You have to change php.ini file in order to configure php settings. This just means changing these directive’s option and value. 1) short_open_tag = Off Allow the many servers don’t support short tags. 2) max_execution_time = 30 Maximum execution time of each script, in seconds 3) error_reporting … Read more

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: Optimizing 404 Page Not Found page

Generally the wordpress 404 page contains one or two sentence saying that the page is not found. But you can make it more user friendly. Instead of just writing plain text about page not found, we can display archive list and a search form. In this way, the visitor can search or browse your website … Read more