https://github.com/pixel-open/magento-product-main-category
The module adds a main category attribute to product.
https://github.com/pixel-open/magento-product-main-category
Last synced: about 1 year ago
JSON representation
The module adds a main category attribute to product.
- Host: GitHub
- URL: https://github.com/pixel-open/magento-product-main-category
- Owner: Pixel-Open
- License: mit
- Created: 2024-04-19T07:28:30.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-19T08:15:27.000Z (about 2 years ago)
- Last Synced: 2024-04-25T08:31:12.784Z (about 2 years ago)
- Language: PHP
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Magento Product Main Category
[](https://php.net/)
[](https://business.adobe.com/products/magento/magento-commerce.html)
[](https://github.com/Pixel-Open/magento-product-main-category/releases)
## Presentation
The module adds a main category attribute to product.

## Requirements
- Magento >= 2.4.4
- PHP >= 8.0.0
## Installation
```
composer require pixelopen/magento-product-main-category
```
## Retrieve Product Main Category value
```php
$mainCategory = $product->getMainCategory();
// OR
$mainCategory = $product->getData('main_category');
// OR
$mainCategory = $product->getCustomAttribute('main_category')?->getValue();
```