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


PHP Collection::addIdFilter方法代码示例

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


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

示例1: testAddTierPriceData

 /**
  * @magentoDataFixture Magento/Catalog/Model/Resource/_files/product_simple.php
  */
 public function testAddTierPriceData()
 {
     $this->_collection->setFlag('tier_price_added', false);
     $this->_collection->addIdFilter(2);
     $this->assertInstanceOf('\\Magento\\Catalog\\Model\\Resource\\Product\\Collection', $this->_collection->addTierPriceData());
     $tierPrice = $this->_collection->getFirstItem()->getDataByKey('tier_price');
     $this->assertEquals($this->_groupManagement->getNotLoggedInGroup()->getId(), current($tierPrice)['cust_group']);
     $this->assertEquals($this->_groupManagement->getAllCustomersGroup()->getId(), next($tierPrice)['cust_group']);
     $this->assertTrue($this->_collection->getFlag('tier_price_added'));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:CollectionTest.php

示例2: testAddTierPriceData

 /**
  * @magentoDataFixture Magento/Catalog/Model/Resource/_files/product_simple.php
  */
 public function testAddTierPriceData()
 {
     $this->_collection->setFlag('tier_price_added', false);
     $this->_collection->addIdFilter(2);
     $this->assertInstanceOf('\\Magento\\Catalog\\Model\\Resource\\Product\\Collection', $this->_collection->addTierPriceData());
     $tierPrice = $this->_collection->getFirstItem()->getDataByKey('tier_price');
     $this->assertEquals(CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, current($tierPrice)['cust_group']);
     $this->assertEquals(CustomerGroupServiceInterface::CUST_GROUP_ALL, next($tierPrice)['cust_group']);
     $this->assertTrue($this->_collection->getFlag('tier_price_added'));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:CollectionTest.php

示例3: getProducts

 /**
  * Get products by IDs
  * @param array    $productIds
  * @param null|int $chunkSize
  * @param bool     $filterVisibility
  * @return \Magento\Catalog\Model\Resource\Product\Collection
  */
 public function getProducts(array $productIds = [], $chunkSize = null, $filterVisibility = true)
 {
     $this->_productCollection->addAttributeToSelect('sku')->addAttributeToSelect($this->_config->getProductAttributes())->addAttributeToSelect('status')->addAttributeToSelect('visibility');
     if ($filterVisibility) {
         $this->_productCollection->addAttributeToFilter('visibility', ['in' => [Visibility::VISIBILITY_IN_CATALOG, Visibility::VISIBILITY_BOTH]])->addAttributeToFilter('status', Status::STATUS_ENABLED);
     }
     if (!empty($productIds)) {
         $this->_productCollection->addIdFilter($productIds);
     }
     if ($chunkSize !== null) {
         $this->_productCollection->setPageSize($chunkSize);
     }
     return $this->_productCollection;
 }
开发者ID:halk,项目名称:recowise-magento2-demo,代码行数:21,代码来源:Product.php


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