Getting an error: No such entity with cartId = 17090. How to resolve it





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















This error is generated when I create order using the backend. When creting the order with frontend, it works fine. I am using multi-website functionality in my project.



I have creted custom quote and sales attributes and saved them in quote and sales_order table.



Vendor/OrderAttributes/Plugin/ShippingInformationManagementPlugin.php



<?php

namespace VendorOrderAttributesPlugin;

class ShippingInformationManagementPlugin
{



protected $_transportBuilder;

/**
* @var MagentoFrameworkTranslateInlineStateInterface
*/
protected $inlineTranslation;

/**
* @var MagentoFrameworkAppConfigScopeConfigInterface
*/
protected $scopeConfig;

/**
* @var MagentoStoreModelStoreManagerInterface
*/
protected $storeManager;

/**
* @var MagentoFrameworkEscaper
*/
protected $_escaper;
protected $quoteRepository;

public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoQuoteModelQuoteRepository $quoteRepository
) {
$this->quoteRepository = $quoteRepository;
}

public function beforeSaveAddressInformation(
MagentoCheckoutModelShippingInformationManagement $subject,
$cartId,
MagentoCheckoutApiDataShippingInformationInterface $addressInformation
) {

$request_body = file_get_contents('php://input');
$delivery_details = json_decode($request_body, true);
$quote = $this->quoteRepository->getActive($cartId);

$delivery_date = null;
$crew_members = null;
$travelling_days = null;
$port_id = null;
$port_name = null;
if (isset($delivery_details['delivery_details']['delivery_date'])) {
$delivery_date = $delivery_details['delivery_details']['delivery_date'];
}
if (isset($delivery_details['delivery_details']['crew_members'])) {
$crew_members = $delivery_details['delivery_details']['crew_members'];
}
if (isset($delivery_details['delivery_details']['travelling_days'])) {
$travelling_days = $delivery_details['delivery_details']['travelling_days'];
}
if (isset($delivery_details['delivery_details']['port_id'])) {
$port_id = $delivery_details['delivery_details']['port_id'];
}
if (isset($delivery_details['delivery_details']['port_name'])) {
$port_name = $delivery_details['delivery_details']['port_name'];
}
$quote->setDeliveryDate($delivery_date);
$quote->setCrewMembers($crew_members);
$quote->setTravellingDays($travelling_days);
$quote->setPortId($port_id);
$quote->setPortName($port_name);
$quote->save();
}
}


Vendor/OrderAttributes/Observer/SaveShippingDeliveryToOrderObserver.php



<?php
/**
* Created by PhpStorm.
* User: eugen
* Date: 27.11.2015
* Time: 17:53
*/

namespace VendorOrderAttributesObserver;

use MagentoFrameworkEventObserver as EventObserver;
use MagentoFrameworkEventObserverInterface;

class SaveShippingDeliveryToOrderObserver implements ObserverInterface
{
/**
* @var MagentoFrameworkObjectManagerInterface
*/
protected $_objectManager;

/**
* @param MagentoFrameworkObjectManagerInterface $objectmanager
*/
public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager, MagentoQuoteModelQuoteRepository $quoteRepository, PsrLogLoggerInterface $logger)
{
$this->_objectManager = $objectmanager;
$this->quoteRepository = $quoteRepository;
$this->logger = $logger;
}

public function execute(EventObserver $observer)
{
$order = $observer->getOrder();

$quote = $this->quoteRepository->getActive($order->getQuoteId());
$level = 'DEBUG';
$this->logger->log($level, 'errorlog1234-delivery-details', [$quote->getDeliveryDate(),$quote->getCrewMembers(),$quote->getTravellingDays(),$quote->getPortId(),$quote->getPortName()]);

$order->setDeliveryDate($quote->getDeliveryDate());
$order->setCrewMembers($quote->getCrewMembers());
$order->setTravellingDays($quote->getTravellingDays());
$order->setPortId($quote->getPortId());
$order->setPortName($quote->getPortName());
$order->save();
return $this;
}
}


Vendor/OrderAttributes/Plugin/OrderRepositoryPlugin.php



<?php

namespace VendorOrderAttributesPlugin;

