本文整理汇总了PHP中Mage_Core_Model_Mysql4_Collection_Abstract::removeItemByKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Mysql4_Collection_Abstract::removeItemByKey方法的具体用法?PHP Mage_Core_Model_Mysql4_Collection_Abstract::removeItemByKey怎么用?PHP Mage_Core_Model_Mysql4_Collection_Abstract::removeItemByKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Mysql4_Collection_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Model_Mysql4_Collection_Abstract::removeItemByKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _removeHiddenCollectionItems
/**
* Remove hidden items from a product or category collection
*
* @param Mage_Eav_Model_Entity_Collection_Abstract|Mage_Core_Model_Mysql4_Collection_Abstract $collection
*/
public function _removeHiddenCollectionItems($collection)
{
// Loop through each category or product
foreach ($collection as $key => $item) {
$catData = Mage::getModel("catalog/category")->load($item->getEntityId());
// If it is a category
if ($item->getEntityTypeId() == 3 && $item->getLevel() != 2) {
if (strtolower($catData->getUrlKey()) != 'get-the-look' && strtolower($catData->getUrlKey()) != 'new-arrivals') {
if ($this->getProductCountCustom($catData) <= 0) {
$collection->removeItemByKey($key);
}
}
}
}
}
示例2: applySalableProductTypesFilter
/**
* Filter collection by removing not available product types
*
* @param Mage_Core_Model_Mysql4_Collection_Abstract $collection
* @return Mage_Core_Model_Mysql4_Collection_Abstract
*/
public function applySalableProductTypesFilter($collection)
{
$productTypes = Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray();
$productTypes = array_keys($productTypes);
foreach ($collection->getItems() as $key => $item) {
if ($item instanceof Mage_Catalog_Model_Product) {
$type = $item->getTypeId();
} else {
if ($item instanceof Mage_Sales_Model_Order_Item) {
$type = $item->getProductType();
} else {
if ($item instanceof Mage_Sales_Model_Quote_Item) {
$type = $item->getProductType();
} else {
$type = '';
}
}
}
if (!in_array($type, $productTypes)) {
$collection->removeItemByKey($key);
}
}
return $collection;
}