$selectionCollection
如果在magento捆绑包产品列表的代码中未找到选择产品,给定的输出是什么?
$bundled_product_custom = new Mage_Catalog_Model_Product();
$bundled_product_custom->load($bundleParentProductId);
$selectionCollection = $bundled_product_custom->getTypeInstance(true)->getSelectionsCollection(
$bundled_product_custom->getTypeInstance(true)->getOptionsIds($bundled_product_custom), $bundled_product_custom
);
实际上,我需要检查此捆绑产品是否具有精选产品。
首先,您应该避免使用new
运算符实例化一个对象。我建议您使用Magento的工厂方法,如下所示:
$bundled_product_custom = Mage::getModel('catalog/product');
这样,如果第三方扩展覆盖了Mage_Catalog_Model_Product
该类,则factory方法将根据覆盖规则实例化正确的对象。
要回答您的问题,请尝试通过这种方式对集合中的元素进行计数:
$selectionCollection->count();
// or
count($selectionCollection);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句