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 🙂
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 🙂
Hello
What should be the file name for the second option?
Sorry for late reply.
You can give any name and place it in root folder.
You can access it using http://www.yourdomain.com/test.php // e.g: test.php is your file name.
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
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?
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