本文整理汇总了PHP中Magento\Catalog\Model\ResourceModel\Product\Collection::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::getItems方法的具体用法?PHP Collection::getItems怎么用?PHP Collection::getItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\ResourceModel\Product\Collection
的用法示例。
在下文中一共展示了Collection::getItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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', ['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());
}
示例2: testAddPriceDataOnSave
/**
* @magentoDataFixture Magento/Catalog/_files/products.php
* @magentoAppIsolation enabled
*/
public function testAddPriceDataOnSave()
{
$this->processor->getIndexer()->setScheduled(false);
$this->assertFalse($this->processor->getIndexer()->isScheduled());
$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Api\\ProductRepositoryInterface');
/** @var \Magento\Catalog\Api\Data\ProductInterface $product */
$product = $productRepository->get('simple');
$this->assertNotEquals(15, $product->getPrice());
$product->setPrice(15);
$productRepository->save($product);
$this->collection->addPriceData(0, 1);
$this->collection->load();
/** @var \Magento\Catalog\Api\Data\ProductInterface[] $product */
$items = $this->collection->getItems();
/** @var \Magento\Catalog\Api\Data\ProductInterface $product */
$product = reset($items);
$this->assertCount(2, $items);
$this->assertEquals(15, $product->getPrice());
}