Public Magento 2 Interfaces

  • Products
  • Product Attributes
  • Product Attribute Types
  • Product Attribute Media Gallery
  • Product Links
  • Categories
  • Category Attributes
  • Category Product Links
  • Directories
  • Files

It’s SAFE and highly encouraged to use these classes in your work injected to your own classes.

All developers can contribute to this page and it’s highly appreciated. When adding new items, please make sure your description is clear and consistent, it will help other developers in their work immensely and save hours of investigation.

Please be discrete; this page must not contain arbitrary “useful” classes and interfaces, only those which fit the following note.

This section mentions only STANDARD Magento 2 interfaces, marked with @api annotation (otherwise called Service Contracts), or classes PREGENERATED by Magento internally.

Products

Interface

Description

\Magento\Catalog\Api\Data\ProductInterface

A product entity interface. Represents the product model. You should NEVER instantiate implementations of this interface (for example, \Magento\Catalog\Model\Product) directly. You should always use the ProductFactory::create() method.

\Magento\Catalog\Api\ProductRepositoryInterface

Products repository is responsible for implementing CRUD and also to list a collection of products. Note that by default SKU is used to get an item, use getById() to fetch an item by the internal ID.

\Magento\Catalog\Api\ProductManagementInterface

An instance of this interface would have a product collection injected. The only method, getCount($status), would return a number of products filtered by a specific status, or not filtered at all. It’s impossible to modify a filter with something else directly.

\Magento\Catalog\Model\ProductFactory

This class doesn’t exist in the codebase, it’s being generated during code generation. Generates instances of \Magento\Catalog\Model\Product on demand.

\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory

This class doesn’t exist in the codebase, it’s being generated during code generation. A product collection factory that is used to instantiate concrete product collection instances.

Please note that product collection is not considered standard, it doesn’t have a service contract defined. In common cases, if you need to work with a list of products, use \Magento\Catalog\Api\ProductRepositoryInterface::getList(), otherwise instantiate product collection using this factory injected into your service class.

Product Attributes

Interface

Description

\Magento\Catalog\Api\Data\ProductAttributeInterface

A product attribute interface. Represents the product attribute model. You should NEVER instantiate implementations of this interface.

\Magento\Catalog\Api\ProductAttributeRepositoryInterface

Product attribute repository is responsible for implementing CRUD and also to list a collection of product attributes.

\Magento\Catalog\Api\ProductAttributeManagementInterface

This interface implements getting a list of attributes from an attribute set, assigning and un-assigning the attribute to/from specific attribute set.

Product Attribute Types

Interface

Description

\Magento\Catalog\Api\Data\ProductAttributeTypeInterface

A product attribute type interface.

\Magento\Catalog\Api\ProductAttributeTypesListInterface

Implements fetching a list of product attribute types. 

Product Attribute Media Gallery

Interface

Description

\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface

Implements a media gallery entry for a gallery attribute. 

\Magento\Catalog\Api\ProductAttributeMediaGalleryManagementInterface

A media gallery entries management interface, implements methods to create entries, to fetch, update and remove them, as well as getting a list of media gallery entries by specific product SKU.

Product Links

Interface

Description

 

 

Categories

Interface

Description

\Magento\Catalog\Api\Data\CategoryInterface

A category entity interface. Represents the category model. You should NEVER instantiate implementations of this interface (for example, \Magento\Catalog\Model\Category) directly. You should always use the CategoryFactory::create() method.

\Magento\Catalog\Api\CategoryRepositoryInterface

Categories repository is responsible for implementing CRUD and also to list a collection of categories. It alternatively provides a way to delete by a category object, or by category ID.

\Magento\Catalog\Api\CategoryManagementInterface

An instance of this interface would have a category collection injected. There are three methods implemented:

  • getCount() — returns a number of categories with parentId > 0
  • getTree([$rootCategoryId], [$depth]) — builds a subtree of categories for specific parent and specific depth (if provided)
  • move($categoryId, $parentId, [$afterId]) — moves the category across the category tree. If $afterId is not specified, doesn’t rearrange the order.

\Magento\Catalog\Model\CategoryFactory

This class doesn’t exist in the codebase, it’s being generated during code generation. Generates instances of \Magento\Catalog\Model\Category on demand.

Category Attributes

Interface

Description

\Magento\Catalog\Api\Data\CategoryAttributeInterface

A category attribute interface. Represents the category attribute model. You should NEVER instantiate implementations of this interface.

\Magento\Catalog\Api\CategoryAttributeRepositoryInterface

Category attribute repository is responsible for getting an instance of an attribute and also to get a collection of category attributes. It does not provide full CRUD interface.

Category Product Links

Interface

Description

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s