製品グリッドに構成可能な製品の在庫ベースを表示するように 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');
しかし、私はそれについてどこにも行くことができませんでした。
これらのいずれも可能でない場合は、「在庫状況」の結果を追加するだけで十分です。
編集: ^構成可能な製品は「在庫あり」ですが、関連するすべての製品は「在庫なし」であるため、これは機能しません。
ありがとう