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


PHP Collection::load方法代码示例

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


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

示例1: testAddLinkAttributeToFilterNoResults

 /**
  * @magentoDataFixture Magento/Catalog/_files/products_crosssell.php
  */
 public function testAddLinkAttributeToFilterNoResults()
 {
     $om = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $link = $om->get('\\Magento\\Catalog\\Model\\Product\\Link')->useCrossSellLinks();
     $this->collection->setLinkModel($link);
     $this->collection->addLinkAttributeToFilter('position', array('from' => 2, 'to' => 3));
     $product = $om->get('Magento\\Catalog\\Model\\Product')->load(2);
     $this->collection->setProduct($product);
     $this->collection->load();
     $this->assertCount(0, $this->collection->getItems());
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:CollectionTest.php

示例2: testSetOrder

 /**
  * @dataProvider setOrderDataProvider
  */
 public function testSetOrder($order, $expectedOrder)
 {
     $this->_collection->setOrder($order);
     $this->_collection->load();
     // perform real SQL query
     $selectOrder = $this->_collection->getSelect()->getPart(\Zend_Db_Select::ORDER);
     foreach ($expectedOrder as $field) {
         $orderBy = array_shift($selectOrder);
         $this->assertArrayHasKey(0, $orderBy);
         $this->assertTrue(false !== strpos($orderBy[0], $field), 'Ordering by same column more than once is restricted by multiple RDBMS requirements.');
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:CollectionTest.php

示例3: _prepareData

 /**
  * @return $this
  */
 protected function _prepareData()
 {
     $product = $this->_coreRegistry->registry('product');
     /* @var $product \Magento\Catalog\Model\Product */
     $this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect('required_options')->setPositionOrder()->addStoreFilter();
     if ($this->moduleManager->isEnabled('Magento_Checkout')) {
         $this->_addProductAttributesAndPrices($this->_itemCollection);
     }
     $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
     $this->_itemCollection->load();
     foreach ($this->_itemCollection as $product) {
         $product->setDoNotUseCategoryId(true);
     }
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:18,代码来源:Related.php

示例4: _prepareData

 /**
  * @return $this
  */
 protected function _prepareData()
 {
     $product = $this->_coreRegistry->registry('product');
     /* @var $product \Magento\Catalog\Model\Product */
     $this->_itemCollection = $product->getUpSellProductCollection()->setPositionOrder()->addStoreFilter();
     if ($this->moduleManager->isEnabled('Magento_Checkout')) {
         $this->_addProductAttributesAndPrices($this->_itemCollection);
     }
     $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
     $this->_itemCollection->load();
     /**
      * Updating collection with desired items
      */
     $this->_eventManager->dispatch('catalog_product_upsell', ['product' => $product, 'collection' => $this->_itemCollection, 'limit' => null]);
     foreach ($this->_itemCollection as $product) {
         $product->setDoNotUseCategoryId(true);
     }
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:22,代码来源:Upsell.php


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