What are Sylius Entities?

Entities in Sylius are PHP classes that represent various aspects of an eCommerce application, such as products, orders, customers, and more. They are the building blocks of your Sylius store, and understanding them is crucial for effective customization and extension.

Basic Sylius Entities:

1. Product

  • Represents the products you sell in your store, such as physical items or digital downloads
  • Contains information like name, price, descriptions, images, and product options

2. Variant

  • Products can have different variations (e.g., sizes or colors), and variants represent these distinctions
  • Each variant has its own price, weight, and other attributes

3. Channel

  • Represents the different sales channels through which your products are sold (e.g., online store, mobile app, physical store).
  • Channels help you manage pricing, inventory, and payment methods separately for each one

4. Order

  • Represents customer orders, including the items they purchased, shipping details, and payment information
  • Orders can be in various states, such as cart, payment pending, or completed

5. Customer

  • Represents the individuals who shop on your website
  • Contains information like name, email, and addresses

6. Taxon

  • Represents product categories or taxonomies
  • Helps organize and categorize your products for easier navigation and search

7. Payment

  • Represents payments made by customers for their orders
  • Contains payment method, amount, and status information

8. Shipping Method

  • Represents various ways to deliver products to customers
  • Defines pricing, availability, and other shipping-related details

How to Extend Sylius Entities:

Customizing and extending Sylius entities is a fundamental part of tailoring the platform to your specific business needs. Here’s how you can do it.

1. Inheritance

Sylius uses inheritance to create custom entities. You can extend existing Sylius entities by creating new PHP classes that inherit from the base Sylius entity. This allows you to add new properties and methods or modify existing ones.

For example, you can create a custom Product entity with an additional field like manufacturer.

2. Doctrine Mappings

Use Doctrine annotations or XML/YAML configurations to define your custom entity mappings. Doctrine is the ORM (Object-Relational Mapping) used by Sylius to interact with the database. Example in XML configuration:

Want to know more about Sylius?

Summary

Understanding Sylius entities and their role in your eCommerce application is key to building a successful online store with Sylius. By customizing and extending these entities, you can create a unique shopping experience tailored to your specific business requirements. Whether you need to add new properties to products, introduce custom order states, or integrate with third-party services, Sylius provides the flexibility to make it happen.

If you have any questions about this topic, please contact us!