对自定义属性的Magento排序消失

时间:2011-11-27 01:14:03

标签: magento

使用Magento 1.6

我用getSelect()检查了这个; SQL以我想要的方式在PhpMyAdmin中进行测试并对其进行正确排序,但是,当我的代码中出现foreach时,它正在放弃排序或重新排序。

$ik_collection_charger_plug = Mage::getModel('catalog/category')->load(21); // 21 is the Category ID for the Charging Plugs
$ik_collection_charger_plug = $ik_collection_charger_plug->getProductCollection();

$ik_collection_charger_plug->addAttributeToSelect('charger_plug_group');
$ik_collection_charger_plug->addAttributeToSelect('max_units_charged');
$ik_collection_charger_plug->SetOrder('max_units_charged', 'DESC');

$ik_collection_charger_plug->addFieldToFilter(array(
    array('attribute'=>'charger_plug_group','eq'=>$ik_tray_charger_plug_group),
    ));

    //echo $ik_collection_charger_plug->getSelect();
foreach($ik_collection_charger_plug->getAllIds() as $product_plugs) {
        $_product_plugs = Mage::getModel('catalog/product')->load($product_plugs);
    $ik_product_id_charger_plug = $_product_plugs->getId();
    $ik_plug_charger_plug_group = $_product_plugs->getcharger_plug_group();
    $ik_plug_max_units_charged = $_product_plugs->getmax_units_charged();

    echo "<br />Product ID Charger Plug:&nbsp;";
    print_r($ik_product_id_charger_plug);
    echo "<br />Charging Plug Group:&nbsp;";
    print_r($ik_plug_charger_plug_group);
    echo "<br />Max Units Charged:&nbsp;";
    print_r($ik_plug_max_units_charged);
    echo "<br />Incrementing:&nbsp;";
    print_r($ik_inc);
    }

提前感谢您的帮助!

0 个答案:

没有答案