本文整理匯總了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;
}