1

需要在产品视图页面上按升序获取与可配置产品关联的简单库存 sku。

Result like:

[1] = "S120622006_5";
[2] = "S120622007";
[4] = "S120622008";
[5] = "S120622009";
[6] = "S1206220010";

我的开始 scipt:这会在可配置的情况下获取所有关联的 sku,但这会得到未安排的结果并显示缺货 sku。我只想获取 In stock sku 并按升序排列。

<?php
    $conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
    $col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
?>

<?php
    $count = 1;
    $itemId = array();
    foreach($col as $simple_product){
        $itemId[] = array($simple_product->getSelectLabel() => $simple_product->getSku());
    }

    foreach($itemId as $val){
        foreach($val as $k => $v){
            echo 'Skus['.$count.'] = "'.$v.'";'. "\n";
            $count++;
        }
    };
?>

我很感激任何帮助。

来自 RS 的结果

S1206220010_5 = 
S1206220011_5 = 
S1206220012_5 = 
S120622006_5 = 
S120622007 = 
S120622007_5 = 
S120622008 = 
S120622008_5 = 
S120622009_5 = 
S120622009 = 
S1206220010 = 
S1206220011 = 
4

1 回答 1

0

现在无法测试,但试试这个:

->getCollection()->addFieldToFilter('qty', array('gteq' => 1))

于 2012-12-12T21:55:48.823 回答