ssossossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

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 2 years, 5 months ago.

  • Creator
    Topic
  • #22420

    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
  • #22421

    Dmitry Khrysev
    Participant

    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)

You must be logged in to reply to this topic.