Magento Upgrade Issue 1.5.1.0 to 1.9.2.1

2019-09-16 13:22发布

问题:

I have just upgraded Magento from 1.5.1.0 to 1.9.2.1 and I am stuck at this error when I try to view a product:

a:5:{i:0;s:1427:"SQLSTATE[42S22]: Column not found: 1054 Unknown column     'rule.calculate_subtotal' in 'field list', query was: SELECT `main_table`.`tax_calculation_rate_id`, `main_table`.`tax_calculation_rule_id`, `main_table`.`customer_tax_class_id`, `main_table`.`product_tax_class_id`, `rule`.`priority`, `rule`.`position`, `rule`.`calculate_subtotal`, `rate`.`rate` AS `value`, `rate`.`tax_country_id`, `rate`.`tax_region_id`, `rate`.`tax_postcode`, `rate`.`tax_calculation_rate_id`, `rate`.`code`, IF(title_table.value IS NULL, rate.code, title_table.value) AS `title` FROM `tax_calculation` AS `main_table` INNER JOIN `tax_calculation_rule` AS `rule` ON `rule`.`tax_calculation_rule_id` = main_table.tax_calculation_rule_id INNER JOIN `tax_calculation_rate` AS `rate` ON rate.tax_calculation_rate_id = main_table.tax_calculation_rate_id LEFT JOIN `tax_calculation_rate_title` AS `title_table` ON rate.tax_calculation_rate_id = title_table.tax_calculation_rate_id AND title_table.store_id = '1' WHERE (customer_tax_class_id = 3) AND (product_tax_class_id IN ('2')) AND (rate.tax_country_id = 'GB') AND (rate.tax_region_id IN(0, 0)) AND (rate.zip_is_range IS NULL) AND (rate.tax_postcode IS NULL OR rate.tax_postcode IN('*', '', 'ig9 5bw', 'ig9 5bw*', 'ig9 5b*', 'ig9 5*', 'ig9 *', 'ig9*', 'ig*', 'i*')) ORDER BY `priority` ASC, `tax_calculation_rule_id` ASC, `tax_country_id` DESC, `tax_region_id` DESC, `tax_postcode` DESC, `value` DESC";i:1;s:6703:"#0 /home/wwwarabesquecost/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

I have tried to manually add it using this link : https://sarfarazlaghari.wordpress.com/2015/06/06/magento-sqlstate42s22-column-not-found-1054-unknown-column-rule-calculate_subtotal-in-field-list/ but this doesn't make a difference.

Has anybody had this issue before?

回答1:

Regarding

I have tried to manually add it using this link : https://sarfarazlaghari.wordpress.com/2015/06/06/magento-sqlstate42s22-column-not-found-1054-unknown-column-rule-calculate_subtotal-in-field-list/ but this doesn't make a difference

Are you saying you've added the column to the tax_calculation_rule table but you're still getting the above error? If that's the case then you've updated the wrong database table, or a configuration file in app/etc is pointed at a different database from the one you think it is.

If that's not what you're saying then be clearer in your question.



回答2:

The query that you found at that link has an obvious error: it create a new field in the table with the same name of the table.

The right query, which solve the error, is the following:

ALTER TABLE tax_calculation_rule
ADD calculate_subtotal TINYINT(1) NOT NULL DEFAULT 0

Hope it helps.



回答3:

You shouldn't run sql alternations just like that. The OP mentioned this has happened after an upgrade to 1.9x.

Having such errors means that your codebase is upgraded but your database is still outdated.

The best way for this would be to alter the core_resource table for the module (e.g. tax_setup) to the version that his database was aware previously, and let magento handle the database updates.



标签: php magento