Magento 如何将不可销售的产品添加到产品集合中
出于某种原因,我需要从一个类别收集的所有产品,包括不出售的产品。但我不确定这是否是magento没有显示它的唯一情况 目前,我得到的所有产品返回的库存和价格等,像正常的产品 收集不是挑选不出售或没有给出价格的产品。这是我们创建的一种不同类型的产品,价格不是快照中的强制选项 现在我想收集这两种产品。 目前,我只得到一个与显示的价格,底部的一个 我试过了Magento 如何将不可销售的产品添加到产品集合中,magento,Magento,出于某种原因,我需要从一个类别收集的所有产品,包括不出售的产品。但我不确定这是否是magento没有显示它的唯一情况 目前,我得到的所有产品返回的库存和价格等,像正常的产品 收集不是挑选不出售或没有给出价格的产品。这是我们创建的一种不同类型的产品,价格不是快照中的强制选项 现在我想收集这两种产品。 目前,我只得到一个与显示的价格,底部的一个 我试过了 <?php class Ubt_Featured_Block_Featured extends Mage_Core_Block_Tem
<?php
class Ubt_Featured_Block_Featured extends
Mage_Core_Block_Template {
private $_itemPerPage = 2;
private $_category_id = 4;
public function allProducts() {
$category = Mage::getModel('catalog/category')->load($this->_category_id);
$_collections = $category->getProductCollection();
$_productCollection = $this->getCollection($_collections); // calling the function that have been created in block page.
return $_productCollection;
}
public function totalPages() {
$category = Mage::getModel('catalog/category')->load(4);
$_collections_count = $category->getProductCollection()->count();
return $number_of_pages = $_collections_count / $this->_itemPerPage;
}
public function getCollection($collection = 'null') {
if ($collection != 'null') {
$collection->addWebsiteFilter();
$collection->addUrlRewrite($this->_category_id);
$collection->addMinimalPrice()->addFinalPrice()->addTaxPercents();
Mage::getSingleton('catalog/product_visibility')
->addVisibleInCatalogFilterToCollection($collection);
Mage::getSingleton('catalog/product_status')
->addVisibleFilterToCollection($collection);
$collection->addAttributeToSelect(array('entity_id', 'sku', 'name', 'short_description',
'description', 'price', 'thumbnail', 'image', 'url_path', 'type_of'), 'inner')
->addAttributeToFilter('is_saleable', array('like' => '0')) ;
$collection->setCurPage(1);
$collection->setPageSize($this->_itemPerPage);
return $collection;
}
}
请建议。多谢各位
这里的区别是,此产品类型没有任何价格输入选项,因此人们无法将其添加到购物车,也无法显示价格。它就像一个cms页面一样。当我们在产品列表页面中单击它时,它会转到产品页面,而不带“添加到购物车”选项。这是从产品清单和所有的工作
但我试着在主页上调用这些产品,其他所有产品都在显示,但不是这个
----config.xml
<?xml version="1.0"?>
<config>
<modules>
<Rik_ReferralProduct>
<version>0.1.0</version>
</Rik_ReferralProduct>
</modules>
<global>
<models>
<referralproduct>
<class>Rik_ReferralProduct_Model</class>
</referralproduct>
</models>
<catalog>
<product>
<type>
<referralproduct translate="label" module="catalog">
<label>Referral Product</label>
<model>referralproduct/product_type_referral</model>
<is_qty>1</is_qty>
<index_data_retreiver>referralproduct/catalogIndex_data_referral</index_data_retreiver>
<composite>0</composite>
</referralproduct>
</type>
</product>
</catalog>
<blocks>
<adminhtml>
<rewrite>
<catalog_product_edit_tabs>Rik_ReferralProduct_Block_Adminhtml_Catalog_Product_Edit_Tabs</catalog_product_edit_tabs>
</rewrite>
</adminhtml>
</blocks>
</global>
<!--<adminhtml>-->
<!--<layout>-->
<!--<updates>-->
<!--<referralproduct>-->
<!--<file>referral.xml</file>-->
<!--</referralproduct>-->
<!--</updates>-->
<!--</layout>-->
<!--</adminhtml>-->
</config>
0.1.0
Rik_参考产品_模型
推荐产品
推荐产品/产品类型推荐
1.
参考产品/目录索引\数据\参考
0
下线\u参考产品\u块\u管理HTML\u目录\u产品\u编辑\u选项卡
Magento检查产品(库存为库存)是否与数量无关,如果{Product[stock\u data][is\u in\u stock]}为真,则为可销售产品,如果为假,则不可销售(无论数量)
===========================
在产品集合之前添加此代码行
Mage::helper('catalog/product')->setSkipSaleableCheck(true);
============================
将告诉catalog product model isAvailabe方法跳过以下方法中的IsScalable检查
public function isAvailable()
{
return $this->getTypeInstance(true)->isSalable($this)
|| Mage::helper('catalog/product')->getSkipSaleableCheck();
}
结果表明,问题出在我的这个方法中,我的“内在”词。移除后,我的所有产品都在我的收藏中
$collection->addAttributeToSelect(array('entity_id', 'sku', 'name', 'short_description',
'description', 'price', 'thumbnail', 'image', 'url_path', 'type_of'), 'inner')
->addAttributeToFilter('is_saleable', array('like' => '0')) ;
请尝试
->addAttributeToFilter('is_saleable',array('gteq'=>'0'))
,这将获得所有可销售和不可销售的产品。我还没有尝试过此解决方案。那么,它是否自动不显示不可销售的产品?magento如何检查产品是否可销售?magento检查产品(库存是否为库存)是否与数量无关,如果{product[stock_data][is_in_stock]}为真,则为可销售产品,如果为假,则不可销售(无论数量)。不,情况并非如此。我已经编辑了问题,请检查。谢谢你粘贴新的产品类型模型?你使用平面目录产品吗?
$collection->addAttributeToSelect(array('entity_id', 'sku', 'name', 'short_description',
'description', 'price', 'thumbnail', 'image', 'url_path', 'type_of'), 'inner')
->addAttributeToFilter('is_saleable', array('like' => '0')) ;