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


PHP Varien_Data_Collection::addItem方法代码示例

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


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

示例1: _getProductCollection

 protected function _getProductCollection()
 {
     $page = Mage::getBlockSingleton('page/html_pager')->getCurrentPage();
     date_default_timezone_set(Mage::getStoreConfig('general/locale/timezone'));
     $todayDate = strftime("%Y-%m-%d", Mage::app()->getLocale()->storeTimeStamp(Mage::app()->getStore()->getId()));
     $storeId = Mage::app()->getStore()->getId();
     $product = Mage::getModel('catalog/product');
     $this->_productCollection = $product->setStoreId($storeId)->getCollection()->addAttributeToSelect(array('name', 'status', 'price', 'special_price', 'small_image', 'required_options', 'special_from_date', 'special_to_date'), 'inner')->joinField('stock_status', 'cataloginventory/stock_status', 'stock_status', 'product_id=entity_id', array('stock_status' => Mage_CatalogInventory_Model_Stock_Status::STATUS_IN_STOCK, 'website_id' => Mage::app()->getWebsite()->getWebsiteId()))->addAttributeToFilter('special_price', array('gt' => 0), 'left')->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))->addAttributeToFilter('special_to_date', array('or' => array(0 => array('date' => true, 'from' => $todayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToSort('created_at', 'desc')->addFinalPrice()->addStoreFilter()->setPageSize($this->getProductsLimit())->setCurPage($page)->addAttributeToFilter('status', 1)->addUrlRewrite();
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->_productCollection);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($this->_productCollection);
     $checkedProducts = new Varien_Data_Collection();
     foreach ($this->_productCollection as $k => $p) {
         $p = $p->loadParentProductIds();
         $parentIds = $p->getData('parent_product_ids');
         if (is_array($parentIds) && !empty($parentIds)) {
             if (!$checkedProducts->getItemById($parentIds[0])) {
                 $parentProduct = Mage::getModel('catalog/product')->setStoreId($storeId)->load($parentIds[0]);
                 if ($parentProduct->isVisibleInCatalog()) {
                     $checkedProducts->addItem($parentProduct);
                 }
             }
         } else {
             if (!$checkedProducts->getItemById($k)) {
                 $checkedProducts->addItem($p);
             }
         }
         if (count($checkedProducts) >= $this->getProductsLimit()) {
             break;
         }
     }
     return $this->_productCollection;
 }
开发者ID:kanotest15,项目名称:cbmagento,代码行数:32,代码来源:Sale.php

示例2: _getProductCollection

 protected function _getProductCollection()
 {
     $storeId = Mage::app()->getStore()->getId();
     $product = Mage::getModel('catalog/product');
     $visibility = array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG);
     $this->_productCollection = $product->setStoreId($storeId)->getCollection()->addAttributeToSelect(array('name', 'price', 'small_image'), 'inner')->addAttributeToSelect(array('special_price'), 'left')->setOrder('created_at', 'desc')->addFieldToFilter('type_id', 'bundle')->setPageSize($this->getProductsLimit())->addAttributeToFilter('visibility', $visibility);
     $checkedProducts = new Varien_Data_Collection();
     foreach ($this->_productCollection as $k => $p) {
         $p = $p->loadParentProductIds();
         $parentIds = $p->getData('parent_product_ids');
         if (is_array($parentIds) && !empty($parentIds)) {
             if (!$checkedProducts->getItemById($parentIds[0])) {
                 $parentProduct = Mage::getModel('catalog/product')->setStoreId($storeId)->load($parentIds[0]);
                 if ($parentProduct->isVisibleInCatalog()) {
                     $checkedProducts->addItem($parentProduct);
                 }
             }
         } else {
             if (!$checkedProducts->getItemById($k)) {
                 $checkedProducts->addItem($p);
             }
         }
         if (count($checkedProducts) >= $this->getProductsLimit()) {
             break;
         }
     }
     return $this->_productCollection;
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:28,代码来源:Combo.php

示例3: testRemoveAllItems

 public function testRemoveAllItems()
 {
     $model = new Varien_Data_Collection();
     $model->addItem(new Varien_Object());
     $model->addItem(new Varien_Object());
     $this->assertCount(2, $model->getItems());
     $model->removeAllItems();
     $this->assertEmpty($model->getItems());
 }
开发者ID:nemphys,项目名称:magento2,代码行数:9,代码来源:CollectionTest.php

示例4: _processPeriod

 private function _processPeriod($collection, $period)
 {
     switch ($period) {
         case 'day':
             return $collection;
             break;
         case 'month':
             $index = 1;
             break;
         case 'year':
             $index = 0;
             break;
     }
     $fields = array('abandoned_carts_num', 'abandoned_carts_price', 'abandoned_items_num', 'recovered_carts_num', 'ordered_carts_num', 'ordered_carts_price', 'ordered_items_num', 'av_back_time', 'target_letter_step');
     $date = $collection->getFirstItem()->getDate();
     $dateArray = explode('-', $date);
     $val = $dateArray[$index];
     $returnCollection = new Varien_Data_Collection();
     $object = new Varien_Object();
     //$counterABT=0;
     $counterTLS = 0;
     foreach ($collection as $item) {
         $dateArray = explode('-', $item->getDate());
         if ($dateArray[$index] != $val) {
             $val = $dateArray[$index];
             /*if($counterABT)
               {
                   $object->setData('av_back_time',$object->getData('av_back_time')/$counterABT);
               }*/
             if ($counterTLS) {
                 $object->setData('target_letter_step', $object->getData('target_letter_step') / $counterTLS);
             }
             $returnCollection->addItem($object);
             $object = new Varien_Object();
             $counterABT = 0;
             $counterTLS = 0;
         }
         $object->setDate($item->getDate());
         //if($item->getData('av_back_time'))$counterABT++;
         if ($item->getData('target_letter_step')) {
             $counterTLS++;
         }
         foreach ($fields as $field) {
             $object->setData($field, $object->getData($field) + $item->getData($field));
         }
     }
     /*if($counterABT)
       {
           $object->setData('av_back_time',$object->getData('av_back_time')/$counterABT);
       }*/
     if ($counterTLS) {
         $object->setData('target_letter_step', $object->getData('target_letter_step') / $counterTLS);
     }
     $returnCollection->addItem($object);
     return $returnCollection;
 }
开发者ID:rajarshc,项目名称:Rooja,代码行数:56,代码来源:Grid.php

示例5: _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;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:32,代码来源:Grid.php

示例6: 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

示例7: _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();
 }
开发者ID:mwin007,项目名称:Magento-Varnish,代码行数:33,代码来源:Grid.php

示例8: __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'));
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:25,代码来源:Customercart.php

示例9: 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;
 }
开发者ID:hoadaithieu,项目名称:mage-giftwrap,代码行数:28,代码来源:Wrap.php

示例10: 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;
 }
开发者ID:flintdigital,项目名称:mage-mod-product-videos-iwd,代码行数:34,代码来源:Media.php

示例11: _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();
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:28,代码来源:Grid.php

示例12: _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();
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:27,代码来源:Grid.php

示例13: 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;
	}
开发者ID:riteshsahu1981,项目名称:captainkyso,代码行数:26,代码来源:Debug.php

示例14: _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);
         }
     }
 }
开发者ID:LiamMcArthur,项目名称:extension-fishpig-wordpress-integration,代码行数:42,代码来源:Gallery.php

示例15: 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;
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:30,代码来源:Speed.php


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