Questions tagged [category]

Questions about product categories in the Magento catalog

Filter by
Sorted by
Tagged with
23
votes
6answers
49k views

How to get first item from product collection

On the category view.phtml if I get the category and then get a product collection, how can I get the first product form the collection assigned to $_product for use in the code? Here is what I have: ...
22
votes
8answers
18k views

Hide categories with no active products

Is there a way to hide categories that don't have active products? Or, even better, only show categories that have active products and stock.
19
votes
2answers
4k views

How to implement multiple category filter in Magento 2 layered navigation

I am implementing multiple category filters for layered navigation. I am getting the result as per my requirement but the collection size is coming wrong remains same as the parent categories ...
15
votes
5answers
23k views

Import & Export all categories using csv file (without extension)

I want to import all the categories in magento using CSV file, I tried to do using extension http://www.magentoworks.net/importexport-magento-category-extension/ it works but i want to do it using ...
14
votes
3answers
41k views

How to get top parent Category from current category object?

How can I get the top level parent category (just after Default Category) from current category object? I want the Category Name and Category URL of that parent category to show in the subcategories. ...
13
votes
4answers
24k views

Magento 2 get current category Id using registry

Any one know how I can get the category id using current category registry in Magento 2?
13
votes
1answer
1k views

Magento 2 Add Category Tree Renderer Input With Modal Button

I am trying to place the category input for my custom form using uicomponent form. I am able to create dropdown but how I can create the button and open a new modal from it? Can I create a button ...
12
votes
4answers
7k views

Create Category page which displays all Special Price products

Basically, I've created a category 'Products on Sale', which I would like to automatically contain all products in my catalog that have had a Special Price applied to them (via Catalog > Manage ...
12
votes
3answers
1k views

Performance: Add Inventory Stock Levels on product listings list.phtml of all product types

TL;DR, The requirement is having a stock level of inventory be displayed on the category product listing page with as little additional queries/memory with performance in mind that adheres to Magento'...
11
votes
2answers
26k views

Magento 2 get base url (current store) in admin static block/page?

How can I get (current store) Base Url in CMS block/page in Magento 2? Actually, I am displaying category names in the footer by using static block. For that how can I give the Category Url links in ...
11
votes
3answers
11k views

Find out to which categories a product belongs to

I opened a product in the backend, but when I switch to the categories tab, the category tree is fully collapsed. I would have to expand all categories to see in which ones the product is in. How can ...
11
votes
2answers
13k views

How to create a static block which displays all categories

I want to create a static block which displays all of my categories and displays them in a list. I don't need an image and I don't need the sub categories. Then I want to add this block to my home ...
10
votes
8answers
23k views

Magento 2 Get category id using category title

I would like get category id by only using category title by using this kind of function. ->load($categoryTitle, 'title') ->getId(); Use case: Get category id by title and put id data to array ...
10
votes
3answers
6k views

How to apply a category's display setting to all categories?

I have many categories and instead of applying new settings to all categories one by one, i would like to know if this is possible to apply new settings to all categories at once? Thanks!
10
votes
3answers
8k views

Add a extra category attribute under general infomation tab

I am trying adding a extra category attrbiute to general infomation tab i have tried adding that using the following code , require_once("app/Mage.php"); Mage::app('default'); Mage::app()->...
9
votes
4answers
6k views

Category error : Item (Magento\Catalog\Model\Category\Interceptor) with the same ID “191” already exists

I know there is a similar issue regarding a product, but now I've got this error with a category. I can't recall that I did something different, it just all of a sudden started throwing this error as ...
9
votes
1answer
13k views

Parent category is showing products in subcategories, even though product was not assigned to parent category

Let's assume I have a category, Clothing and this category have a sub-category, T-shirts. Now I add a product to the T-shirts category (by checking the box in the add product screen), but I don't ...
9
votes
1answer
207 views

Magento 2 - Full hierarchy wise product breadcrumb

If I open a product directly from Home or search page then breadcrumb shows like this: Home > MyProduct Whereas if I go to the category, then subcategory and then open the product, it show the ...
9
votes
2answers
4k views

Magento 2 :- Add select attribute to category

I want to add a select/dropdown attribute to a category and display it in the backend to let the store owner select it. After some research I found out the following to do: Create an attribute via ...
9
votes
2answers
1k views

Filter Product Collection by Child product attribute

I have situation like 2 attribute which is assign to child product 1) person_height_from and 2) person_height_to which has DropDown type attribute which is only assign in child product but not ...
8
votes
5answers
22k views

Magento 2 - Get Subcategories of Specific Parent Category

What I'd like to do is grab all of the child categories of a specific parent category. I'm assuming the best way to do this is by using the parent's ID and of those child categories that are returned, ...
8
votes
4answers
11k views

Magento 2 : How to check if we are on a category page or product page?

Is there a way I can check that If a user on a category page,or an individual product page in Magento 2? Any help would be greatly appreciated!
8
votes
6answers
28k views

Hide or remove “category” filter from the layered navigation

I'm struggling to remove the Category filter from the layered, because I already have a category dropdown menu in my new website, so it will be only a waste of space (and confuse my customers) I know ...
8
votes
2answers
10k views

How to retrieve the Category name, Category URL and Category image using Category-Id?

As we know that in the Category Management page we can upload an image and give a URL for each category. I want to retrieve the Category name, Category URL and Category image using only the Category ...
8
votes
1answer
7k views

How to get list of all subcategories which are set “Include in Navigation Menu” as no

I have tried to get all sub categories which are not include in navigation menu but those are being active, of current category in list page. $children = Mage::getModel('catalog/category')->...
8
votes
1answer
11k views

