我试图让Magento在产品网格中展示可配置产品的库存基础 . 显然,可配置产品没有数量,所以我的意思是我想修改产品数量的显示方式,类似于:

if (product != configurable) 
{qty = do what it normally does}

else 
{get collection of associated products.
qty = sum of qty of that collection;}

我找到了几个参考数量的控制器,例如这个Block / Catalog / Product / grid.php

protected function _prepareCollection()
{
    $collection = $this->getCollection();
    if($queryString = $this->getQueryStr()) {
        $collection = Mage::Helper('enhancedgrid')
            ->getSearchCollection($queryString, $this->getRequest());
    }
    if(!$collection) {
        $collection = Mage::getModel('catalog/product')->getCollection();
    }
    $store = $this->_getStore();
    $collection 
        ->joinField('qty',
            'cataloginventory/stock_item',
            'qty',
            'product_id=entity_id',
            '{{table}}.stock_id=1',
            'left');
    $collection->addAttributeToSelect('sku');

但是我无法在任何地方找到它 .

如果这些都不可能 - 只需添加'库存可用性'结果即可 .

编辑:^这不起作用,因为可配置产品是“IN STOCK”但所有相关产品都是“缺货”

谢谢