本文整理汇总了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'));
}
示例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'));
}
示例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;
}