本文整理汇总了PHP中Mage_Catalog_Model_Category::getProductCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::getProductCount方法的具体用法?PHP Mage_Catalog_Model_Category::getProductCount怎么用?PHP Mage_Catalog_Model_Category::getProductCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Category
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Category::getProductCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetProductCount
public function testGetProductCount()
{
$this->_model->load(6);
$this->assertEquals(0, $this->_model->getProductCount());
$this->_model->setData(array());
$this->_model->load(3);
$this->assertEquals(1, $this->_model->getProductCount());
}
示例2: exportData
protected function exportData(Mage_Catalog_Model_Category $category, $file, $depth = 0)
{
$data = array('id' => $category->getId(), 'parent_id' => $category->getParentId(), 'attribute_set_id' => $category->getAttributeSetId(), 'urlPath' => $category->getUrlPath(), 'urlKey' => $category->getUrlKey(), 'path' => $category->getPath(), 'position' => $category->getPosition(), 'page_layout' => $category->getPageLayout(), 'description' => $category->getDescription(), 'display_mode' => $category->getDisplayMode(), 'is_active' => $category->getIsActive(), 'is_anchor' => $category->getIsAnchor(), 'include_in_menu' => $category->getIncludeInMenu(), 'custom_design' => $category->getCustomDesign(), 'level' => $category->getLevel(), 'name' => $category->getName(), 'metaTitle' => $category->getMetaTitle(), 'metaKeywords' => $category->getMetaKeywords(), 'metaDescription' => $category->getMetaDescription());
echo str_repeat(' ', $depth);
echo '* ' . $category->getName() . sprintf(' (%s products)', $category->getProductCount()) . PHP_EOL;
fputcsv($file, $data);
if ($category->hasChildren()) {
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
foreach ($children as $child) {
$child = Mage::getModel('catalog/category')->load($child->getId());
$this->exportData($child, $file, $depth + 1);
}
}
}
示例3: _getProductCount
/**
* @param Mage_Catalog_Model_Category $category
* @return mixed
*/
protected function _getProductCount($category)
{
/** @var Amasty_Shopby_Helper_Data $helper */
$helper = Mage::helper('amshopby');
if ($helper->useSolr()) {
// not implemented yet
return null;
} else {
return $category->getProductCount();
}
}
示例4: getObject
public function getObject(Mage_Catalog_Model_Category $category)
{
/** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
$productCollection = $category->getProductCollection();
$category->setProductCount($productCollection->addMinimalPrice()->count());
$transport = new Varien_Object();
Mage::dispatchEvent('algolia_category_index_before', array('category' => $category, 'custom_data' => $transport));
$customData = $transport->getData();
$storeId = $category->getStoreId();
$category->getUrlInstance()->setStore($storeId);
$path = '';
foreach ($category->getPathIds() as $categoryId) {
if ($path != '') {
$path .= ' / ';
}
$path .= $this->getCategoryName($categoryId, $storeId);
}
$image_url = NULL;
try {
$image_url = $category->getImageUrl();
} catch (Exception $e) {
/* no image, no default: not fatal */
}
$data = array('objectID' => $category->getId(), 'name' => $category->getName(), 'path' => $path, 'level' => $category->getLevel(), 'url' => $category->getUrl(), '_tags' => array('category'), 'popularity' => 1, 'product_count' => $category->getProductCount());
if (!empty($image_url)) {
$data['image_url'] = $image_url;
}
foreach ($this->config->getCategoryAdditionalAttributes($storeId) as $attribute) {
$value = $category->getData($attribute['attribute']);
$attribute_ressource = $category->getResource()->getAttribute($attribute['attribute']);
if ($attribute_ressource) {
$value = $attribute_ressource->getFrontend()->getValue($category);
}
if (isset($data[$attribute['attribute']])) {
$value = $data[$attribute['attribute']];
}
if ($value) {
$data[$attribute['attribute']] = $value;
}
}
$data = array_merge($data, $customData);
foreach ($data as &$data0) {
$data0 = $this->try_cast($data0);
}
return $data;
}
示例5: _getProductCount
/**
* Return the number of products assigned to the category
*
* @param Mage_Catalog_Model_Category|Varien_Data_Tree_Node $category
* @return int
*/
protected function _getProductCount($category)
{
if (null === ($count = $category->getData('product_count'))) {
$count = 0;
if ($category instanceof Mage_Catalog_Model_Category) {
$count = $category->getProductCount();
} elseif ($category instanceof Varien_Data_Tree_Node) {
$count = $this->_getProductCountFromTreeNode($category);
}
}
return $count;
}
示例6: _prepareItemData
/**
* Prepare category row
* @param Mage_Catalog_Model_Category $category
* @param unknown_type $id
* @param unknown_type $isSelected
* @param unknown_type $level
* @param unknown_type $isFolded
* @return array
*/
protected function _prepareItemData($category, $id, $isSelected, $level = 1, $isFolded = false, $skipCount = false)
{
$row = null;
/*
* Display only active category and having products or being parents
*/
if ($category->getIsActive() && ($skipCount || $category->getProductCount())) {
$row = array('label' => Mage::helper('core')->htmlEscape($category->getName()), 'value' => Mage::helper('amshopby/url')->getCategoryUrl($category), 'count' => $skipCount ? 0 : $category->getProductCount(), 'level' => $level, 'id' => $id, 'is_folded' => $isFolded, 'is_selected' => $isSelected);
}
return $row;
}
示例7: _getProductCount
/**
* @param Mage_Catalog_Model_Category $category
* @return mixed
*/
protected function _getProductCount($category)
{
if ($this->_getDataHelper()->useSolr()) {
/** @var Enterprise_Search_Model_Resource_Collection $productCollection */
// $productCollection = $this->getLayer()->getProductCollection();
// $categoriesCount = $productCollection->getFacetedData('category_ids');
// return isset($categoriesCount[$category->getId()]) ? $categoriesCount[$category->getId()] : null;
// Disabled, course still buggy
return null;
} else {
return $category->getProductCount();
}
}