I am facing an issue regarding magento product collection as I have some additional product attribute and use general way to get product collection like:

Mage::getModel('catalog/product')->getCollection(); in one of my function. Selecting attribute with '*' that is all the attributes.

One more thing the Flat Catalog Product is set to "Yes".

Everything is working fine as I print the query using getSelect(), Its showing that all the data comes from the catalog_product_flat_1 table.

But when I am using the same way (function) in my another controller using ajax, The Query is not getting data from flat table, Its showing EAV tables using joins and show me error like:

ERROR 1054: Unknown column 'capacity' in 'field list'


List.php Block of Catalog product:

public function loadProductInfo($category){
    $_productCollection_new = Mage::getModel('catalog/product')
        ->getCollection()->addFieldToFilter('visibility', 4)//->setStoreId($store_id = Mage::app()->getStore()->getId())
        ->addAttributeToFilter('equipment_status',array('in' => array(820,822)))
        ->addAttributeToFilter('is_option', '0')
        ->addAttributeToSelect('*')->joinField('is_in_stock', 'cataloginventory/stock_item', 'is_in_stock', 'product_id=entity_id', 'is_in_stock=1', '{{table}}.stock_id=1', 'left')
        ->addFieldToFilter('condition', array('in' => array(812)));
    $cond = array(
        '{{table}}.use_config_manage_stock = 0 AND {{table}}.manage_stock=1 AND {{table}}.is_in_stock=1',
        '{{table}}.use_config_manage_stock = 0 AND {{table}}.manage_stock=0',

    $cond[] = '{{table}}.use_config_manage_stock = 1 AND {{table}}.is_in_stock=1';

        '(' . join(') OR (', $cond) . ')'


    return $_productCollection;

Calling this in phtml like:


put the ajax code at the end of the phtml file, create custom module and controller and put the same function inside that having some additional filter.

Why this issue with ajax? Any suggestions?

  • I think would be hard to understand the issue without more details: for example, you can add the code in the Ajax controller – Enzo Perrotta Aug 21 '19 at 13:58

Your Answer

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

Browse other questions tagged or ask your own question.