Solution: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘main_table.custom_design_apply’ in ‘field list’

Posted: March 30, 2013 in Magento, Version 1.6.*
Tags: , , ,

Hello Guys,

Today i m going to show you the ways to resolve error “SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘main_table.custom_desiwegn_apply’ in ‘field list’”

How this error occurs?

The above error occurs when we enable Flat catalog category settings from admin  >> System  >> Configuration >> Catalog  >> Frontend >> “Use Flat Catalog Category” set to “Yes”

How to resolve above error?

There are two ways to resolve above error specified below:

First Solution: 

Rewrite file  “YourProject\app\code\core\Mage\Catalog\Model\Resource\Category\Flat.php ” to do change in function getDesignUpdateData we need to comment code ”  ‘main_table.custom_design_apply’,” from function.

Second Solution:

To resolve above error we will create category attribute , create one file in root and paste below code and than execute that file once:

<?php
error_reporting(E_ALL | E_STRICT);
define('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
// below code will add text attribute
$setup->addAttribute('catalog_category','custom_design_apply',
	 array(
            'type'              => 'int',
            'label'             => 'Apply To',
            'frontend'          => '',
            'table'             => '',
            'input'             => 'select',
            'class'             => '',
            'source'            => 'core/design_source_apply',
            'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
            'visible'           => true,
            'required'          => false,
            'user_defined'      => false,
            'default'           => '',
            'searchable'        => false,
            'filterable'        => false,
            'comparable'        => false,
            'visible_on_front'  => false,
            'unique'            => false,
            'group' => 'design',
	    'sort'  => 20
        )
);

Don’t forget to do re-index from Admin panel, System >> Index Management

I hope above solution works like  charm.

Thanks,

Bijal Bhavsar 🙂

Advertisements
Comments
  1. John Jones says:

    where do you put this setup code? In the core file?
    Any way of doing this without editing core?

    • Hello John,

      You can create one file in root folder and run it once. You need to add below code above setup code:

      <?php
      error_reporting(E_ALL | E_STRICT);
      define('MAGENTO_ROOT', getcwd());
      $mageFilename = MAGENTO_ROOT . '/app/Mage.php';
      require_once $mageFilename;
      Mage::setIsDeveloperMode(true);
      ini_set('display_errors', 1);
      umask(0);

      ///SETUP CODE COMES HERE

      Sorry for late reply.

      Regards,
      Bijal Bhavsar 🙂

  2. Hello
    What should be the file name for the second option?

  3. dev2014 says:

    Its showing error
    Fatal error: Call to a member function getResourceConfig() on a non-object in /app/code/core/Mage/Core/Model/Resource/Setup.php on line 131

  4. Shoaib says:

    What if we Set “Use Flat Catalog Category” set to “No” simply it will resolve the problem, it does for me.. is there any issue with this?

  5. Shoaib says:

    Not worked for me at all gives the error:
    Fatal error: Call to a member function getResourceConfig() on a non-object in /var/www/html/magento/app/code/core/Mage/Core/Model/Resource/Setup.php on line 131

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s