Magento Upgade Notes

Here are some useful notes for upgrading Magento:

  • Before starting the upgrade, block all access to the site by turning on password protection. It is critical that only one browser execute the database upgrade.
  • Next make a full backup of all files and the database. If the upgrade fails you’ll need these to restore.
  • Using the command line seems to give the most stable results. Here’s a great article that shows the command line upgrade process:
    http://blog.nexcess.net/2011/03/11/upgrading-to-magento-1-5-0-1/
  • In the above instructions, if Step 2 fails then try running:

    ./pear pear-setup .
    

    Then try Step 2 again.

  • After the upgrade you’ll need to rebuild indexes and clear caches before products will display.
  • If you get an exception like this:
    PHP Fatal error:  Call to a member function toHtml() on a non-object in ...

    Then use the fix described here:

    http://screencastworld.com/2010/07/magento/how-to-fix/php-fatal-error-call-to-a-member-function-tohtml-on-a-non-object-in-layout-php-on-line-529

  • If you get an exception like this:

    Invalid method Mage_Catalog_Block_Product_List_Toolbar::isLastPage...

    Then follow these steps:

    1. Create folder at app/code/local/Mage/Core/Block/
    2. Copy app/code/core/Mage/Core/Block/Template.php to app/code/local/Mage/Core/Block/Template.php
    3. Edit app/code/local/Mage/Core/Block/Template.php and paste this code:

      public function isLastPage()
          {
              return $this->getCollection()->getCurPage() >= $this->getLastPageNum();
          }
      

      directly after this existing code:

      public function getCacheKeyInfo()
          {
              return array(
                  'BLOCK_TPL',
                  Mage::app()->getStore()->getCode(),
                  $this->getTemplateFile(),
                  'template' => $this->getTemplate()
              );
          }
      

    This fix comes from here:

    http://www.magentocommerce.com/boards/viewthread/201998/

  • Sometimes pagination will be lost from categories that span multiple pages. This can be fixed with the following steps:

    1. Edit app/design/frontend/default/modern/layout/catalog.xml
    2. Add this line:
      <block type="page/html_pager" name="product_list_toolbar_pager" template="page/html/pager.phtml"/>
      

      after this line:

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

      in the “Catalog default layout” section. Also add the same line after:

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

      in the “Category layer navigation layout” section.

    3. Edit app/design/frontend/default/modern/template/catalog/product/list/toolbar.phtml
    4. Remove these lines:
      <?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') ?>" /></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') ?>" /></a>
               </li>
            <?php endif ?>
         </ol>
      </td>
      <?php endif; ?>
      

      And replace with this line:

      <?php echo $this->getPagerHtml() ?>
      
    5. Next edit skin/frontend/default/modern/css/boxes.css.
    6. Change the “table.pager td” definition around line 443 to:
      table.pager td { width:53%; border-top:1px solid #ddd; padding:4px 8px; vertical-align:middle; }
      
    7. After the following lines around line 450:
      table.pager td.sort-by .active:hover { color:#444; }
      

      Add these lines:

      table.pager td td{ width:57%; border-top:none; padding:0px; vertical-align:none; }
      table.pager td td.a-right{ width:auto; }
      
    8. Locate the “.a-right” definition around line 1447 and change to:
      .a-right        { text-align:right !important; width:19% !important;}
      

    Note that the CSS changes in steps 5 to 8 may vary between sites and different layouts.

  • The Credit Card checkout method may be broken due to a missing javascript file reference. The symptom is that the Continue button on step file does nothing. The fix is to edit the layout/page.xml file for your theme at app/design/frontend/default/[YourThemeName]/layout/page.xml and add the following line in two places:

    <action  method="addJs"><script>lib/ccard.js</script></action>
    

    Full details can be found in this article:

    http://www.magthemes.com/magento-blog/checkout-does-not-work-with-credit-card-payment-method-in-magento-1-4-1-0/

    Don’t forget to flush the JavaScript/CSS Cache after making these changes.

  • While the database upgrade is running, if you get an exception like this:
    Invalid mode for clean() method
    

    Then you’ll need to manually clear the caches like this:

    rm -rf var/session/*
    rm -rf var/cache/*
    rm -rf app/code/core/Zend/Cache/*
    

    The same fix applies if you get an exception like:

    Mage registry key "_resource_helper/core" already exists
    
  • If you get SQL integrity constrain violation errors similar to this:
    Error in file: "/var/www/vhosts/shop.burgerlounge.com/httpdocs/app/code/core/Mage/
    Customer/sql/customer_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php" -
    SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate
    entry '0-1' for key 2
    

    Then first try to Google and find a solution. As a last resort edit app/etc/config.xml and change:

    <initStatements>SET NAMES utf8</initStatements>
    

    to:

    <initStatements>SET NAMES utf8;SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0;</initStatements>
    

    This will disable integrity checking. Make sure you remove this change after the upgrade has been completed.

  • Sometimes in an old theme you’ll see where the developer hacked an addJs2 function into app/code/core/Mage/Page/Block/Html/Head.php and then put something like:

    <action method="addJs2"><script>js/jquery.cookie.js</script></action>
    

    into the page.xml layout.

    To fix this change the page.xml code to:

    <action method="addItem"><type>skin_js</type><name>js/jquery.cookie.js</name></action>
    
  • In older versions you could do this in a template:

    $childCat = Mage::getModel('catalog/category')->load($child);

    For newer versions do this instead:

    $childCat = Mage::getModel('catalog/category')->load($child->getId());
  • http://xavisys.com/ Aaron D. Campbell

    Thanks for the info, and even more so thanks for helping fix up that Magento site for me!

blog comments powered by Disqus