use MagentoSalesApiDataOrderExtensionFactory;
use MagentoSalesApiDataOrderExtensionInterface;
use MagentoSalesApiDataOrderInterface;
use MagentoSalesApiDataOrderSearchResultInterface;
use MagentoSalesApiOrderRepositoryInterface;

/**
* Class OrderRepositoryPlugin
*/
class OrderRepositoryPlugin
{
/**
* Order feedback field name
*/
const DELIVERY_DATE = 'delivery_date';
const CREW_MEMBERS = 'crew_members';
const TRAVELLING_DAYS = 'travelling_days';
const PORT_ID = 'port_id';
const PORT_NAME = 'port_name';

/**
* Order Extension Attributes Factory
*
* @var OrderExtensionFactory
*/
protected $extensionFactory;

/**
* OrderRepositoryPlugin constructor
*
* @param OrderExtensionFactory $extensionFactory
*/
public function __construct(OrderExtensionFactory $extensionFactory)
{
$this->extensionFactory = $extensionFactory;
}

/**
* Add "crew_members" extension attribute to order data object to make it accessible in API data
*
* @param OrderRepositoryInterface $subject
* @param OrderInterface $order
*
* @return OrderInterface
*/
public function afterGet(OrderRepositoryInterface $subject, OrderInterface $order)
{
$DeliveryDate = $order->getData(self::DELIVERY_DATE);
$CrewMembers = $order->getData(self::CREW_MEMBERS);
$TravellingDays = $order->getData(self::TRAVELLING_DAYS);
$PortId = $order->getData(self::PORT_ID);
$PortName = $order->getData(self::PORT_NAME);
$extensionAttributes = $order->getExtensionAttributes();
$extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
$extensionAttributes->setDeliveryDate($DeliveryDate);
$extensionAttributes->setCrewMembers($CrewMembers);
$extensionAttributes->setTravellingDays($TravellingDays);
$extensionAttributes->setPortId($PortId);
$extensionAttributes->setPortName($PortName);
$order->setExtensionAttributes($extensionAttributes);

return $order;
}

/**
* Add "crew_members" extension attribute to order data object to make it accessible in API data
*
* @param OrderRepositoryInterface $subject
* @param OrderSearchResultInterface $searchResult
*
* @return OrderSearchResultInterface
*/
public function afterGetList(OrderRepositoryInterface $subject, OrderSearchResultInterface $searchResult)
{
$orders = $searchResult->getItems();

foreach ($orders as &$order) {
$DeliveryDate = $order->getData(self::DELIVERY_DATE);
$CrewMembers = $order->getData(self::CREW_MEMBERS);
$TravellingDays = $order->getData(self::TRAVELLING_DAYS);
$PortId = $order->getData(self::PORT_ID);
$PortName = $order->getData(self::PORT_NAME);
$extensionAttributes = $order->getExtensionAttributes();
$extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
$extensionAttributes->setDeliveryDate($DeliveryDate);
$extensionAttributes->setCrewMembers($CrewMembers);
$extensionAttributes->setTravellingDays($TravellingDays);
$extensionAttributes->setPortId($PortId);
$extensionAttributes->setPortName($PortName);
$order->setExtensionAttributes($extensionAttributes);
}

return $searchResult;
}
}


Vendor/OrderAttributes/etc/extension_attributes.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="MagentoSalesApiDataOrderInterface">
<attribute code="delivery_date" type="string" />
<attribute code="crew_members" type="integer" />
<attribute code="travelling_days" type="integer" />
<attribute code="port_id" type="integer" />
<attribute code="port_name" type="string" />
</extension_attributes>
</config>








