我有这个错误
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xxxx_mage.catalog_product_entity' doesn't exist, query was: SELECT * FROM catalog_product_entity ORDER BY CAST(sku AS unsigned) DESC LIMIT 1
#0 /home/angeecom/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(65): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/angeecom/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/angeecom/public_html/lib/Zend/Db/Adapter/Abstract.php(270): Zend_Db_Statement->execute(Array)
#3 /home/angeecom/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(133): Zend_Db_Adapter_Abstract->query('SELECT * FROM c...', Array)
#4 /home/angeecom/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(331): Zend_Db_Adapter_Pdo_Abstract->query('SELECT * FROM c...', Array)
#5 /home/angeecom/public_html/app/design/adminhtml/default/default/template/catalog/product/edit.phtml(136): Varien_Db_Adapter_Pdo_Mysql->query('SELECT * FROM c...')
#6 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Template.php(241): include('/home/angeecom/...')
#7 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#8 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#9 /home/angeecom/public_html/app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#10 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#11 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#12 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Core_Block_Text_List->_toHtml()
#13 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#14 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#15 /home/angeecom/public_html/app/design/adminhtml/default/default/template/page.phtml(67): Mage_Core_Block_Abstract->getChildHtml('content')
#16 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Template.php(241): include('/home/angeecom/...')
#17 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#18 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#19 /home/angeecom/public_html/app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#20 /home/angeecom/public_html/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#21 /home/angeecom/public_html/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#22 /home/angeecom/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#23 /home/angeecom/public_html/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php(269): Mage_Core_Controller_Varien_Action->renderLayout()
#24 /home/angeecom/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Catalog_ProductController->editAction()
#25 /home/angeecom/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('edit')
#26 /home/angeecom/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#27 /home/angeecom/public_html/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#28 /home/angeecom/public_html/app/Mage.php(423): Mage_Core_Model_App->run(Array)
#29 /home/angeecom/public_html/index.php(54): Mage::run('', 'store')
#30 {main}

桌子就在那里。这是mysql的脚本:
<?php
$installer = $this;
$installer->startSetup();
$installer->run(
"DROP TABLE IF EXISTS {$this->getTable('netsol_social_discount')};
CREATE TABLE IF NOT EXISTS {$this->getTable('netsol_social_discount')} (
`id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`media` varchar(30) NOT NULL,
`ip_address` varchar(50) NOT NULL,
`coupon_code` varchar(30) NOT NULL,
`coupon_used` enum('1','0') NOT NULL DEFAULT '0',
`creation_date` datetime NOT NULL,
`coupon_used_date` datetime NOT NULL,
`magento_order_id` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE {$this->getTable('netsol_social_discount')} ADD PRIMARY KEY (`id`);
ALTER TABLE {$this->getTable('netsol_social_discount')} MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
UPDATE `catalog_eav_attribute` SET `is_used_for_promo_rules` = 1 WHERE `attribute_id` = (SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code` = 'sku' AND entity_type_id = (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_type_code` = 'catalog_product') LIMIT 1);"
);
$installer->endSetup();
$catalogSetup = new Mage_Eav_Model_Entity_Setup('core_setup');
$catalogSetup->startSetup();
$catalogSetup->addAttribute('catalog_product', 'enable_social_discount', array(
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Enable Social Discount',
'input' => 'boolean',
'class' => '',
'source' => 'adminhtml/system_config_source_yesno',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => 1,
'searchable' => true,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'group' => 'General',
'attribute_set' => 'Default'
));
$catalogSetup->endSetup();
&#13;
其余文件在其他文件中:
<?php
/*
* @desc: Default enable social discount for all products on installation
*/
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('enable_social_discount');
if($products->count()) {
Mage::getSingleton('core/resource_iterator')->walk($products->getSelect(), array('socialDiscountCallback'));
}
function socialDiscountCallback($args) {
$product = Mage::getModel('catalog/product');
$product->setData($args['row']); //map data to product model
$product->setEnableSocialDiscount(1);
$product->getResource()->saveAttribute($product, 'enable_social_discount');
}
&#13;
可能是什么问题?我试图创建表和属性,但现在当我去添加产品时,我得到了这个错误。
谢谢
答案 0 :(得分:0)
在我的情况下,导致问题的是数据库前缀。我删除了所有前缀,一切正常。