Magento – price helper code snippet

This piece of codes will help you get final price with tax and formatted nicely using your store currency


<?php
$_coreHelper = $this->helper(’core’);
$_taxHelper = $this->helper(’tax’);
$_finalPriceInclTax = $_taxHelper->getPrice($_product, $_product->getFinalPrice(), true);
$_finalPriceInclTaxNicelyFormated = $_coreHelper->currency($_finalPriceInclTax,true,false);
echo $_finalPriceInclTaxNicelyFormated;

?>

Hope you find it useful ! 😀

Five common PHP design patterns

php

Design patterns were introduced to the software community in Design Patterns, by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (colloquially known as the “gang of four”). The core concept behind design patterns, presented in the introduction, was simple. Over their years of developing software, Gamma et al found certain patterns of solid design emerging, just as architects designing houses and buildings can develop templates for where a bathroom should be located or how a kitchen should be configured. Having those templates, or design patterns, means they can design better buildings more quickly. The same applies to software.

Continue reading

WordPress – reset your admin password using Command line (quick way)

Sometimes, you lose your credential to your wordpress admin dashboard, i guess many of you had this question in mind : what is the quickest way to reset my admin password ?

error-wp1

In WordPress, there is more than one way to set your password. In normal circumstances, you can do it through the WordPress interface. If you forget your password, WordPress has a built in recovery mechanism that uses email.

But on some hosts, especially when email isn’t working right, sometimes you have to take different steps to reset your password. in this article, i’ll show you how to reset you admin password using command line:

1. log in to MySQL

mysql -u root -p

Continue reading

Magento – fix the 404 error on the admin dashboard

When I changed the URI to access to my dashboard, when I logged in again, there was a 404 error on the admin dashboard. It seems is something related to permissions and can be easily solved executing the following commands:

find . -type d -exec chmod 755 {} ;
find . -type f -exec chmod 644 {} ;
chmod o+w var media -R

If this doesn’t work, maybe the login form is not redirecting correctly. In that case we need to change the action url in the app/design/adminhtml/default/default/template/login.phtml file. Look for the «form» start tag:

<form method="post" action="" id="loginForm">

Change it to:

<form method="post" action="<?php echo $this->getUrl('adminhtml') ?>" id="loginForm">

that’s it, you have you familiar dashboard back 😀

Design patterns which are used in Magento

A design pattern in architecture and computer science is a formal way of documenting a solution to a design problem in a particular field of expertise.

from wikipedia.

Factory:

$product = Mage::getModel(‘catalog/product’);

Singleton:

$category = Mage::getSingleton(‘catalog/session’);
Continue reading