Data Interface in Magento 2

A complete guide with examples

What is a Data Interface?

Data Interfaces are part of Service Contracts...

Purpose of Data Interfaces

  • Encapsulation of Data
  • Loose Coupling
  • Used in APIs

Example: Product Data Interface


namespace Magento\Catalog\Api\Data;

interface ProductInterface {
    public function getSku();
    public function setSku($sku);
}
    

Last updated: September 2025