Wednesday, 10 October 2012

Magento: can't login to admin panel, can't add product to cart

If ever you encountered issues like you cannot login to the admin panel or cannot even add product to the cart, I have a better solution for you.

Using phpMyAdmin, in your magento database, look for the core_config_data table and click it. Click the "Search" tab.  Then on the "path" column set the operator to LIKE %...% and the Value to cookie and click the "Go" button to search.

Screenshot provided for clarity

After searching, set the value of web/cookie/cookie_pathweb/cookie/cookie_domainweb/cookie/cookie_httponly, and web/browser_capabilities/cookies to NULL

Just like this on the screenshot.
Screenshot provided for clarity

Adding product to cart and logging in to the admin panel should work now!

Monday, 1 October 2012

Git: Colorizing

It's much easier to work with Git especially if it's colorized. And you can do that by simply executing these in your Terminal :

git config --global core.pager "less -FRSX"
git config --global color.ui auto
git config --global color.pager true

Friday, 28 September 2012

Ubuntu: MySQL import/export with gunzip

To export your mysql database simply do the following :

mysqldump -u user -p database | gzip > database.sql.gz
And to import it :

gunzip < database.sql.gz | mysql -u user -p database

Magento: Unable to list current working directory.

If you are experiencing this error :
"Unable to list current working directory." when saving the product images you uploaded, simply change the permission of the media folder by doing like this :

chmod -R 777 media

Magento: How to fix "The requested URL /index.php was not found on this server" error

If ever you're seeing an error like this when you go to your magento inner pages.

This might fix your problem. In your .htaccess file you probably have something like this :

RewriteRule ^(.*)$ /index.php/$1 [L,QSA,PT]


RewriteRule .* /index.php [NS,L]

If that is so, just simply remove the leading "/" from the index.php then save it.
Refresh the page. And voila! The issue should be fixed now.

Thursday, 27 September 2012

Ubuntu: How to install Compass

Just do the following and everything will be okay.

sudo aptitude install rubygems

(if aptitude doesn't work, you need to install it first by doing this: sudo apt-get install aptitude)
sudo gem install compass
cd /usr/bin
sudo ln -s /var/lib/gems/1.8/bin/compass compass

Friday, 21 September 2012

Magento: How to create a configurable product with associated simple products

Step 1 - Create a simple product.

Screenshot provided for clarity

Screenshot provided for clarity

Fill in all the required fields

Screenshot provided for clarity

Select configurable attributes

Screenshot provided for clarity

Set the "Visibility" to "Not Visible Individually" so that obviously this will not be visible in the frontend and if you are intending to only have configurable products in your store.

Screenshot provided for clarity

Don't forget to fill in the "Qty" and "Stock Availability" in the "Inventory" tab

Screenshot provided for clarity

and assign it to a specific category.

Screenshot provided for clarity

Then after filling all those fields, hit the "Save/Save and Continue" button

Step 2 - Create a configurable product.

Just follow the same process on Step 1.
But this time you have to do the following :
1. Set "Product Type" as "Configurable Product"
2. Select configurable attributes
3. And associate the simple product(s) you want to be associated to this configurable product.

Screenshot provided for clarity

Screenshot provided for clarity

Screenshot provided for clarity

And never forget to hit the "Save/Save and Continue" button! When you go to the frontend you will see now the configurable product you have just created. Isn't that simple?

That's all folks!

Tuesday, 18 September 2012

Magento : Add Custom Layout Template

Tested in CE and EE

In app/design/frontend/base/<your_theme>/layout/page.xml (CE) or app/design/frontend/enterprise/<your_theme>/layout/page.xml (EE), you will see the custom page layout handles. Just copy any of them.

E.g. :

    <page_empty translate="label">
        <label>All Empty Layout Pages</label>
        <reference name="root">
            <action method="setTemplate"><template>page/empty.phtml</template></action>
            <!-- Mark root page block that template is applied -->
            <action method="setIsHandle"><applied>1</applied></action>
            <action method="setLayoutCode"><name>empty</name></action>

I will modify it to :

    <page_homepage translate="label">
        <label>Homepage Layout Page</label>
        <reference name="root">
            <action method="setTemplate"><template>page/homepage.phtml</template></action>
            <!-- Mark root page block that template is applied -->
            <action method="setIsHandle"><applied>1</applied></action>
            <action method="setLayoutCode"><name>homepage</name></action>

Then in app/design/frontend/base/<your_theme>/template/page (CE) or app/design/frontend/enterprise/<your_theme>/template/page (EE), create your custom template. Say homepage.phtml and add the content you need.

After that, you should now be able to access the newly added layout in the Admin panel via CMS->Pages in the design tab of the page you want to edit.

Here's the screenshot :