-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
I have the category links on the left side of the homepage ( and in the top dropdown menu) and would like it to show how many products are in that category, right in the link.
for eample:
shirts (10)
how can I do this? any help is appreciated.
Thx,
Sean
|
| |
-
- Posted: November 16 2009
-
| top
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
please, this can’t be that hard, right in the backend if you click on manage categories, it shows this exact listing, shirts (10), I want to show it on the frontpage.
Thx,
Sean
|
| |
-
- Posted: November 17 2009
-
| top
| # 1
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
Thanks for the reply.
I am not sure where to add the edits?
I tried adding the 1st in /public_html/app/code/core/Mage/Catalog/Model/category.php
and the second in /public_html/app/design/frontend/default/f002/template/catalog/navigation/sidebar.phtml,
which seems to be where they should go, but just got php errors for the site, could you help me out some more?
Thx,
Sean
|
| |
-
- Posted: November 17 2009
-
| top
| # 2
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
Parse error: syntax error, unexpected T_STRING in /home/nepadyes/public_html/app/code/core/Mage/Catalog/Model/Category.php on line 130
protected function _construct() { if (Mage::helper('catalog/category_flat')->isEnabled()) { $this->_init('catalog/category_flat'); $this->_useFlatResource = true; } else { $this->_init('catalog/category'); } } public function getFrontentProductCount() { $collection = Mage::getResourceModel('catalog/product_collection') ->addCategoryFilter($this) Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $collection->count(); }
/** * Retrieve URL instance * * @return Mage_Core_Model_Url */
and
<?php /** * Top menu for store * * @see Mage_Catalog_Block_Navigation */ ?> <div class="box base-mini mini-navigation"> <div class="head"><h4><?php echo $this->__('NepaDyes Products') ?></h4></div> <div class="content"> <ul id="nav-sidebox"> <?php foreach ($this->getStoreCategories() as $_category): ?> <?php echo $this->drawItem($_category) ?><?php echo $_category->getName(). '('.$_category->getFrontentProductCount().')' ?> <?php endforeach ?> </ul> </div> </div>
is what I’ve got so far
|
| |
-
- Posted: November 17 2009
-
| top
| # 3
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
hmm something is still wrong. now I don’t get any errors, but the page will only load up to the header and logo then nothing , never seen that 1 b4
I think we r getting close tho,
thx 4 the help
Sean
|
| |
-
- Posted: November 17 2009
-
| top
| # 4
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
protected function _construct() { if (Mage::helper('catalog/category_flat')->isEnabled()) { $this->_init('catalog/category_flat'); $this->_useFlatResource = true; } else { $this->_init('catalog/category'); } } public function getFrontentProductCount() { $collection = Mage::getResourceModel('catalog/product_collection') ->addCategoryFilter($this); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $collection->count(); }
/** * Retrieve URL instance * * @return Mage_Core_Model_Url */
} $html.= '">'."\n"; $html.= '<a href="'.$this->getCategoryUrl($category).'"><span>'.$this->htmlEscape($category->getName()).'('.$_category->getFrontentProductCount().')'.'</span></a>'."\n";
if ($hasChildren){
|
| |
-
- Posted: November 17 2009
-
| top
| # 5
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
sorry, I just noticed this error, if you hover over the top nav menu
Fatal error: Call to a member function getFrontentProductCount() on a non-object in /home/nepadyes/public_html/app/code/core/Mage/Catalog/Block/Navigation.php on line 242
|
| |
-
- Posted: November 17 2009
-
| top
| # 6
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
It’s nepadyes.com, I set the original files back so it is up and running, thanks for trying. I think it was getting close
Sean
|
| |
-
- Posted: November 17 2009
-
| top
| # 7
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
AHHH so close! it is showing the () but not populating the inventory counts
No errors now tho
|
| |
-
- Posted: November 17 2009
-
| top
| # 8
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
protected function _construct() { if (Mage::helper('catalog/category_flat')->isEnabled()) { $this->_init('catalog/category_flat'); $this->_useFlatResource = true; } else { $this->_init('catalog/category'); } } public function getFrontentProductCount() { $collection = Mage::getResourceModel('catalog/product_collection') ->addCategoryFilter($this); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $collection->count(); }
/** * Retrieve URL instance * * @return Mage_Core_Model_Url */
} $html.= '">'."\n"; $html.= '<a href="'.$this->getCategoryUrl($category).'"><span>'.$this->htmlEscape($category->getName()).'('.$category->getFrontentProductCount().')'.'</span></a>'."\n";
if ($hasChildren)
Sean
|
| |
-
- Posted: November 17 2009
-
| top
| # 9
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
all the code looks good to me, I am not great at code, but I can usually spot the bugs, would the calls still be the same in the 1.4 alpha version? or would that not matter?
Sean
|
| |
-
- Posted: November 17 2009
-
| top
| # 10
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
Thanks so much for trying, I really appreciate it, it is 5 in the morning here, I will try to figure this out in the morning, at least I have a good start now, if you come up with anything let me know,
Thanks again, getting answers in this forum is not always easy, let alone someone that sticks in and works it out post by post. I really appreciate it.
Sean
|
| |
-
- Posted: November 17 2009
-
| top
| # 11
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
$loadedCategory = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($category->getEntityId()); $html.= '<a href="'.$this->getCategoryUrl($category).'"><span>'.$this->htmlEscape($category->getName()).' ('.$loadedCategory ->getFrontentProductCount() ' )'.'</span></a>'."\n";
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/nepadyes/public_html/app/code/core/Mage/Catalog/Block/Navigation.php on line 222
Do I have the link right?
|
| |
-
- Posted: November 17 2009
-
| top
| # 12
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
THAT"S IT!!!
I was missing a period.
Thank You So Much!!
You are awesome
Sean
|
| |
-
- Posted: November 17 2009
-
| top
| # 13
-
|
 |
 |
 |
|
|
-
- sean14538

-
Total Posts: 32
Joined: 2009-11-04
Gouldsboro, PA
|
Hey 1,2,...758 as long as it’s right in the end.
Thank you, I owe you a pizza!
I wish I could figure this stuff out, if I knew all the variables I could make my site even better, where did you learn all the variable names that you can call? I wish I was as good as you at coding.
Have a great day!
Sean
|
| |
-
- Posted: November 17 2009
-
| top
| # 14
-
|
 |
 |
 |
|
|
-
- k1nG

-
Total Posts: 10
Joined: 2009-05-27
|
Hey, seems like there where some more posts in this thread.
What was the code that finally worked?
THX
|
| |
-
- Posted: December 13 2009
-
| top
| # 15
-
|
 |
 |
 |
|
|