本文整理汇总了PHP中Magento\Catalog\Model\ResourceModel\Product\Collection::setVisibility方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::setVisibility方法的具体用法?PHP Collection::setVisibility怎么用?PHP Collection::setVisibility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\ResourceModel\Product\Collection
的用法示例。
在下文中一共展示了Collection::setVisibility方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareCollection
/**
* Premare block data
* @return $this
*/
protected function _prepareCollection()
{
$post = $this->_coreRegistry->registry('current_blog_post');
$this->_itemCollection = $this->_productCollectionFactory->create()->addAttributeToSelect('required_options')->addStoreFilter()->addAttributeToFilter('entity_id', array('in' => $post->getRelatedProductIds() ?: array(0)));
if ($this->_moduleManager->isEnabled('Magento_Checkout')) {
$this->_addProductAttributesAndPrices($this->_itemCollection);
}
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->setPageSize((int) $this->_scopeConfig->getValue('mfblog/post_view/related_products/number_of_products', \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product) {
$product->setDoNotUseCategoryId(true);
}
return $this;
}
示例2: _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;
}
示例3: _prepareCollection
/**
* Premare block data
* @return $this
*/
protected function _prepareCollection()
{
$post = $this->getPost();
$this->_itemCollection = $post->getRelatedProducts()->addAttributeToSelect('required_options');
if ($this->_moduleManager->isEnabled('Magento_Checkout')) {
$this->_addProductAttributesAndPrices($this->_itemCollection);
}
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->setPageSize((int) $this->_scopeConfig->getValue('mfblog/post_view/related_products/number_of_products', \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
$this->_itemCollection->getSelect()->order('rl.position', 'ASC');
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product) {
$product->setDoNotUseCategoryId(true);
}
return $this;
}
示例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;
}
示例5: setVisibility
/**
* Set product visibility filter for enabled products
*
* @param array $visibility
* @return $this
*/
public function setVisibility($visibility)
{
$this->addFieldToFilter('visibility', $visibility);
return parent::setVisibility($visibility);
}