Customizing Models
Why customize a model?
How to customize a model?
Example: Adding a flag Field to the Country Model
flag Field to the Country Model<?php declare(strict_types=1); namespace App\Entity\Addressing; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Addressing\Model\Country as BaseCountry; use Sylius\Component\Addressing\Model\CountryInterface; /** * @ORM\Entity() * @ORM\Table(name="sylius_country") */ class Country extends BaseCountry implements CountryInterface { /** @ORM\Column(type="string", nullable=true) */ private $flag; public function getFlag(): ?string { return $this->flag; } public function setFlag(string $flag): void { $this->flag = $flag; } }sylius_addressing: resources: country: classes: model: App\Entity\Addressing\Countryphp bin/console doctrine:schema:update --forcephp bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate
How to customize a translatable model?
Example: Adding an estimatedDeliveryTime Field to the ShippingMethod Model
estimatedDeliveryTime Field to the ShippingMethod ModelExample: Adding a translatable deliveryConditions Field to the ShippingMethod Model
deliveryConditions Field to the ShippingMethod ModelKey Takeaways
Learn more
Was this helpful?
