/** * Fetch base quote data and map it to DTO fields * * @param Quote $quote * @return array */ public function map(Quote $quote) { return [Cart::ID => $quote->getId(), Cart::STORE_ID => $quote->getStoreId(), Cart::CREATED_AT => $quote->getCreatedAt(), Cart::UPDATED_AT => $quote->getUpdatedAt(), Cart::CONVERTED_AT => $quote->getConvertedAt(), Cart::IS_ACTIVE => $quote->getIsActive(), Cart::IS_VIRTUAL => $quote->getIsVirtual(), Cart::ITEMS_COUNT => $quote->getItemsCount(), Cart::ITEMS_QUANTITY => $quote->getItemsQty(), Cart::CHECKOUT_METHOD => $quote->getCheckoutMethod(), Cart::RESERVED_ORDER_ID => $quote->getReservedOrderId(), Cart::ORIG_ORDER_ID => $quote->getOrigOrderId()]; }
/** * Fetch base quote data and map it to DTO fields * * @param Quote $quote * @return array */ public function map(Quote $quote) { $this->cartBuilder->populateWithArray([Cart::ID => $quote->getId(), Cart::STORE_ID => $quote->getStoreId(), Cart::CREATED_AT => $quote->getCreatedAt(), Cart::UPDATED_AT => $quote->getUpdatedAt(), Cart::CONVERTED_AT => $quote->getConvertedAt(), Cart::IS_ACTIVE => $quote->getIsActive(), Cart::IS_VIRTUAL => $quote->getIsVirtual(), Cart::ITEMS_COUNT => $quote->getItemsCount(), Cart::ITEMS_QUANTITY => $quote->getItemsQty(), Cart::CHECKOUT_METHOD => $quote->getCheckoutMethod(), Cart::RESERVED_ORDER_ID => $quote->getReservedOrderId(), Cart::ORIG_ORDER_ID => $quote->getOrigOrderId()]); $this->customerBuilder->populateWithArray($this->customerMapper->map($quote)); $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote)); $items = []; foreach ($quote->getAllItems() as $item) { $items[] = $this->itemTotalsMapper->extractDto($item); } $this->totalsBuilder->setItems($items); $this->cartBuilder->setCustomer($this->customerBuilder->create()); $this->cartBuilder->setTotals($this->totalsBuilder->create()); $this->cartBuilder->setCurrency($this->currencyMapper->extractDto($quote)); return $this->cartBuilder->create(); }