相关疑难解决方法(0)

在加载后对Magento系列进行排序

Magento集合排序函数(例如Mage_Eav_Model_Entity_Collection_Abstract::addAttributeToSort)通过向ORDER BYSQL select语句添加子句来工作.但是,有时候已经加载了一个集合,并且有必要对集合进行排序.

当然可以使用该toArray($fields)函数,然后使用PHP数组排序函数(本机或用户定义),但这有点笨拙.这也意味着集合中的对象被转换为"哑"值的行,而没有可以/可以用算法等实现的魔法getter/setter.

我想知道是否有更优雅/ Magento-esque方法对系列进行排序.

谢谢,
乔纳森

php arrays sorting collections magento

6
推荐指数
2
解决办法
1万
查看次数

getData不起作用,返回空

我创建了自定义属性,但是当我用我的方法显示它时它不起作用!

看是做...创建我的属性..

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$config = array(
    'position' => 1,
    'required'=> 0,
    'label' => 'Height',
    'type' => 'int',
    'input' => 'text',
    'apply_to' => 'simple,bundle,grouped,configurable'
);

$setup->addAttribute('catalog_product', 'height' , $config);
Run Code Online (Sandbox Code Playgroud)

我收到结帐中的物品清单......

$items = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();

foreach($items as $item){

    echo $item->getSku() .'<br/>'; //just test... and all right!

    echo $item->getHeight() .'<br/>'; //return empty! or....
    echo $item->getData('height') .'<br/>';//return empty!
}
Run Code Online (Sandbox Code Playgroud)

我在后端设置此属性的fiels中的值.

谢谢你的帮助!

magento

1
推荐指数
1
解决办法
3561
查看次数

标签 统计

magento ×2

arrays ×1

collections ×1

php ×1

sorting ×1