How to enable Template path hints for Magento admin pages

Wednesday, 30. November 2011

One of them nice little handy tools for backend developers!

INSERT INTO core_config_data (scope, scope_id, path, VALUE)
VALUES ('default', 0, 'dev/debug/template_hints_blocks', 1),
('default', 0, 'dev/debug/template_hints', 1);

Column not found: 1054 Unknown column main_table.include_in_menu in where clause

Tuesday, 29. November 2011

Had this issue today upgrading Magento from 1.3.3.0 to 1.6.0.1 :

Column not found: 1054 Unknown column ‘main_table.include_in_menu’ in ‘where clause’

After a bit of looking around with no luck, resorted back to running a complete Index Management which solved the issue for us.

Let us know if you have any interesting observations yourself!

Mysql – Disable Foreign key with Mysqldump

Monday, 28. November 2011

Here is a script/flag you will need to disable foreign keys while backing up your database with mysqldump

mysql -uUSER -pPASSWORS --disable-keys DATABASE_NAME > dump.sql

Enjoy

Install and configure Ubuntu Classic Desktop in Ubuntu 11.10

Monday, 28. November 2011

For those of you who would like to use Ubuntu classic gnome desktop while on the latest versions on Ubuntu, this script may help

Go to your command line window: Ctrl ? Alt ? T

Type the command below to install Gnome Session Fallback.

sudo apt-get install gnome-session-fallback

After installing, restart your machine and when you come back to login choose Gnome Classic Desktop as shown below.

:)

Magento – Check If Current Page is Home page

Sunday, 27. November 2011

If you have been wondering how easy it is to check if current page is a home page or not in Magento, this script may help out.

<?php if(Mage::getSingleton('cms/page')->getIdentifier() == 'home'  && 
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms') : ? >
# DO The Homepage stuff
<?php endif;?>

Feel free to drop an alternative idea if you have one!

Invalid argument supplied for foreach() lib Varien Data-Collection-Filesystem line 234

Monday, 21. November 2011

Tried to back up the database view Magento Backup tools and go this error.

Invalid argument supplied for foreach() public_html/dev/lib/Varien/Data/Collection/Filesystem.php on line 234

Typical for older versions i.e 1.3.x and here is how you can fix this:

– Navigate to line 234 of file /lib/Varien/Data/Collection/Filesystem.php

– Then change this line which should like something like:

foreach (glob($folder . DIRECTORY_SEPARATOR . '*') as $node) {

TO :

foreach ((array)glob($folder . DIRECTORY_SEPARATOR . '*') as $node) {

Enjoy!

Magento – How to Remove index.php from url address bar

Sunday, 20. November 2011

Here is how you can remove the index.php suffix from Magento URLs with ease!

This is also great thing to do for your SEO.

Log in to the backend and navigate to

System > Configuration > Web > Search Engines Optimization

Set Use Web Server Rewrites to YES.

Refresh cache management and you should be all set from here.

PS:
For others, you may also find useful to enable the RewriteBase from your .htaccess file. Never found this necessary though!

Enjoy.

Magento : Invalid argument supplied for foreach in toolbar.phtml on line 63

Friday, 18. November 2011

Invalid argument supplied for foreach in toolbar.phtml is a common error abserved mostly when upgrading from very old versions of Magento notably 1.3 and below to latest versions.

Here are steps to follow in order to solve the problem.

1. Create Template file for Pagination

Create a new file called pager.phtml in the /template/catalog/product/list/ folder inside your theme folder and add this code.

<?php if($this->getCollection()->getSize()): ?>
        <?php if($this->getLastPageNum()>1): ?>
        <td class="pages">
            <strong><?php echo $this->__('Page:') ?></strong>
            <ol>
            <?php if (!$this->isFirstPage()): ?>
                <li><a href="<?php echo $this->getPreviousPageUrl() ?>"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="<?php echo $this->__('Previous Page'); ?>" /></a></li>
            <?php endif ?>
            <?php foreach ($this->getPages() as $_page): ?>
                <?php if ($this->isPageCurrent($_page)): ?>
                    <li><span class="on"><?php echo $_page ?></span></li>
                <?php else: ?>
                    <li><a href="<?php echo $this->getPageUrl($_page) ?>"><?php echo $_page ?></a></li>
                <?php endif ?>
            <?php endforeach;; ?>
            <?php if (!$this->isLastPage()): ?>
                <li><a href="<?php echo $this->getNextPageUrl() ?>"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="<?php echo $this->__('Next Page'); ?>" /></a></li>
            <?php endif ?>
            </ol>
        </td>
        <?php endif; ?>
<?php endif ?>

2. Now open file catalog.xml

Locate and edit the file catalog.xml from your theme’s layout folder. Search for this line of code:

<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">

Add this line underneath.

<block type="page/html_pager" name="product_list_toolbar_pager" template="catalog/product/list/pager.phtml" />

2. Now open file toolbar.phtml

Finally locate the file toolbar.phtml from your theme/template/catalog/product/list/. Now search for the below block of code approximately around lines 42 – 63:

<?php if($this->getLastPageNum()>1 && is_array($this->getPages())): ?>
...
...
...
<?php endif; ?>

Now replace this block of code with the following code:

<?php echo $this->getPagerHtml(); ?>

Enjoy!

Magento Easy Lightbox Not working after upgrade to 1.6.1.0

Tuesday, 15. November 2011

Had a rather awkward issue today installing Magento Easy Lightbox extension for one of my client. Turned out, it was never that “Easy” to get this thing working seemingly on upgraded version of Magento 1.6.1.0.

After few hours of scratching my head etc, realised the EasyLightbox JS object was never actually initiated so to fix the issues I did the following:

1) Go and open then file:

app/design/frontend/[YOUR_PACKAGE]/[YOUR_THEME]/template/easylightbox/script.phtml.

2) Copy the content of this file and add it to the bottom of the file:

app/design/frontend/[YOUR_PACKAGE]/[YOUR_THEME]/template/easylightbox/media.phtml

3) Log back to Magento Admin page and clear your cache. Visit the frontend and hopefully, you will be screaming for joy!

Enjoy!

How to Remove session id ?___SID=U from the URL – Magento

Monday, 14. November 2011

If Magento has been frustrating the heck out of you with regards to Session IDs (___SID=U) being appended to the URLs, here is a solution for you..

1) Go to System > Configuration > Web > Session Validation Settings

2) Set Use SID on Frontend to ‘No’