1

I have created a new product type and if I create a grouped product it currently will not let me select any products of my new type under associated products. I enabled SQL logging and I see this query:

SELECT 
    `e` . *,
    `links`.`link_id`,
    `link_attribute_position_int`.`value` AS `position`,
    `link_attribute_qty_decimal`.`value` AS `qty`
FROM
    `catalog_product_entity` AS `e`
        LEFT JOIN
    `catalog_product_link` AS `links` ON links.linked_product_id = e.entity_id
        AND links.link_type_id = 3
        AND links.product_id = '4'
        LEFT JOIN
    `catalog_product_link_attribute_int` AS `link_attribute_position_int` ON link_attribute_position_int.link_id = links.link_id
        AND link_attribute_position_int.product_link_attribute_id = '2'
        LEFT JOIN
    `catalog_product_link_attribute_decimal` AS `link_attribute_qty_decimal` ON link_attribute_qty_decimal.link_id = links.link_id
        AND link_attribute_qty_decimal.product_link_attribute_id = '3'
WHERE
    (((`e`.`required_options` != '1') OR (`e`.`required_options` IS NULL)))
    AND (((`e`.`type_id` = 'simple') OR (`e`.`type_id` = 'virtual') OR (`e`.`type_id` = 'downloadable')))
    AND (`e`.`entity_id` != '4')
ORDER BY `e`.`entity_id` DESC
LIMIT 20

I know this is the query getting the products I can select for the grid, but I can't figure out where the code is that builds the WHERE clause. Here is the stack trace for the query:

#1 Magento_Db_Adapter_Pdo_Mysql[Varien_Db_Adapter_Pdo_Mysql]#000000004a3d0c9b00007f76c0d70388#->_debugStat(2, 'SELECT `e`.*, `l...', array(), &Varien_Db_Statement_Pdo_Mysql#000000004
#2 Magento_Db_Adapter_Pdo_Mysql[Varien_Db_Adapter_Pdo_Mysql]#000000004a3d0c9b00007f76c0d70388#->query('SELECT `e`.*, `l...', array()) called at [lib/Zend/Db/Adapter/Abstract.php:734]
#3 Magento_Db_Adapter_Pdo_Mysql[Zend_Db_Adapter_Abstract]#000000004a3d0c9b00007f76c0d70388#->fetchAll('SELECT `e`.*, `l...', array()) called at [lib/Varien/Data/Collection/Db.php:734]
#4 Mage_Catalog_Model_Resource_Product_Link_Product_Collection[Varien_Data_Collection_Db]#000000004a3d0ea500007f76c0d70388#->_fetchAll('SELECT `e`.*, `l...') called at [app/code/core/Mage/E
#5 Mage_Catalog_Model_Resource_Product_Link_Product_Collection[Mage_Eav_Model_Entity_Collection_Abstract]#000000004a3d0ea500007f76c0d70388#->_loadEntities(false, false) called at [app/code/
#6 Mage_Catalog_Model_Resource_Product_Link_Product_Collection[Mage_Eav_Model_Entity_Collection_Abstract]#000000004a3d0ea500007f76c0d70388#->load() called at [app/code/core/Mage/Adminhtml/B
#7 Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group[Mage_Adminhtml_Block_Widget_Grid]#000000004a3d0ebe00007f76c0d70388#->_prepareCollection() called at [app/code/core/Mage/Adminhtm
#8 Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group#000000004a3d0ebe00007f76c0d70388#->_prepareCollection() called at [app/code/core/Mage/Adminhtml/Block/Widget/Grid.php:626]
#9 Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group[Mage_Adminhtml_Block_Widget_Grid]#000000004a3d0ebe00007f76c0d70388#->_prepareGrid() called at [app/code/core/Mage/Adminhtml/Bloc
#10 Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group[Mage_Adminhtml_Block_Widget_Grid]#000000004a3d0ebe00007f76c0d70388#->_beforeToHtml() called at [var/Mage_Core_Block
#11 Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group[Mage_Core_Block_Abstract]#000000004a3d0ebe00007f76c0d70388#->toHtml() called at [app/code/core/Mage
#12 Mage_Core_Block_Text_List#000000004a3d0ef700007f76c0d70388#->_toHtml() called at [var/Mage_Core_Block_Abstract.php:921]
#13 Mage_Core_Block_Text_List[Mage_Core_Block_Abstract]#000000004a3d0ef700007f76c0d70388#->toHtml() called at [app/code/core/Mage/Core/Model/Layout.php:555]
#14 Mage_Core_Model_Layout#000000004a3d0cf300007f76c0d70388#->getOutput() called at [app/code/core/Mage/Core/Controller/Varien/Action.php:390]
#15 Mage_Adminhtml_Catalog_ProductController[Mage_Core_Controller_Varien_Action]#000000004a3d0ce600007f76c0d70388#->renderLayout() called at [app/code/core/Mage/Adminhtml/controllers/Catalo
#16 Mage_Adminhtml_Catalog_ProductController#000000004a3d0ce600007f76c0d70388#->superGroupGridOnlyAction() called at [app/code/core/Mage/Core/Controller/Varien/Action.php:418]
#17 Mage_Adminhtml_Catalog_ProductController[Mage_Core_Controller_Varien_Action]#000000004a3d0ce600007f76c0d70388#->dispatch('superGroupGridOn...') called at [app/code/core/Mage/Core/Contro
#18 Mage_Core_Controller_Varien_Router_Admin[Mage_Core_Controller_Varien_Router_Standard]#000000004a3d0cac00007f76c0d70388#->match(&Mage_Core_Controller_Request_Http#000000004a3d0cc600007f7
#19 Mage_Core_Controller_Varien_Front#000000004a3d0c5400007f76c0d70388#->dispatch() called at [app/code/core/Mage/Core/Model/App.php:354]
#20 Mage_Core_Model_App#000000004a3d0cd800007f76c0d70388#->run(array('scope_code' => '', 'scope_type' => 'store', 'options' => array())) called at [app/Mage.php:684]
#21 Mage::run('', 'store') called at [index.php:87]
  • @ Jason Neumann : Is it working ?? – Gem Jan 10 '17 at 12:05
0

I finally found it. It's set in the config.xml, of course. Its in Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group::_prepareCollection(). The second line gets all the nodes:

Mage::getConfig()->getNode('global/catalog/product/type/grouped/allow_product_types')->children();

Then, after getting all the node names, its added to the query with a simple ->addAttributeToFilter('type_id', $allowProductTypes); call.

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.