This topic contains 1 reply, has 2 voices, and was last updated by Andrey Yatsenko 5 years, 11 months ago.
- Topic
I’ve tried to add one-2-many relationship to the existing Opportunity entity. The collection is called product interest collection. I also defined some fields in ProductInterest entity.
I also tried to extend Opportuniy entity by extending Oro\Bundle\SalesBundle\Entity\Opportunity.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546<?phpnamespace Acme\Bundle\SalesBundle\Entity;use Oro\Bundle\SalesBundle\Entity\Opportunity as OpportunityOROCRM;use Acme\Bundle\OrderBundle\Entity\ProductInterest;class Opportunity extends OpportunityOROCRM{/*** @var ProductInterest[]|Collection** @ORM\OneToMany(targetEntity="Acme\Bundle\OrderBundle\Entity\ProductInterest", mappedBy="opportunity",cascade={"all"})* @ConfigField(* defaultValues={* "importexport"={* "full"=true* },* "dataaudit"={"auditable"=true},* }* )*/protected $productinterests;/*** @return ProductInterest[]|Collection*/public function getItems(){return $this->productinterests;}/*** @param float $items** @return ProductInterest*/public function setItems($items){$this->items = $productinterests;return $this;}}?>12345678910111213141516171819202122232425262728293031323334353637<?phpnamespace Acme\Bundle\SalesBundle\Form\Extension;use Symfony\Component\Form\AbstractTypeExtension;use Symfony\Component\Form\FormBuilderInterface;use Oro\Bundle\SalesBundle\Form\Type\OpportunityType;class OpportunityTypeExtension extends AbstractTypeExtension{public function buildForm(FormBuilderInterface $builder, array $options){$builder->add('items','oro_address_collection',array('label' => '','type' => 'Acme\Bundle\SalesBundle\Form\Type\ProductInterestType','required' => false,'options' => array('data_class' => 'Acme\Bundle\OrderBundle\Entity\ProductInterest')));}/*** Returns the name of the type being extended.** @return string The name of the type being extended*/public function getExtendedType(){return OpportunityType::class;}}However, I cannot make it work. The system doesn’t detect the extended Opporunity entity at all. It always throw me the following error.
[2018-05-08 10:04:55] request.CRITICAL: Uncaught PHP Exception Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException: “Neither the property “items” nor one of the methods “getItems()”, “items()”, “isItems()”, “hasItems()”, “__get()” exist and have public access in class “Oro\Bundle\SalesBundle\Entity\Opportunity”.” at /var/www/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php line 486 {“exception”:”[object] (Symfony\\Component\\PropertyAccess\\Exception\\NoSuchPropertyException(code: 0): Neither the property \”items\” nor one of the methods \”getItems()\”, \”items()\”, \”isItems()\”, \”hasItems()\”, \”__get()\” exist and have public access in class \”Oro\\Bundle\\SalesBundle\\Entity\\Opportunity\”. at /var/www/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php:486)”} []
Can anyone tell me what’s the correct way of extends Opporunity entity and a new sub collection to it?
The forum ‘OroCRM’ is closed to new topics and replies.