本文整理汇总了PHP中Varien_Data_Collection类的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Collection类的具体用法?PHP Varien_Data_Collection怎么用?PHP Varien_Data_Collection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Varien_Data_Collection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRewriteCollection
/**
* Retrieve a collection of all rewrites
*
* @author FireGento Team <team@firegento.com>
* @copyright 2013 FireGento Team (http://firegento.com). All rights served.
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
*/
public function getRewriteCollection()
{
$collection = new Varien_Data_Collection();
$rewrites = $this->_loadRewrites();
foreach ($rewrites as $rewriteNodes) {
foreach ($rewriteNodes as $n) {
$nParent = $n->xpath('..');
$module = (string) $nParent[0]->getName();
$nSubParent = $nParent[0]->xpath('..');
$component = (string) $nSubParent[0]->getName();
if (!in_array($component, array('blocks', 'helpers', 'models'))) {
continue;
}
$pathNodes = $n->children();
foreach ($pathNodes as $pathNode) {
$path = (string) $pathNode->getName();
$completePath = $module . '/' . $path;
$rewriteClassName = (string) $pathNode;
$instance = Mage::getConfig()->getGroupedClassName(substr($component, 0, -1), $completePath);
$collection->addItem(new Varien_Object(array('path' => $completePath, 'rewrite_class' => $rewriteClassName, 'active_class' => $instance, 'status' => $instance == $rewriteClassName)));
}
}
}
return $collection;
}
示例2: getTestResultsCollection
public function getTestResultsCollection()
{
if (is_null($this->_testResultsCollection)) {
$collection = new Varien_Data_Collection();
foreach($this->_getCheckMethods() as $method => $title) {
$statusClass = 'success-msg';
try {
$response = $this->_performCheck($method);
}
catch (Exception $e) {
$response = $e->getMessage();
$statusClass = 'error-msg';
}
$collection->addItem(
new Varien_Object(array('title' => $title, 'response' => $response, 'result' => $statusClass))
);
}
$this->_testResultsCollection = $collection;
}
return $this->_testResultsCollection;
}
示例3: _prepareCollection
public function _prepareCollection()
{
/*Vamos a crear los campos que futuramente va a almacenar, pero aun no los vamos a tomar de la BBDD
* por comodidad y ver como queda y tener algunos datos de ejemplo*/
/*Creamos los datos de ejemplo*/
$thing_1 = new Varien_Object();
$thing_1->setCampaignId(1)->setNumReg(200)->setNombreLista('Lista de chicas')->setFechaCreacion('2012-03-14')->setDescripcion('Descripción de la primera lista')->setNameList('SMS_linstachicas_388232.csv');
$thing_2 = new Varien_Object();
$thing_2->setCampaignId(2);
$thing_2->setNumReg(200);
$thing_2->setNombreLista('Lista de chicos');
$thing_2->setFechaCreacion('2012-03-13');
$thing_2->setDescripcion('Descripción de la segunda lista');
$thing_2->setNameList('SMS_linstachicos_384562.csv');
$thing_3 = new Varien_Object();
$thing_3->setCampaignId(3);
$thing_3->setNumReg(200);
$thing_3->setNombreLista('Lista de compradores');
$thing_3->setFechaCreacion('2012-03-12');
$thing_3->setDescripcion('Descripción de la tercera lista');
$thing_3->setNameList('SMS_linstacompradores_198232.csv');
$collectionDemo = new Varien_Data_Collection();
$collectionDemo->addItem($thing_1)->addItem($thing_2)->addItem($thing_3);
/* Fin de los datos de ejemplo*/
$this->setCollection($collectionDemo);
return parent::_prepareCollection();
}
示例4: _prepareCollection
protected function _prepareCollection()
{
$sort = $this->getParam('sort', $this->_defaultSort);
$dir = $this->getParam('dir', $this->_defaultDir);
$files = $this->_helper->getLogFiles();
if (isset($sort) && !empty($files) && isset($files[0][$sort])) {
usort($files, function ($a, $b) use($sort, $dir) {
$a = $a[$sort];
$b = $b[$sort];
if (is_numeric($a)) {
return $dir == 'asc' ? $a - $b : $b - $a;
} else {
return $dir == 'asc' ? strcmp($a, $b) : -strcmp($a, $b);
}
});
}
$collection = new Varien_Data_Collection();
foreach ($files as $file) {
$item = new Varien_Object();
$item->setIdFieldName('filename');
$item->setFilename($file['filename']);
$item->setFilesize($this->_helper->humanFilesize($file['filesize']));
$item->setLines($file['lines']);
$collection->addItem($item);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
示例5: _apply
/**
* Apply the Vimeo short code
*
* @param string &$content
* @param Fishpig_Wordpress_Model_Post_Abstract $object
* @return void
*/
protected function _apply(&$content, Fishpig_Wordpress_Model_Post_Abstract $object)
{
if (($shortcodes = $this->_getShortcodes($content)) !== false) {
foreach ($shortcodes as $it => $shortcode) {
$args = $shortcode->getParams();
if (!$args->getColumns()) {
$args->setColumns(3);
}
if (!$args->getSize()) {
$args->setSize('thumbnail');
}
if (!$args->getLink()) {
$args->setLink('attachment');
}
if ($args->getPostId()) {
if ($args->getPostId() !== $params['object']->getId()) {
$post = Mage::getModel('catalog/post')->load($args->getPostId());
}
}
if (($ids = trim($args->getIds(), ',')) !== '') {
$images = new Varien_Data_Collection();
foreach (explode(',', $ids) as $imageId) {
$image = Mage::getModel('wordpress/image')->load($imageId);
if ($image->getId()) {
$images->addItem($image);
}
}
} else {
$images = $object->getImages();
}
$html = $this->_createBlock('wordpress/template')->setImageCollection($images)->setColumns($args->getColumns())->setPost($object)->setSize($args->getSize())->setLink($args->getLink())->setGalleryIt($it + 1)->setTemplate('wordpress/shortcode/gallery.phtml')->setAfterGalleryScript(Mage::helper('wp_addon_lightboxgallery')->getAfterGalleryScript($it + 1))->toHtml();
$content = str_replace($shortcode->getHtml(), $html, $content);
}
}
}
示例6: _prepareCollection
protected function _prepareCollection()
{
// Build a collection representing each data feed for each website
$collection = new Varien_Data_Collection();
// Iterate websites and check configuration
$websites = Mage::app()->getWebsites(false, true);
foreach ($websites as $website) {
// Grab id from website
$websiteId = $website->getId();
// Create Website Row in Grid
if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled') == 'enabled') {
// Lookup configuration for this site
$feedTypes = '';
foreach (Mybuys_Connector_Model_Generatefeeds::getFeedTypes() as $curFeedType) {
if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/feedsenabled/' . $curFeedType) == 'enabled') {
if (strlen($feedTypes) > 0) {
$feedTypes .= ', ';
}
$feedTypes .= $curFeedType;
}
}
$sftpUser = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/username');
$sftpDestination = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/hostname');
// Create and save grid item
$newItem = $collection->getNewEmptyItem();
$newItem->setData(array('id' => $website->getId(), 'website_name' => $website->getName(), 'website_code' => $website->getCode(), 'feeds' => $feedTypes, 'sftp_destination' => $sftpDestination, 'sftp_user' => $sftpUser));
$collection->addItem($newItem);
}
}
$this->setCollection($collection);
return $this;
}
示例7: _prepareColumns
protected function _prepareColumns()
{
try {
$collection = $this->_createCollection();
$collection->setPageSize(1);
$collection->load();
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($this->__('An error occured rendering the grid: ' . $e->getMessage()));
Mage::logException($e);
$collection = new Varien_Data_Collection();
}
$config = $this->_getReport()->getGridConfig();
$filterable = $config->getFilterable();
$items = $collection->getItems();
if (count($items)) {
$item = reset($items);
foreach ($item->getData() as $key => $val) {
$isFilterable = false;
if (isset($filterable[$key])) {
$isFilterable = $filterable[$key];
} elseif (in_array($key, $filterable)) {
$isFilterable = 'adminhtml/widget_grid_column_filter_text';
}
$this->addColumn($key, array('header' => Mage::helper('core')->__($key), 'index' => $key, 'filter' => $isFilterable, 'sortable' => true));
}
}
return parent::_prepareColumns();
}
示例8: getGalleryImages
public function getGalleryImages()
{
if ($this->_all === null) {
if (class_exists('FlintDigital_SimpleProductData_Block_Product_View_Media')) {
$block = new FlintDigital_SimpleProductData_Block_Product_View_Media();
$collection = $block->getGalleryImages();
} else {
$collection = parent::getGalleryImages();
}
if (empty($collection) || $collection->getSize() == 0) {
$productMediaConfig = Mage::getModel('catalog/product_media_config');
$image = $this->getProduct()->getImage();
if ($image != 'no_selection') {
$img['url'] = $productMediaConfig->getMediaUrl($image);
$img['id'] = null;
$img['path'] = $productMediaConfig->getMediaPath($image);
$collection = new Varien_Data_Collection();
$collection->addItem(new Varien_Object($img));
}
}
$videosInit = new IWD_Productvideo_Block_Frontend_Init();
$this->_all = new Varien_Data_Collection();
if ($videosInit->getThumbnailsPosition() == 'before') {
$this->_completeCollectionWithVideo();
}
foreach ($collection as $item) {
$this->_all->addItem($item);
}
if ($videosInit->getThumbnailsPosition() == 'after') {
$this->_completeCollectionWithVideo();
}
}
return $this->_all;
}
示例9: 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;
}
示例10: _prepareCollection
/**
* Prepare grid collection
*/
protected function _prepareCollection()
{
$collection = new Varien_Data_Collection();
$layout = $this->getLayout();
$update = $layout->getUpdate();
$design = Mage::getSingleton('core/design_package');
$layoutXML = $update->getFileLayoutUpdatesXml('frontend', $design->getPackageName(), $design->getTheme('layout'), 0);
$xpath = $layoutXML->xpath('//action[@method="setEsi"]');
foreach ($xpath as $x) {
$esi = new Varien_Object();
$handle = $x->xpath('ancestor::node()[last()-2]');
$handleName = $handle[0]->label ? $handle[0]->label : $handle[0]->getName();
$parentBlock = $x->xpath('parent::*');
$parentBlockName = $parentBlock[0]->getAttribute('name');
$parentBlockDescription = $parentBlock[0]->getAttribute('description');
$cacheType = $x->params->cache_type ? $x->params->cache_type : "global";
$esi->setId($parentBlockName);
$esi->setHandle($handleName);
$esi->setBlockName($parentBlockName);
$esi->setDescription($parentBlockDescription);
$esi->setCacheType($cacheType);
try {
$collection->addItem($esi);
} catch (Exception $e) {
Mage::logException($e);
}
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
示例11: __construct
public function __construct()
{
parent::__construct();
$this->setTemplate('order-approval/cart.phtml');
$approverId = Mage::getSingleton('customer/session')->getCustomer()->getId();
$groups = Mage::getResourceModel('customer/group_collection')->addFieldToFilter('approver_id', $approverId)->load();
$_customers = array();
foreach ($groups as $group) {
$_customers += Mage::getResourceModel('customer/customer_collection')->addNameToSelect()->addAttributeToFilter('group_id', $group->getId())->getItems();
}
$_customers += Mage::getResourceModel('customer/customer_collection')->addNameToSelect()->addAttributeToFilter('approver', $approverId)->getItems();
$customers = new Varien_Data_Collection();
foreach ($_customers as $customer) {
$quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore()->getId())->loadByCustomer($customer->getId());
$declinedItems = Mage::getModel('sales/quote_item')->getCollection()->addFieldToFilter('approved', 2)->setQuote($quote);
$approvedItems = Mage::getModel('sales/quote_item')->getCollection()->addFieldToFilter('approved', 1)->setQuote($quote);
$unapprovedItemsNumber = count($quote->getItemsCollection()) - count($approvedItems) - count($declinedItems);
if ($unapprovedItemsNumber) {
$customer->setUnapprovedItemsNumber($unapprovedItemsNumber);
$customers->addItem($customer);
}
}
$this->setCustomers($customers);
Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('root')->setHeaderTitle(Mage::helper('orderapproval')->__('Carts of customers'));
}
示例12: processGroup
public function processGroup($collection)
{
$items = null;
if ($collection && $collection->getSize() > 0) {
$items = new Varien_Data_Collection();
//$items->clear();
$_groupId = 0;
$_item = null;
$_groupItem = array();
$_groupQty = array();
foreach ($collection as $item) {
$product = Mage::getModel('catalog/product')->load($item->getProductId());
$_groupItem = array('product_name' => $product->getName(), 'product_id' => $item->getProductId(), 'sku' => $item->getSku(), 'product_qty' => $item->getQty(), 'product_qty_invoiced' => $item->getQtyInvoiced(), 'product_qty_shipped' => $item->getQtyShipped(), 'product_qty_refunded' => $item->getQtyRefunded(), 'price' => $item->getPrice(), 'wrap_id' => $item->getId());
$_groupItem = $this->_appendItem($_groupItem, $item);
if ($_groupId != $item->getGroupId()) {
$_item = clone $item;
$_groupId = $item->getGroupId();
$_item->setGroupItem(array($_groupItem));
$items->addItem($_item);
} else {
$_groupItem = $_item->getGroupItem();
$_groupItem[] = $_groupItem;
$_item->setGroupItem($_groupItem);
}
}
}
return $items;
}
示例13: getSearchResultCollection
private function getSearchResultCollection()
{
$collection = new Varien_Data_Collection();
$index = Mage::helper('searchindex/index')->getIndex('mage_catalog_product');
$storeId = $this->getStoreId();
if (($query = $this->getRequest()->getParam('q')) && $index) {
$engine = Mage::helper('searchindex')->getSearchEngine();
$start = microtime(true);
try {
$result = $engine->query($query, $storeId, $index);
} catch (Exception $e) {
try {
$engine = Mage::getModel('searchsphinx/engine_fulltext');
$result = $engine->query($query, $storeId, $index);
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
$result = array();
}
}
$end = microtime(true);
$this->searchTime = round($end - $start, 4);
foreach ($result as $productId => $relevance) {
$varienObject = new Varien_Object();
$varienObject->addData(array('id' => $productId, 'relevance' => $relevance));
$collection->addItem($varienObject);
}
$this->resultSize = $collection->getSize();
}
return $collection;
}
示例14: _prepareCollection
/**
* Collection object set up
*/
protected function _prepareCollection()
{
$collection = new Varien_Data_Collection();
foreach (Mage_Api2_Model_Auth_User::getUserTypes() as $type => $label) {
$collection->addItem(new Varien_Object(array('user_type_name' => $label, 'user_type_code' => $type)));
}
$this->setCollection($collection);
}
示例15: _prepareCollection
/**
* Prepare grid collection
*/
protected function _prepareCollection()
{
$collection = new Varien_Data_Collection();
foreach (Mage::app()->getCacheInstance()->getTypes() as $type) {
$collection->addItem($type);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}