menu

Magento get current category details


Magento get current category details : We are going to cover all details about the current category such as category name, category id, category url etc. Here are the things which we will cover in this tutorial.

  • Id
  • Name
  • Url
  • Description
  • Level
  • Image Url
  • Thumbnail Image Url
  • Product Collection

Magento get current category Details

There are followings conditions to get category details –
1 – You want to get current selected category detail.
2 – Or You want load category detail by Category Id.

Let us start with above both conditions –

First get Current Category Id.

Magento get current category Id

Syntax to get current Category Id :

Magento Load Category By Id


Now we will use the above category id to load category details and other information-

Load Category By Id :

Now you can get category details such as name, url etc.

Magento get category Name By Category Id

Syntax to get Category Name Id :

Magento get category Url By Category Id

Syntax to get Category Url :

Magento get category Description By Category Id

Syntax to get Category Description :

Magento get category Level By Category Id

Syntax to get Category Level :

Magento get category Image Url By Category Id

Syntax to get Category Image Url :

Magento get category Thumbnail Image Url By Category Id

Syntax to get Category Thumbnail Image Url :

Magento Load Category Products Collection

If you want to load products in individual category by id you can get all products as below .


Magento Load Category Products Collection By Category Id

Category Products Collection :

The above example will load all products of the category.

Note : In the above example we have selected all attributes
->addAttributeToSelect(‘*’);. We suggest not to select all attributes while getting the products collection, select the attributes which you need to display because it may slow down the system performance.

Advertisements