OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – Programming Questions Extra field in order item

This topic contains 1 reply, has 2 voices, and was last updated by  Dmitry Khrysev 8 years, 9 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #25038

    ant-workaholic
    Participant

    Hi guys. I need your help. I need to add some extra field in order item. I have created new field for Order Item entity in admin panel also I added new field to wsdl in Magento. Now, I need to get data from this field in magento and save it to oro order item.
    I have created new bundle, and add new listener for oro_importexport.strategy.process_before
    my services.yml is:

    parameters:
    # acme_test.example.class: Acme\Bundle\TestBundle\Example
    acme_test.import_strategy.listener.class: Acme\Bundle\TestBundle\Event\ImportStrategyListener
    services:
    # listen import export before event
    acme_test.event_listener.channel_succeed_import:
    class: %acme_test.import_strategy.listener.class%
    arguments: ["@logger"]
    tags:
    - { name: kernel.event_listener, event: oro_importexport.strategy.process_before, method: onProcessBefore }
    - { name: monolog.logger, channel: acme }

    I have created class and my listener method.

    <?php
    /**
    *
    */
    namespace Acme\Bundle\TestBundle\Event;

    use Symfony\Component\HttpKernel\Log\LoggerInterface;
    use Symfony\Component\Security\Core\SecurityContext;

    use OroCRM\Bundle\MagentoBundle\Entity\Order;
    use Oro\Bundle\ImportExportBundle\Event\StrategyEvent;

    class ImportStrategyListener
    {

    private $logger;

    /**
    * Set new logger
    *
    * @param LoggerInterface $logger
    */
    public function __construct(LoggerInterface $logger)
    {
    $this->logger = $logger;
    }

    /**
    * @param \Oro\Bundle\ImportExportBundle\Event\StrategyEvent $event
    */
    public function onProcessBefore(StrategyEvent $event)
    {
    $entity = $event->getEntity();

    //$this->logger->info("Test information!!!!!");

    if (!$entity instanceof Order) {
    return;
    }
    $orderItems = $entity->getItems();

    foreach($orderItems as $item) {
    $item->setLogoWebPath('test');
    }
    $strategy = $event->getStrategy();
    /**
    $entity = $event->getEntity();
    $strategy = $event->getStrategy();
    **/
    }
    }

    But I don’t know, how I can get data about this field from soap response. If you have some documentation about this, please provide me. Thank you.

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #25039

    Hi.
    AbstractImportStrategy contains $context (instance of ContextInterface). It contains itemData which is your Response data.
    For now there is no get method for it, but you can make it accessible with Reflection API Make property accessible

    We will plan improvement which will provide ability to access context without such workarounds.

Viewing 1 replies (of 1 total)

The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.

Back to top