This is the error, can anyone help me with a solution to this?

There has been an error processing your request

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'f4p_sales_bestsellers_aggregated_yearly.product_type_id' in 'field list', 

Query was:

SELECT COUNT(*) FROM (SELECT MAX(DATE_FORMAT(period, '%Y-%m-%d')) AS `period`, SUM(qty_ordered) AS `qty_ordered`, `f4p_sales_bestsellers_aggregated_yearly`.`product_id`, MAX(product_name) AS `product_name`, MAX(product_price) AS `product_price`, `f4p_sales_bestsellers_aggregated_yearly`.`product_type_id` FROM `f4p_sales_bestsellers_aggregated_yearly` WHERE (EXISTS (SELECT 1 FROM `f4p_catalog_product_entity` AS `existed_products` WHERE (f4p_sales_bestsellers_aggregated_yearly.product_id = existed_products.entity_id))) AND (store_id IN(0)) GROUP BY `product_id` LIMIT 5) AS `t`

Check this table f4p_sales_bestsellers_aggregated_yearly have 'product_type_id' columns in it.

If 'product_type_id' column is in table then re-index and refresh cache.

If 'product_type_id' column is not in table then you need to create (upload backup table) table again.


Database should look like this. Database correct view


This happens if product_type_id was not added by setup update script app/code/core/Mage/Sales/sql/sales_setup/upgrade-


$bestsellersTables = array($installer->getTable('sales/bestsellers_aggregated_daily'),

foreach ($bestsellersTables as $table) {
            'type'     => Varien_Db_Ddl_Table::TYPE_TEXT,
            'length'   => 32,
            'default'  => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
            'nullable' => false,
            'after'    => 'product_id',
            'comment'  => 'Product Type Id'


Often its just that Cache was not cleaned after pulling/adding Magento modifications. If this not the case I would recommend to set the value of "sales_setup" from back to in table core_resource


Rename your file app/etc/local.xml to app/etc/local.xmlBKP and run the install process using the data in this one.

Then remove local.xml that was automatically generated and rename the file app/etc/local.xmlBKP to app/etc/local.xml again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.