Magento Ecommerce Strategy, Design & Development

Magento - How to tell if you are on the home page or not

How to tell if your on the home page in magento or not
if($this->getIsHomePage()) {
echo 'You are in Homepage!';
} else {
echo 'You are NOT in Homepage!';

Or you can try this:

$routeName = Mage::app()->getRequest()->getRouteName(); $identifier = Mage::getSingleton('cms/page')->getIdentifier(); if($routeName == 'cms' && $identifier == 'home') { echo 'You are in Homepage!'; } else { echo 'You are NOT in Homepage!'; }

Magento – changing the status of an order

Here, I will show you, how you can change your order status programmatically (with PHP coding). First, you need to load your order. If you have order id, you can load order in the following way:-

$orderId = YOUR_ORDER_ID;
$order = Mage::getModel('sales/order')

If you have order increment id, you can load order in the following way:-

$orderIncrementId = YOUR_ORDER_INCREMENT_ID;
$order = Mage::getModel('sales/order')

Now, here is the code to change order status:-

 * change order status to 'Completed'
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();

Similarly, you can change the order status to pending, processing, canceled, closed, holded, etc.

Read more

Magento – creating a custom observer

3 Steps to create a custom observer. These instructions are to create an observer when a customer is in the process of checking out, and we are "Observing" the Save shipping piece. This was needed for a project that we are appending to the Gift Message feature for magento. We are adding some text to every order that passes through regardless if the user entered something or not. For this project I have a Website called Bloom Step 1: create the module xml In /app/etc/modules create an xml file called Bloom_Checkout.xml In this new file add the following:

<?xml version="1.0"?>

Read more

Recover Mysql Root password

You can recover MySQL database server password with following five easy steps.

Step # 1: Stop the MySQL server process.

Step # 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for password.

Step # 3: Connect to mysql server as the root user.

Step # 4: Setup new mysql root account password i.e. reset mysql password.

Step # 5: Exit and restart the MySQL server. Here are commands you need to type for each step (login as the root user):

Step # 1 : Stop mysql service # /etc/init.d/mysql stop Output: Stopping MySQL database server: mysqld.

Step # 2: Start to MySQL server w/o password: # mysqld_safe --skip-grant-tables & Output: [1] 5988 Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client: # mysql -u root Output: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>

Read more

How to get a magento item using sku, name, ID

// Load by name $_category = Mage::getModel('catalog/category')->loadByAttribute('name', 'Ruby Ring'); $_product = Mage::getModel('catalog/product')->loadByAttribute('name', 'emerald earring'); // Load by SKU $_product = Mage::getModel('catalog/product')->loadByAttribute('sku', 'Eram18j4'); //Load by ID (just load): $_product = Mage::getModel('catalog/product')->load($productID);