share





























    0















    This error is generated when I create order using the backend. When creting the order with frontend, it works fine. I am using multi-website functionality in my project.



    I have creted custom quote and sales attributes and saved them in quote and sales_order table.



    Vendor/OrderAttributes/Plugin/ShippingInformationManagementPlugin.php



    <?php

    namespace VendorOrderAttributesPlugin;

    class ShippingInformationManagementPlugin
    {



    protected $_transportBuilder;

    /**
    * @var MagentoFrameworkTranslateInlineStateInterface
    */
    protected $inlineTranslation;

    /**
    * @var MagentoFrameworkAppConfigScopeConfigInterface
    */
    protected $scopeConfig;

    /**
    * @var MagentoStoreModelStoreManagerInterface
    */
    protected $storeManager;

    /**
    * @var MagentoFrameworkEscaper
    */
    protected $_escaper;
    protected $quoteRepository;

    public function __construct(
    MagentoFrameworkAppActionContext $context,
    MagentoQuoteModelQuoteRepository $quoteRepository
    ) {
    $this->quoteRepository = $quoteRepository;
    }

    public function beforeSaveAddressInformation(
    MagentoCheckoutModelShippingInformationManagement $subject,
    $cartId,
    MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    ) {

    $request_body = file_get_contents('php://input');
    $delivery_details = json_decode($request_body, true);
    $quote = $this->quoteRepository->getActive($cartId);

    $delivery_date = null;
    $crew_members = null;
    $travelling_days = null;
    $port_id = null;
    $port_name = null;
    if (isset($delivery_details['delivery_details']['delivery_date'])) {
    $delivery_date = $delivery_details['delivery_details']['delivery_date'];
    }
    if (isset($delivery_details['delivery_details']['crew_members'])) {
    $crew_members = $delivery_details['delivery_details']['crew_members'];
    }
    if (isset($delivery_details['delivery_details']['travelling_days'])) {
    $travelling_days = $delivery_details['delivery_details']['travelling_days'];
    }
    if (isset($delivery_details['delivery_details']['port_id'])) {
    $port_id = $delivery_details['delivery_details']['port_id'];
    }
    if (isset($delivery_details['delivery_details']['port_name'])) {
    $port_name = $delivery_details['delivery_details']['port_name'];
    }
    $quote->setDeliveryDate($delivery_date);
    $quote->setCrewMembers($crew_members);
    $quote->setTravellingDays($travelling_days);
    $quote->setPortId($port_id);
    $quote->setPortName($port_name);
    $quote->save();
    }
    }


    Vendor/OrderAttributes/Observer/SaveShippingDeliveryToOrderObserver.php



    <?php
    /**
    * Created by PhpStorm.
    * User: eugen
    * Date: 27.11.2015
    * Time: 17:53
    */

    namespace VendorOrderAttributesObserver;

    use MagentoFrameworkEventObserver as EventObserver;
    use MagentoFrameworkEventObserverInterface;

    class SaveShippingDeliveryToOrderObserver implements ObserverInterface
    {
    /**
    * @var MagentoFrameworkObjectManagerInterface
    */
    protected $_objectManager;

    /**
    * @param MagentoFrameworkObjectManagerInterface $objectmanager
    */
    public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager, MagentoQuoteModelQuoteRepository $quoteRepository, PsrLogLoggerInterface $logger)
    {
    $this->_objectManager = $objectmanager;
    $this->quoteRepository = $quoteRepository;
    $this->logger = $logger;
    }

    public function execute(EventObserver $observer)
    {
    $order = $observer->getOrder();

    $quote = $this->quoteRepository->getActive($order->getQuoteId());
    $level = 'DEBUG';
    $this->logger->log($level, 'errorlog1234-delivery-details', [$quote->getDeliveryDate(),$quote->getCrewMembers(),$quote->getTravellingDays(),$quote->getPortId(),$quote->getPortName()]);

    $order->setDeliveryDate($quote->getDeliveryDate());
    $order->setCrewMembers($quote->getCrewMembers());
    $order->setTravellingDays($quote->getTravellingDays());
    $order->setPortId($quote->getPortId());
    $order->setPortName($quote->getPortName());
    $order->save();
    return $this;
    }
    }


    Vendor/OrderAttributes/Plugin/OrderRepositoryPlugin.php



    <?php

    namespace VendorOrderAttributesPlugin;

    use MagentoSalesApiDataOrderExtensionFactory;
    use MagentoSalesApiDataOrderExtensionInterface;
    use MagentoSalesApiDataOrderInterface;
    use MagentoSalesApiDataOrderSearchResultInterface;
    use MagentoSalesApiOrderRepositoryInterface;

    /**
    * Class OrderRepositoryPlugin
    */
    class OrderRepositoryPlugin
    {
    /**
    * Order feedback field name
    */
    const DELIVERY_DATE = 'delivery_date';
    const CREW_MEMBERS = 'crew_members';
    const TRAVELLING_DAYS = 'travelling_days';
    const PORT_ID = 'port_id';
    const PORT_NAME = 'port_name';

    /**
    * Order Extension Attributes Factory
    *
    * @var OrderExtensionFactory
    */
    protected $extensionFactory;

    /**
    * OrderRepositoryPlugin constructor
    *
    * @param OrderExtensionFactory $extensionFactory
    */
    public function __construct(OrderExtensionFactory $extensionFactory)
    {
    $this->extensionFactory = $extensionFactory;
    }

    /**
    * Add "crew_members" extension attribute to order data object to make it accessible in API data
    *
    * @param OrderRepositoryInterface $subject
    * @param OrderInterface $order
    *
    * @return OrderInterface
    */
    public function afterGet(OrderRepositoryInterface $subject, OrderInterface $order)
    {
    $DeliveryDate = $order->getData(self::DELIVERY_DATE);
    $CrewMembers = $order->getData(self::CREW_MEMBERS);
    $TravellingDays = $order->getData(self::TRAVELLING_DAYS);
    $PortId = $order->getData(self::PORT_ID);
    $PortName = $order->getData(self::PORT_NAME);
    $extensionAttributes = $order->getExtensionAttributes();
    $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
    $extensionAttributes->setDeliveryDate($DeliveryDate);
    $extensionAttributes->setCrewMembers($CrewMembers);
    $extensionAttributes->setTravellingDays($TravellingDays);
    $extensionAttributes->setPortId($PortId);
    $extensionAttributes->setPortName($PortName);
    $order->setExtensionAttributes($extensionAttributes);

    return $order;
    }

    /**
    * Add "crew_members" extension attribute to order data object to make it accessible in API data
    *
    * @param OrderRepositoryInterface $subject
    * @param OrderSearchResultInterface $searchResult
    *
    * @return OrderSearchResultInterface
    */
    public function afterGetList(OrderRepositoryInterface $subject, OrderSearchResultInterface $searchResult)
    {
    $orders = $searchResult->getItems();

    foreach ($orders as &$order) {
    $DeliveryDate = $order->getData(self::DELIVERY_DATE);
    $CrewMembers = $order->getData(self::CREW_MEMBERS);
    $TravellingDays = $order->getData(self::TRAVELLING_DAYS);
    $PortId = $order->getData(self::PORT_ID);
    $PortName = $order->getData(self::PORT_NAME);
    $extensionAttributes = $order->getExtensionAttributes();
    $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
    $extensionAttributes->setDeliveryDate($DeliveryDate);
    $extensionAttributes->setCrewMembers($CrewMembers);
    $extensionAttributes->setTravellingDays($TravellingDays);
    $extensionAttributes->setPortId($PortId);
    $extensionAttributes->setPortName($PortName);
    $order->setExtensionAttributes($extensionAttributes);
    }

    return $searchResult;
    }
    }


    Vendor/OrderAttributes/etc/extension_attributes.xml



    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="MagentoSalesApiDataOrderInterface">
    <attribute code="delivery_date" type="string" />
    <attribute code="crew_members" type="integer" />
    <attribute code="travelling_days" type="integer" />
    <attribute code="port_id" type="integer" />
    <attribute code="port_name" type="string" />
    </extension_attributes>
    </config>








    share

























      0












      0








      0








      This error is generated when I create order using the backend. When creting the order with frontend, it works fine. I am using multi-website functionality in my project.



      I have creted custom quote and sales attributes and saved them in quote and sales_order table.



      Vendor/OrderAttributes/Plugin/ShippingInformationManagementPlugin.php



      <?php

      namespace VendorOrderAttributesPlugin;

      class ShippingInformationManagementPlugin
      {



      protected $_transportBuilder;

      /**
      * @var MagentoFrameworkTranslateInlineStateInterface
      */
      protected $inlineTranslation;

      /**
      * @var MagentoFrameworkAppConfigScopeConfigInterface
      */
      protected $scopeConfig;

      /**
      * @var MagentoStoreModelStoreManagerInterface
      */
      protected $storeManager;

      /**
      * @var MagentoFrameworkEscaper
      */
      protected $_escaper;
      protected $quoteRepository;

      public function __construct(
      MagentoFrameworkAppActionContext $context,
      MagentoQuoteModelQuoteRepository $quoteRepository
      ) {
      $this->quoteRepository = $quoteRepository;
      }

      public function beforeSaveAddressInformation(
      MagentoCheckoutModelShippingInformationManagement $subject,
      $cartId,
      MagentoCheckoutApiDataShippingInformationInterface $addressInformation
      ) {

      $request_body = file_get_contents('php://input');
      $delivery_details = json_decode($request_body, true);
      $quote = $this->quoteRepository->getActive($cartId);

      $delivery_date = null;
      $crew_members = null;
      $travelling_days = null;
      $port_id = null;
      $port_name = null;
      if (isset($delivery_details['delivery_details']['delivery_date'])) {
      $delivery_date = $delivery_details['delivery_details']['delivery_date'];
      }
      if (isset($delivery_details['delivery_details']['crew_members'])) {
      $crew_members = $delivery_details['delivery_details']['crew_members'];
      }
      if (isset($delivery_details['delivery_details']['travelling_days'])) {
      $travelling_days = $delivery_details['delivery_details']['travelling_days'];
      }
      if (isset($delivery_details['delivery_details']['port_id'])) {
      $port_id = $delivery_details['delivery_details']['port_id'];
      }
      if (isset($delivery_details['delivery_details']['port_name'])) {
      $port_name = $delivery_details['delivery_details']['port_name'];
      }
      $quote->setDeliveryDate($delivery_date);
      $quote->setCrewMembers($crew_members);
      $quote->setTravellingDays($travelling_days);
      $quote->setPortId($port_id);
      $quote->setPortName($port_name);
      $quote->save();
      }
      }


      Vendor/OrderAttributes/Observer/SaveShippingDeliveryToOrderObserver.php



      <?php
      /**
      * Created by PhpStorm.
      * User: eugen
      * Date: 27.11.2015
      * Time: 17:53
      */

      namespace VendorOrderAttributesObserver;

      use MagentoFrameworkEventObserver as EventObserver;
      use MagentoFrameworkEventObserverInterface;

      class SaveShippingDeliveryToOrderObserver implements ObserverInterface
      {
      /**
      * @var MagentoFrameworkObjectManagerInterface
      */
      protected $_objectManager;

      /**
      * @param MagentoFrameworkObjectManagerInterface $objectmanager
      */
      public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager, MagentoQuoteModelQuoteRepository $quoteRepository, PsrLogLoggerInterface $logger)
      {
      $this->_objectManager = $objectmanager;
      $this->quoteRepository = $quoteRepository;
      $this->logger = $logger;
      }

      public function execute(EventObserver $observer)
      {
      $order = $observer->getOrder();

      $quote = $this->quoteRepository->getActive($order->getQuoteId());
      $level = 'DEBUG';
      $this->logger->log($level, 'errorlog1234-delivery-details', [$quote->getDeliveryDate(),$quote->getCrewMembers(),$quote->getTravellingDays(),$quote->getPortId(),$quote->getPortName()]);

      $order->setDeliveryDate($quote->getDeliveryDate());
      $order->setCrewMembers($quote->getCrewMembers());
      $order->setTravellingDays($quote->getTravellingDays());
      $order->setPortId($quote->getPortId());
      $order->setPortName($quote->getPortName());
      $order->save();
      return $this;
      }
      }


      Vendor/OrderAttributes/Plugin/OrderRepositoryPlugin.php



      <?php

      namespace VendorOrderAttributesPlugin;

      use MagentoSalesApiDataOrderExtensionFactory;
      use MagentoSalesApiDataOrderExtensionInterface;
      use MagentoSalesApiDataOrderInterface;
      use MagentoSalesApiDataOrderSearchResultInterface;
      use MagentoSalesApiOrderRepositoryInterface;

      /**
      * Class OrderRepositoryPlugin
      */
      class OrderRepositoryPlugin
      {
      /**
      * Order feedback field name
      */
      const DELIVERY_DATE = 'delivery_date';
      const CREW_MEMBERS = 'crew_members';
      const TRAVELLING_DAYS = 'travelling_days';
      const PORT_ID = 'port_id';
      const PORT_NAME = 'port_name';

      /**
      * Order Extension Attributes Factory
      *
      * @var OrderExtensionFactory
      */
      protected $extensionFactory;

      /**
      * OrderRepositoryPlugin constructor
      *
      * @param OrderExtensionFactory $extensionFactory
      */
      public function __construct(OrderExtensionFactory $extensionFactory)
      {
      $this->extensionFactory = $extensionFactory;
      }

      /**
      * Add "crew_members" extension attribute to order data object to make it accessible in API data
      *
      * @param OrderRepositoryInterface $subject
      * @param OrderInterface $order
      *
      * @return OrderInterface
      */
      public function afterGet(OrderRepositoryInterface $subject, OrderInterface $order)
      {
      $DeliveryDate = $order->getData(self::DELIVERY_DATE);
      $CrewMembers = $order->getData(self::CREW_MEMBERS);
      $TravellingDays = $order->getData(self::TRAVELLING_DAYS);
      $PortId = $order->getData(self::PORT_ID);
      $PortName = $order->getData(self::PORT_NAME);
      $extensionAttributes = $order->getExtensionAttributes();
      $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
      $extensionAttributes->setDeliveryDate($DeliveryDate);
      $extensionAttributes->setCrewMembers($CrewMembers);
      $extensionAttributes->setTravellingDays($TravellingDays);
      $extensionAttributes->setPortId($PortId);
      $extensionAttributes->setPortName($PortName);
      $order->setExtensionAttributes($extensionAttributes);

      return $order;
      }

      /**
      * Add "crew_members" extension attribute to order data object to make it accessible in API data
      *
      * @param OrderRepositoryInterface $subject
      * @param OrderSearchResultInterface $searchResult
      *
      * @return OrderSearchResultInterface
      */
      public function afterGetList(OrderRepositoryInterface $subject, OrderSearchResultInterface $searchResult)
      {
      $orders = $searchResult->getItems();

      foreach ($orders as &$order) {
      $DeliveryDate = $order->getData(self::DELIVERY_DATE);
      $CrewMembers = $order->getData(self::CREW_MEMBERS);
      $TravellingDays = $order->getData(self::TRAVELLING_DAYS);
      $PortId = $order->getData(self::PORT_ID);
      $PortName = $order->getData(self::PORT_NAME);
      $extensionAttributes = $order->getExtensionAttributes();
      $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
      $extensionAttributes->setDeliveryDate($DeliveryDate);
      $extensionAttributes->setCrewMembers($CrewMembers);
      $extensionAttributes->setTravellingDays($TravellingDays);
      $extensionAttributes->setPortId($PortId);
      $extensionAttributes->setPortName($PortName);
      $order->setExtensionAttributes($extensionAttributes);
      }

      return $searchResult;
      }
      }


      Vendor/OrderAttributes/etc/extension_attributes.xml



      <?xml version="1.0"?>
      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
      <extension_attributes for="MagentoSalesApiDataOrderInterface">
      <attribute code="delivery_date" type="string" />
      <attribute code="crew_members" type="integer" />
      <attribute code="travelling_days" type="integer" />
      <attribute code="port_id" type="integer" />
      <attribute code="port_name" type="string" />
      </extension_attributes>
      </config>








      share














      This error is generated when I create order using the backend. When creting the order with frontend, it works fine. I am using multi-website functionality in my project.



      I have creted custom quote and sales attributes and saved them in quote and sales_order table.



      Vendor/OrderAttributes/Plugin/ShippingInformationManagementPlugin.php



      <?php

      namespace VendorOrderAttributesPlugin;

      class ShippingInformationManagementPlugin
      {



      protected $_transportBuilder;

      /**
      * @var MagentoFrameworkTranslateInlineStateInterface
      */
      protected $inlineTranslation;

      /**
      * @var MagentoFrameworkAppConfigScopeConfigInterface
      */
      protected $scopeConfig;

      /**
      * @var MagentoStoreModelStoreManagerInterface
      */
      protected $storeManager;

      /**
      * @var MagentoFrameworkEscaper
      */
      protected $_escaper;
      protected $quoteRepository;

      public function __construct(
      MagentoFrameworkAppActionContext $context,
      MagentoQuoteModelQuoteRepository $quoteRepository
      ) {
      $this->quoteRepository = $quoteRepository;
      }

      public function beforeSaveAddressInformation(
      MagentoCheckoutModelShippingInformationManagement $subject,
      $cartId,
      MagentoCheckoutApiDataShippingInformationInterface $addressInformation
      ) {

      $request_body = file_get_contents('php://input');
      $delivery_details = json_decode($request_body, true);
      $quote = $this->quoteRepository->getActive($cartId);

      $delivery_date = null;
      $crew_members = null;
      $travelling_days = null;
      $port_id = null;
      $port_name = null;
      if (isset($delivery_details['delivery_details']['delivery_date'])) {
      $delivery_date = $delivery_details['delivery_details']['delivery_date'];
      }
      if (isset($delivery_details['delivery_details']['crew_members'])) {
      $crew_members = $delivery_details['delivery_details']['crew_members'];
      }
      if (isset($delivery_details['delivery_details']['travelling_days'])) {
      $travelling_days = $delivery_details['delivery_details']['travelling_days'];
      }
      if (isset($delivery_details['delivery_details']['port_id'])) {
      $port_id = $delivery_details['delivery_details']['port_id'];
      }
      if (isset($delivery_details['delivery_details']['port_name'])) {
      $port_name = $delivery_details['delivery_details']['port_name'];
      }
      $quote->setDeliveryDate($delivery_date);
      $quote->setCrewMembers($crew_members);
      $quote->setTravellingDays($travelling_days);
      $quote->setPortId($port_id);
      $quote->setPortName($port_name);
      $quote->save();
      }
      }


      Vendor/OrderAttributes/Observer/SaveShippingDeliveryToOrderObserver.php



      <?php
      /**
      * Created by PhpStorm.
      * User: eugen
      * Date: 27.11.2015
      * Time: 17:53
      */

      namespace VendorOrderAttributesObserver;

      use MagentoFrameworkEventObserver as EventObserver;
      use MagentoFrameworkEventObserverInterface;

      class SaveShippingDeliveryToOrderObserver implements ObserverInterface
      {
      /**
      * @var MagentoFrameworkObjectManagerInterface
      */
      protected $_objectManager;

      /**
      * @param MagentoFrameworkObjectManagerInterface $objectmanager
      */
      public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager, MagentoQuoteModelQuoteRepository $quoteRepository, PsrLogLoggerInterface $logger)
      {
      $this->_objectManager = $objectmanager;
      $this->quoteRepository = $quoteRepository;
      $this->logger = $logger;
      }

      public function execute(EventObserver $observer)
      {
      $order = $observer->getOrder();

      $quote = $this->quoteRepository->getActive($order->getQuoteId());
      $level = 'DEBUG';
      $this->logger->log($level, 'errorlog1234-delivery-details', [$quote->getDeliveryDate(),$quote->getCrewMembers(),$quote->getTravellingDays(),$quote->getPortId(),$quote->getPortName()]);

      $order->setDeliveryDate($quote->getDeliveryDate());
      $order->setCrewMembers($quote->getCrewMembers());
      $order->setTravellingDays($quote->getTravellingDays());
      $order->setPortId($quote->getPortId());
      $order->setPortName($quote->getPortName());
      $order->save();
      return $this;
      }
      }


      Vendor/OrderAttributes/Plugin/OrderRepositoryPlugin.php



      <?php

      namespace VendorOrderAttributesPlugin;

      use MagentoSalesApiDataOrderExtensionFactory;
      use MagentoSalesApiDataOrderExtensionInterface;
      use MagentoSalesApiDataOrderInterface;
      use MagentoSalesApiDataOrderSearchResultInterface;
      use MagentoSalesApiOrderRepositoryInterface;

      /**
      * Class OrderRepositoryPlugin
      */
      class OrderRepositoryPlugin
      {
      /**
      * Order feedback field name
      */
      const DELIVERY_DATE = 'delivery_date';
      const CREW_MEMBERS = 'crew_members';
      const TRAVELLING_DAYS = 'travelling_days';
      const PORT_ID = 'port_id';
      const PORT_NAME = 'port_name';

      /**
      * Order Extension Attributes Factory
      *
      * @var OrderExtensionFactory
      */
      protected $extensionFactory;

      /**
      * OrderRepositoryPlugin constructor
      *
      * @param OrderExtensionFactory $extensionFactory
      */
      public function __construct(OrderExtensionFactory $extensionFactory)
      {
      $this->extensionFactory = $extensionFactory;
      }

      /**
      * Add "crew_members" extension attribute to order data object to make it accessible in API data
      *
      * @param OrderRepositoryInterface $subject
      * @param OrderInterface $order
      *
      * @return OrderInterface
      */
      public function afterGet(OrderRepositoryInterface $subject, OrderInterface $order)
      {
      $DeliveryDate = $order->getData(self::DELIVERY_DATE);
      $CrewMembers = $order->getData(self::CREW_MEMBERS);
      $TravellingDays = $order->getData(self::TRAVELLING_DAYS);
      $PortId = $order->getData(self::PORT_ID);
      $PortName = $order->getData(self::PORT_NAME);
      $extensionAttributes = $order->getExtensionAttributes();
      $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
      $extensionAttributes->setDeliveryDate($DeliveryDate);
      $extensionAttributes->setCrewMembers($CrewMembers);
      $extensionAttributes->setTravellingDays($TravellingDays);
      $extensionAttributes->setPortId($PortId);
      $extensionAttributes->setPortName($PortName);
      $order->setExtensionAttributes($extensionAttributes);

      return $order;
      }

      /**
      * Add "crew_members" extension attribute to order data object to make it accessible in API data
      *
      * @param OrderRepositoryInterface $subject
      * @param OrderSearchResultInterface $searchResult
      *
      * @return OrderSearchResultInterface
      */
      public function afterGetList(OrderRepositoryInterface $subject, OrderSearchResultInterface $searchResult)
      {
      $orders = $searchResult->getItems();

      foreach ($orders as &$order) {
      $DeliveryDate = $order->getData(self::DELIVERY_DATE);
      $CrewMembers = $order->getData(self::CREW_MEMBERS);
      $TravellingDays = $order->getData(self::TRAVELLING_DAYS);
      $PortId = $order->getData(self::PORT_ID);
      $PortName = $order->getData(self::PORT_NAME);
      $extensionAttributes = $order->getExtensionAttributes();
      $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
      $extensionAttributes->setDeliveryDate($DeliveryDate);
      $extensionAttributes->setCrewMembers($CrewMembers);
      $extensionAttributes->setTravellingDays($TravellingDays);
      $extensionAttributes->setPortId($PortId);
      $extensionAttributes->setPortName($PortName);
      $order->setExtensionAttributes($extensionAttributes);
      }

      return $searchResult;
      }
      }


      Vendor/OrderAttributes/etc/extension_attributes.xml



      <?xml version="1.0"?>
      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
      <extension_attributes for="MagentoSalesApiDataOrderInterface">
      <attribute code="delivery_date" type="string" />
      <attribute code="crew_members" type="integer" />
      <attribute code="travelling_days" type="integer" />
      <attribute code="port_id" type="integer" />
      <attribute code="port_name" type="string" />
      </extension_attributes>
      </config>






      magento2.2 sales-order





      share












      share










      share



      share










      asked 34 secs ago









      Meetali GuptaMeetali Gupta

      264




      264






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270238%2fgetting-an-error-no-such-entity-with-cartid-17090-how-to-resolve-it%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270238%2fgetting-an-error-no-such-entity-with-cartid-17090-how-to-resolve-it%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          What other Star Trek series did the main TNG cast show up in?

          Berlina muro

          Berlina aerponto