当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Data_Collection::toArray方法代码示例

本文整理汇总了PHP中Varien_Data_Collection::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Collection::toArray方法的具体用法?PHP Varien_Data_Collection::toArray怎么用?PHP Varien_Data_Collection::toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Data_Collection的用法示例。


在下文中一共展示了Varien_Data_Collection::toArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: listing

 /**
  * List all Cache types
  *
  * @return  MageHack_MageConsole_Model_Abstract
  */
 public function listing()
 {
     $collection = new Varien_Data_Collection();
     foreach (Mage::app()->getCacheInstance()->getTypes() as $type) {
         $collection->addItem($type);
     }
     if (!$collection->count()) {
         $message = 'This is strange, we did not find any cache types.';
         $this->setType(self::RESPONSE_TYPE_MESSAGE);
         $this->setMessage($message);
     } else {
         if ($collection->count() > 0) {
             $values = $collection->toArray();
             if (is_array($values) && $values['totalRecords'] > 0) {
                 foreach ($values['items'] as $row) {
                     if (is_array($row)) {
                         $_values[] = array_intersect_key($row, $this->_attrToShow);
                     }
                 }
                 if (Mage::getStoreConfig('admin/mageconsole/html_tables') != 1) {
                     $this->setType(self::RESPONSE_TYPE_MESSAGE);
                     $message = Mage::helper('mageconsole')->createTable($_values, true, $this->_columnWidths);
                     $this->setMessage($message);
                 } else {
                     $this->setMessage($_values);
                     $this->setType(self::RESPONSE_TYPE_LIST);
                 }
             }
         }
     }
     return $this;
 }
开发者ID:keywork,项目名称:MageConsole,代码行数:37,代码来源:Cache.php

示例2: getCsv

 public function getCsv(Varien_Data_Collection $collection, $getAll = false)
 {
     $csv = '';
     $collectionData = $collection->toArray();
     $type = $collection->getEntity()->getType();
     // first pass, collect header
     $_columns = array();
     $_ignoredColumns = array();
     // speedup
     foreach ($collectionData as $item) {
         foreach ($item as $key => $value) {
             if (gettype($value) == 'Array') {
                 $_ignoredColumns[] = $key;
             }
             if ($getAll) {
                 $_columns[] = $key;
             } else {
                 if (!in_array($key, $_columns) && !in_array($key, $_ignoredColumns)) {
                     $attr = Mage::getModel('eav/entity_attribute')->loadByCode($type, $key);
                     // get rid of non-attributes
                     if (!count($attr->getData())) {
                         $_ignoredColumns[] = $key;
                     } else {
                         $_columns[] = $key;
                     }
                 }
             }
         }
     }
     $data = array();
     // add headers as first row
     foreach ($_columns as $column) {
         $data[] = "\"{$column}\"";
     }
     $csv .= implode(',', $data) . "\n";
     // second pass, concatenate data content
     foreach ($collectionData as $item) {
         $data = array();
         foreach ($_columns as $column) {
             $data[] = '"' . str_replace(array('"', '\\'), array('""', '\\\\'), $item[$column]) . '"';
         }
         $csv .= implode(',', $data) . "\n";
     }
     return $csv;
 }
开发者ID:keywork,项目名称:MageConsole,代码行数:45,代码来源:Data.php

示例3: _getCollectionData

 /**
  *
  * @param Varien_Data_Collection $collection
  * @return array
  */
 protected function _getCollectionData(Varien_Data_Collection $collection)
 {
     return array_values($collection->toArray());
 }
开发者ID:styladev,项目名称:magentoStylaConnect,代码行数:9,代码来源:V1.php


注:本文中的Varien_Data_Collection::toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。