How can I get current category id of Virtue Mart - virtuemart

I want to change the default Featured Products module of Virtue Mart. I would like to this module show just the current category's featured product. So I need to get the current category id.
How can I get it?
Thanks!

JRequest::getInt(category_id);

$input = JFactory::getApplication()->input;
// should be article, categories, featured, blog...
$view = $input->get('view');
// if it's a category view, this will be the category id, else the article id
$id = $input->getInt('id');
// in an article view, this will be the cat id.
$catid = $input->getInt('catid');
// this is the menu item id i.e. what you call page id I guess.
$Itemid = $input->getInt('Itemid');
I hope this will help you.. :)

Related

magento variable for product detail view

is there a variable to check if the product detail view (view.phtml) is used?
Why do I need this?
Price.phtml is used in product overview and product detail view also. I want to add a ifelse function when the price is shown on product detail view cause I want some more information.
Regards
Matt
Yup this is quite easy to achieve;
$pageIdentifier = Mage::app()->getFrontController()->getAction()->getFullActionName();
if($pageIdentifier == 'catalog_product_view') {
// Do something on product view page only
echo 'This is a product view page';
}

All products (category and sub category products) count on category list page in magento

I want to show count for all the products under category and also sub categories.I can't use toolbar for that purpose.I know default magento toolbar have code but i want to use custom code to only get count.i try to get collection by calling block method getTotalNum() but didn't succeeded.Thanks in advance
In list.phtml you can try this code:
//get the current layer
$layer = Mage::getSingleton('catalog/layer');
//get the current category
$currentCategory = $this->getLayer()->getCurrentCategory();
//get the subcategories
$categoriesChildren = $currentCategory->getChildrenCategories(); //means get your children
$categoriesSiblings = $currentCategory->getParentCategory()->getChildrenCategories(); //means get your siblings
//(decide if you want to use siblings or children, here we use children)
//get the product collection for the current layer
$productCollection = Mage::getResourceModel('catalog/product_collection');
$layer->prepareProductCollection($productCollection);
//count up
$productCollection->addCountToCategories($categoriesChildren); //note the function accepts a collection of categories and counts them all
//display
echo("<ol>".PHP_EOL);
foreach ($categoriesChildren as $key=>$_category){
if($_category->getIsActive()){
echo("<li>".PHP_EOL);
echo("<a href=\"".$this->getCategoryUrl($_category)."\">".$this->htmlEscape($_category->getName()));
echo("(".$_category->getProductCount().")</a>".PHP_EOL);
echo("</li>".PHP_EOL);
}
}
echo("</ol>".PHP_EOL);
//done
I think you might want to customise it a little.

How To Get Current Page Parameters And Properties of Joomla 3.1

I want to create a module for joomla 3.1 for my own site. I need to know how to get current category id, parent category id, current page id. Please some one tell me how to do that. Thanks for your advance
going from memory here, please bear with some inaccuracies but it should be enough to get you going.
$input = JFactory::getApplication()->input;
// should be article, categories, featured, blog...
$view = $input->get('view');
// if it's a category view, this will be the category id, else the article id
$id = $input->getInt('id');
// in an article view, this will be the cat id.
$catid = $input->getInt('catid');
// this is the menu item id i.e. what you call page id I guess.
$Itemid = $input->getInt('Itemid');

Display New Products, Filter by Category Ids: in Magento

i have magento 1.5 and i want to display new products Filter by Category Ids. I had try by ->addCategoryFilter($categoryId);
But not working...
I also try this tips, which exactly i want by (Category ids). but it give me error of: "Invalid attribute Category_ids"...
SO can any one display new products in magento by list of Category ids....?
See my reply here How to get all product from a category including its subcategories in Magento?
To filter with Category you need to pass category model data rather then category ID. As like
below.
$category_id = 10;
$catagory_model = Mage::getModel('catalog/category')->load($category_id);
$collection->addCategoryFilter($catagory_model);
Please see this link for more detail http://way2discuss.blogspot.in/2012/07/magento-show-all-products-from-specific.html

Magento - Get category name in a custom product grid in homepage

I want to get the name of category in a custom category products grid in homepage
How can I do that ?
Thanks a lot
If you don't already have a variable containing a category object, create one:
$category = Mage::getModel('catalog/category')->load($categoryId);
Getting the name is then a simple matter of...
echo $category->getName();

Resources