2015-08-23 35 views
0

我有这个错误基表或视图:1146 Tablecatalog_product_entity不存在

 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(
 
\t "DROP TABLE IF EXISTS {$this->getTable('netsol_social_discount')}; 
 
\t 
 
\t CREATE TABLE IF NOT EXISTS {$this->getTable('netsol_social_discount')} (
 
\t \t `id` int(11) NOT NULL, 
 
\t \t `product_id` int(11) NOT NULL, 
 
\t \t `media` varchar(30) NOT NULL, 
 
\t \t `ip_address` varchar(50) NOT NULL, 
 
\t \t `coupon_code` varchar(30) NOT NULL, 
 
\t \t `coupon_used` enum('1','0') NOT NULL DEFAULT '0', 
 
\t \t `creation_date` datetime NOT NULL, 
 
\t \t `coupon_used_date` datetime NOT NULL, 
 
\t \t `magento_order_id` varchar(50) NOT NULL 
 
\t) ENGINE=InnoDB DEFAULT CHARSET=latin1; 
 
\t 
 
\t ALTER TABLE {$this->getTable('netsol_social_discount')} ADD PRIMARY KEY (`id`); 
 
\t 
 
\t ALTER TABLE {$this->getTable('netsol_social_discount')} MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 
 
\t 
 
\t 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(
 
\t 'type' => 'int', 
 
\t 'backend' => '', 
 
\t 'frontend' => '', 
 
\t 'label' => 'Enable Social Discount', 
 
\t 'input' => 'boolean', 
 
\t 'class' => '', 
 
\t 'source' => 'adminhtml/system_config_source_yesno', 
 
\t 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 
 
\t 'visible' => true, 
 
\t 'required' => false, 
 
\t 'user_defined' => true, 
 
\t 'default' => 1, 
 
\t 'searchable' => true, 
 
\t 'filterable' => false, 
 
\t 'comparable' => false, 
 
\t 'visible_on_front' => false, 
 
\t 'unique' => false, 
 
\t 'group' => 'General', 
 
\t 'attribute_set' => 'Default' 
 
)); 
 
$catalogSetup->endSetup();

这里休息另一个文件:

<?php 
 
/* 
 
* @desc: Default enable social discount for all products on installation 
 
*/ 
 

 
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('enable_social_discount'); 
 
if($products->count()) { 
 
\t Mage::getSingleton('core/resource_iterator')->walk($products->getSelect(), array('socialDiscountCallback')); 
 
} 
 

 
function socialDiscountCallback($args) { 
 
\t $product = Mage::getModel('catalog/product'); 
 
\t $product->setData($args['row']); //map data to product model 
 
    $product->setEnableSocialDiscount(1); 
 
    $product->getResource()->saveAttribute($product, 'enable_social_discount'); 
 
}

可能是什么问题呢?我试图创建表和属性,帮助,但现在当我去添加一个产品,我得到这个错误。

谢谢

+0

也许你是在错误的数据库。尝试限定表名,看看是否有帮助。我还注意到,有问题的名称以字符串“table”开头,这看起来很不寻常。 –

回答

0

在我的情况是,是造成麻烦的数据库前缀。我删除了所有的前缀,一切正常。

相关问题