Log in
Model

CategoryLink

Magento\Catalog\Model\CategoryLink

What it does

This class represents a link between a product and a category in Magento 2, storing the category ID and the product's position within that category.

Developers use this when working with product-category assignments through the API, such as when assigning products to categories or updating their sort order.

It implements the CategoryLinkInterface to ensure consistent data structure for category-product relationships.

Public Methods

  • getPosition()
  • getCategoryId()
  • setPosition()
  • setCategoryId()
  • getExtensionAttributes()
  • setExtensionAttributes()