This topic contains 1 reply, has 2 voices, and was last updated by Mike Kudelya 7 years, 4 months ago.
- Topic
Hi Oro Team,
I have extend the task bundle using migration I add a ManyToOne Relation on Task to MagentoOrder.
I have made a formExtension, override the update.html.twig and all works fine except that when i try to create a task , I have this error :Fatal error: Call to undefined method OroCRM\Bundle\MagentoBundle\Entity\Order::toArray() in /home/sinabs/sites/dev.orocrm.sinabs.fr/app/cache/dev/oro_entities/Extend/Entity/EX_OroCRMTaskBundle_Task.php on line 426
Here is my code :
12345678910111213141516171819202122232425262728293031323334353637<?phpnamespace Sinabs\TaskBundle\Migrations\Schema\v1_0;use Doctrine\DBAL\Schema\Schema;use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtension;use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtensionAwareInterface;use Oro\Bundle\MigrationBundle\Migration\Migration;use Oro\Bundle\MigrationBundle\Migration\QueryBag;use Oro\Bundle\EntityExtendBundle\EntityConfig\ExtendScope;class OrderExtendTaskBundle implements Migration, ExtendExtensionAwareInterface {protected $extendExtension;public function setExtendExtension(ExtendExtension $extendExtension) {$this->extendExtension = $extendExtension;}public function up(Schema $schema, QueryBag $queries) {// @codingStandardsIgnoreStart$extendExtension = $this->extendExtension;/** extend table orocrm_account **/$table = $schema->getTable('orocrm_task');$extendExtension->addManyToOneRelation($schema,$table,'order','orocrm_magento_order','increment_id',['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);}}123456789101112131415161718192021222324252627282930<?phpnamespace Sinabs\TaskBundle\Form\Extension;use Symfony\Component\Form\AbstractTypeExtension;use Symfony\Component\Form\FormBuilderInterface;class TaskFormExtension extends AbstractTypeExtension {public function buildForm(FormBuilderInterface $builder, array $options) {$builder->add('order_19a88871', 'genemu_jqueryselect2_entity', ['required' => false,'multiple' => false,'label' => 'Order','class' => 'OroCRMMagentoBundle:Order','configs' => ['placeholder' => 'please select order'],]);}/*** Returns the name of the type being extended.** @return string The name of the type being extended*/public function getExtendedType() {return 'orocrm_task';}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899{% extends 'OroUIBundle:actions:update.html.twig' %}{% oro_title_set({params : {"%entity.subject%": entity.subject, "%entityName%": 'orocrm.task.entity_label'|trans }}) %}{% set entityId = entity.id %}{% block navButtons %}{% set html = UI.saveAndCloseButton({'route': 'orocrm_task_view','params': {'id': '$id'}}) %}{% if resource_granted('orocrm_task_create') %}{% set html = html ~ UI.saveAndNewButton({'route': 'orocrm_task_create'}) %}{% endif %}{% if resource_granted('orocrm_task_update') %}{% set html = html ~ UI.saveAndStayButton({'route': 'orocrm_task_update','params': {'id': '$id'}}) %}{% endif %}{{ UI.dropdownSaveButton({'html': html}) }}{{ UI.cancelButton(path('orocrm_task_index')) }}{% endblock navButtons %}{% block pageHeader %}{% if entityId %}{% set breadcrumbs = {'entity': entity,'indexPath': path('orocrm_task_index'),'indexLabel': 'orocrm.task.entity_plural_label'|trans,'entityTitle': entity.subject} %}{{ parent() }}{% else %}{% set title = 'oro.ui.create_entity'|trans({'%entityName%': 'orocrm.task.entity_label'|trans}) %}{% include 'OroUIBundle::page_title_block.html.twig' with { title: title } %}{% endif %}{% endblock pageHeader %}{% block breadcrumbs %}{{ parent() }}<div class="pull-left">{% if entity.status is not null %}{% if entity.status.id == 'closed' %}<div class="badge badge-enabled status-enabled"><i class="icon-status-enabled icon-circle"></i>{{ entity.status.name }}</div>{% elseif entity.status.id == 'in_progress' %}<div class="badge badge-tentatively status-tentatively"><i class="icon-status-tentatively icon-circle"></i>{{ entity.status.name }}</div>{% else %}<div class="badge badge-disabled status-unknown"><i class="icon-status-disabled icon-circle"></i>{{ entity.status.name }}</div>{% endif %}{% endif %}</div>{% endblock breadcrumbs %}{% block content_data %}{% set id = 'task-form' %}{% set dataBlocks = [{'title': 'General Information'|trans,'class': 'active','subblocks': [{'title': '','data': [form_row(form.subject),form_row(form.description),form_row(form.dueDate),form_row(form.status),form_row(form.taskPriority),form.owner is defined ? form_row(form.owner) : '',form_row(form.reminders),form_row(form.order_19a88871)]}]}] %}{% set additionalData = [] %}{% for child in form.children if child.vars.extra_field is defined and child.vars.extra_field %}{% set additionalData = additionalData|merge([form_row(child)]) %}{% endfor %}{% if additionalData is not empty %}{% set dataBlocks = dataBlocks|merge([{'title': 'Additional'|trans,'subblocks': [{'title': '','useSpan': false,'data' : additionalData}]}] ) %}{% endif %}{% set data = {'formErrors': form_errors(form)? form_errors(form) : null,'dataBlocks': dataBlocks,} %}{{ parent() }}{% endblock content_data %}
The forum ‘OroCRM – Installation/Technical Issues or Problems’ is closed to new topics and replies.