How to set a page to display sub-categories and not products?

How to set a page to display sub-categories and not products?
8
votes
1answer
9k views

Magento 2 Products Not Showing in Category (but are visible via search)

Got a little issue here with Categories. Running Magento 2.1.3 All other categories display the correct amount of product, except this one Under Products->Categories->"Kingdom Death" category ...
8
votes
1answer
139 views

how to optimize load all categories with image

right now, I have two nested foreach to loop through all the category, and it's extremely slow (3-4s on my local server). I think the problem is i use ->LOAD() to get the image path for the child ...
8
votes
1answer
311 views

Magento 2 url_rewrite table contains “az-categories/” prepended to URLs for all of our stores

We have a multi-store Magento 2.1.4 installation, with 3 stores, and in recent weeks we've noticed that our category URLs will some times include one of our store code's prepended with "-categories/" ...
7
votes
7answers
40k views

Get full list of categories using sql

How would I format a sql query to get a list of all category (id, name and url_path) from my magento database. Alternatively if you know the tables I need to do this, a list and some sort of ...
7
votes
7answers
11k views

Magento 2: How to delete all categories at once?

We have been experimenting with syncing our existing database(not Magento) to Magento 2. In the process, we have created over 1000 categories, but then we rearranged all the IDs to sync with our ...
7
votes
5answers
35k views

Filter product collection by multiple categories?

I have this snippet of code that gets the most recently added products: $_productCollection = Mage::getResourceModel('catalog/product_collection') ->addAttributeToSelect('*') ...
7
votes
4answers
10k views

Assign products to category programatically in magento2

How can I assign 'New products' to 'NEW PRODUCTS category' programatically in magento 2.
7
votes
3answers
27k views

How to get Category Collection per Store in Magento 2?

I want to get all categories names from a specific store. I'm trying: $categoryFactory = $objectManager->create('Magento\Catalog\Model\ResourceModel\Category\CollectionFactory'); $categories = $...
7
votes
4answers
4k views

How to get category ids from product collection

I have an array of product ids now i want to get all categories where these products belongs in magento2. For example we have categories cat_1, cat_2 ,cat_3, cat_4, cat_5, cat_6, cat_7 ...
7
votes
4answers
22k views

How to redirect a category to another link

I have an extension in my store that i can upload posts with this and it has a link in top menu that' name is blog. In menu I have a category that's name is News and I want to redirect it to blog. ...
7
votes
5answers
34k views

How to get Category Id of current product?

I have get the current product category id on product details page. I have used some method like : $_product = Mage::getModel('catalog/product')->load(prodId); $ids = $_product->getCategoryId();...
7
votes
2answers
5k views

Impossible to save category with more that 1000 products

This is a known issue caused by PHP 5.3.9 and max_input_vars that by default it is set to 1000. The solution 2 proposed here it is the best in my opinion but doesn't work: for some strange reason it ...
7
votes
1answer
8k views

What is 'best practice' when setting anchor on multi-level categories?

With three level category tree (can be more!) where we want the highest level not to be set to 'anchor' but want the next level down to be an 'anchor', what would we do with the lowest level? Set it ...
7
votes
1answer
23k views

In which database table are products and categories coupled

Each product can be assigned to a category. I was wondering in which database table these products and categories are coupled.
7
votes
2answers
11k views

Get subcategories of parent category when FLAT categories enabled

I override a block class Mage_Catalog_Block_Navigation (link to signature) to create a custom menu which displays only subcategories of current category. Inside method renderCategoriesMenuHtml (link ...
7
votes
2answers
6k views

update category attributes programmatically

I can't seem to figure out how to best update hundreds of category attributes with a script. Any suggestions as the best way to approach this? I won't be using the installer or anything like that.
7
votes
7answers
21k views

Magento 2 : URL key For Specified Store Already Exists

We have a Magento 2 multisite setup, with categories set up. When editing some (but not all) of these categories, in different store views, Magento throws following error and does not save data: In ...
7
votes
2answers
1k views

Add category image with REST

Has anyone successfully uploaded an image for use with a category? When going through the documentation @ http://devdocs.magento.com/swagger/index.html#/ I don't see any implementation that could ...
7
votes
3answers
835 views

Set Use Default Value for all categories attributes Magento 2

I have around 1260 categories.If i switch the store view , the all attributes have own value.But i want to set the all attribute values as parent main store view value. I can not open each category ...
7
votes
1answer
828 views

Show different number of products in category page

I am trying to show different number of products in category but it is only working on page 1. I want to show 22 products on page1 and rest all the pages 20 products per page. I managed to change by ...
7
votes
4answers
6k views

Access Sub-category without Parent Category

We have following category and sub-category in our store. Category: http://yoursite.com/category.html Sub-category: http://yoursite.com/category/sub-category.html Is it possible to access sub-...
7
votes
2answers
176 views

How to show Categories in System.xml in magento 2

I'm getting all the categories in System.xml using the class Vender\Module\Model\Config\Source\Category <?php namespace Vender\Module\Model\Config\Source; use Magento\Framework\Data\...
7
votes
1answer
294 views

Magento2 : Parent category load child category's product too

In my store parent category load collection of its child category also. I can solve it by Is Anchor to "No". But by doing this Filter is not coming in the left bar so it is not the solution of my ...
7
votes
3answers
3k views

Magento 2.1.5: Products Missing in Categories after Reindex

I am running Magento 2.1.5 and facing a really strange issue. I have over 6,500 products uploaded to the store but some items are not showing up after performing a complete reindex. Of course, some ...