Overview
  • Package
  • Class
  • Tree
  • Todo

Packages

  • AddonValue
    • Interfaces
  • ApiV2Controllers
  • Category
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Providers
    • Repositories
    • Storages
  • Customer
    • Address
    • Country
    • CountryZone
    • Interfaces
    • Validation
    • ValueObjects
  • Email
    • Collections
    • Entities
    • Exceptions
    • Interfaces
    • Repository
    • ValueObjects
  • Http
    • Collections
    • Exceptions
    • Factories
    • Interfaces
    • ValueObjects
  • Loaders
    • CrossCuttingLoader
    • GXCoreLoader
    • Interfaces
  • None
  • Order
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Repositories
    • Storages
    • ValueObjects
  • Product
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Providers
    • Repositories
    • Storages
  • ProductModule
    • Collections
    • Deleter
    • Entities
    • Factories
    • Interface
    • Interfaces
    • Reader
    • Repositories
    • Writer
  • Shared
    • Exceptions
    • FileSystem
    • Interfaces
    • Storage
    • Types
  • Statistics
    • Interfaces
  • UserConfiguration
    • Interfaces
    • Repository

Classes

  • AbstractAddonValueServiceFactory
  • AbstractAddonValueStorage
  • AbstractApiV2Controller
  • AbstractCategoryServiceFactory
  • AbstractCollection
  • AbstractCustomerFactory
  • AbstractCustomerServiceFactory
  • AbstractFileStorage
  • AbstractHttpContextFactory
  • AbstractHttpViewControllerRegistryFactory
  • AbstractImagesApiV2Controller
  • AbstractOrderServiceFactory
  • AbstractProductAttributeServiceFactory
  • AbstractProductServiceFactory
  • AddonValueService
  • AddonValueServiceFactory
  • AddonValueStorageFactory
  • AddressBlock
  • AddressBookService
  • AddressClass
  • AddressesApiV2Controller
  • AddressFormatProvider
  • AdminHttpViewController
  • AdminPageHttpControllerResponse
  • Asset
  • AssetCollection
  • AttachmentCollection
  • AttachmentName
  • AttachmentPath
  • AttachmentsApiV2Controller
  • AttachmentsHandler
  • BoolType
  • CategoriesApiV2Controller
  • Category
  • CategoryAddonValueStorage
  • CategoryFactory
  • CategoryIconsApiV2Controller
  • CategoryImagesApiV2Controller
  • CategoryListItem
  • CategoryListItemCollection
  • CategoryListProvider
  • CategoryListProviderFactory
  • CategoryObjectService
  • CategoryReadService
  • CategoryRepository
  • CategoryRepositoryDeleter
  • CategoryRepositoryReader
  • CategoryRepositoryWriter
  • CategoryServiceFactory
  • CategorySettings
  • CategorySettingsRepository
  • CategorySettingsRepositoryReader
  • CategorySettingsRepositoryWriter
  • CategoryWriteService
  • ContactCollection
  • ContactName
  • ContactType
  • CountriesApiV2Controller
  • CountryService
  • CrossCuttingLoader
  • CurrencyCode
  • Customer
  • CustomerAccountInputValidator
  • CustomerAddress
  • CustomerAddressDeleter
  • CustomerAddressInputValidator
  • CustomerAddressReader
  • CustomerAddressRepository
  • CustomerAddressWriter
  • CustomerB2BStatus
  • CustomerCallNumber
  • CustomerCity
  • CustomerCompany
  • CustomerCountry
  • CustomerCountryIso2
  • CustomerCountryIso3
  • CustomerCountryName
  • CustomerCountryReader
  • CustomerCountryRepository
  • CustomerCountryZone
  • CustomerCountryZoneIsoCode
  • CustomerCountryZoneName
  • CustomerCountryZoneReader
  • CustomerCountryZoneRepository
  • CustomerDateOfBirth
  • CustomerDeleter
  • CustomerEmail
  • CustomerFactory
  • CustomerFirstname
  • CustomerGender
  • CustomerInputValidator
  • CustomerInputValidatorSettings
  • CustomerLastname
  • CustomerNumber
  • CustomerPassword
  • CustomerPostcode
  • CustomerReader
  • CustomerReadService
  • CustomerRegistrationInputValidatorService
  • CustomerRepository
  • CustomersApiV2Controller
  • CustomerService
  • CustomerServiceFactory
  • CustomerServiceSettings
  • CustomerStatusInformation
  • CustomerStatusProvider
  • CustomerStreet
  • CustomerSuburb
  • CustomerVatNumber
  • CustomerWriter
  • CustomerWriteService
  • DecimalType
  • DefaultApiV2Controller
  • EditableCollection
  • EditableKeyValueCollection
  • Email
  • EmailAddress
  • EmailAttachment
  • EmailCollection
  • EmailContact
  • EmailContent
  • EmailDeleter
  • EmailFactory
  • EmailReader
  • EmailRepository
  • EmailsApiV2Controller
  • EmailService
  • EmailStringType
  • EmailSubject
  • EmailWriter
  • EmptyCurrencyCode
  • EmptyDateTime
  • EmptyLanguageCode
  • EmptyOrderItemDownloadInformation
  • EmptyProductImage
  • EnvCategoryServiceSettings
  • EnvironmentHttpContextFactory
  • EnvironmentHttpViewControllerRegistryFactory
  • EnvProductImageFileStorageSettings
  • ExistingDirectory
  • ExistingFile
  • FilenameStringType
  • GXCoreLoader
  • GXCoreLoaderSettings
  • GXEngineOrder
  • GXEngineProduct
  • HttpApiV2Controller
  • HttpContext
  • HttpContextReader
  • HttpControllerResponse
  • HttpDispatcher
  • HttpResponseProcessor
  • HttpService
  • HttpServiceFactory
  • HttpViewController
  • HttpViewControllerFactory
  • HttpViewControllerRegistry
  • IdCollection
  • IdType
  • ImageFileStorage
  • IntType
  • JsonHttpControllerResponse
  • KeyValueCollection
  • LanguageCode
  • LegacyProductImageProcessing
  • MailerAdapter
  • NonEmptyStringType
  • OrderAddonValueStorage
  • OrderFactory
  • OrderItem
  • OrderItemAddonValueStorage
  • OrderItemAttribute
  • OrderItemAttributeCollection
  • OrderItemAttributeFactory
  • OrderItemAttributeRepository
  • OrderItemAttributeRepositoryDeleter
  • OrderItemAttributeRepositoryFactory
  • OrderItemAttributeRepositoryReader
  • OrderItemAttributeRepositoryWriter
  • OrderItemCollection
  • OrderItemDownloadInformation
  • OrderItemFactory
  • OrderItemProperty
  • OrderItemPropertyFactory
  • OrderItemPropertyRepository
  • OrderItemPropertyRepositoryDeleter
  • OrderItemPropertyRepositoryReader
  • OrderItemPropertyRepositoryWriter
  • OrderItemRepository
  • OrderItemRepositoryDeleter
  • OrderItemRepositoryReader
  • OrderItemRepositoryWriter
  • OrderListGenerator
  • OrderListItem
  • OrderListItemCollection
  • OrderObjectService
  • OrderPaymentType
  • OrderReadService
  • OrderRepository
  • OrderRepositoryDeleter
  • OrderRepositoryReader
  • OrderRepositoryWriter
  • OrdersApiV2Controller
  • OrderServiceFactory
  • OrderServiceSettings
  • OrderShippingType
  • OrdersHistoryApiV2Controller
  • OrdersItemsApiV2Controller
  • OrdersItemsAttributesApiV2Controller
  • OrderStatusHistoryListItem
  • OrderStatusHistoryListItemCollection
  • OrderStatusHistoryStorage
  • OrdersTotalsApiV2Controller
  • OrderTotal
  • OrderTotalCollection
  • OrderTotalFactory
  • OrderTotalRepository
  • OrderTotalRepositoryDeleter
  • OrderTotalRepositoryReader
  • OrderTotalRepositoryWriter
  • OrderWriteService
  • ProductAddonValueStorage
  • ProductAttribute
  • ProductAttributeCollection
  • ProductAttributeFactory
  • ProductAttributeObjectService
  • ProductAttributeRepository
  • ProductAttributeRepositoryDeleter
  • ProductAttributeRepositoryReader
  • ProductAttributeRepositoryWriter
  • ProductAttributeService
  • ProductAttributeServiceFactory
  • ProductCategoryLinker
  • ProductFactory
  • ProductImage
  • ProductImageCollection
  • ProductImageContainer
  • ProductImageContainerRepository
  • ProductImageFileStorage
  • ProductImagesApiV2Controller
  • ProductListItem
  • ProductListItemCollection
  • ProductListProvider
  • ProductListProviderFactory
  • ProductObjectService
  • ProductPermissionSetter
  • ProductReadService
  • ProductRepository
  • ProductRepositoryDeleter
  • ProductRepositoryReader
  • ProductRepositoryWriter
  • ProductsApiV2Controller
  • ProductServiceFactory
  • ProductSettings
  • ProductSettingsRepository
  • ProductSettingsRepositoryReader
  • ProductSettingsRepositoryWriter
  • ProductsLinksApiV2Controller
  • ProductWriteService
  • RedirectHttpControllerResponse
  • StaticCrossCuttingLoader
  • StaticGXCoreLoader
  • StatisticsService
  • StoredCategory
  • StoredOrderItem
  • StoredOrderItemAttribute
  • StoredOrderItemAttributeCollection
  • StoredOrderItemCollection
  • StoredOrderItemProperty
  • StoredOrderTotal
  • StoredOrderTotalCollection
  • StoredProduct
  • StoredProductAttribute
  • StoredProductAttributeCollection
  • StringCollection
  • StringType
  • UserConfigurationReader
  • UserConfigurationService
  • UserConfigurationWriter
  • VatNumberValidator
  • WritableDirectory
  • WritableFile
  • YetAnotherLanguageProvider
  • ZonesApiV2Controller

Interfaces

  • AddonValueContainerInterface
  • AddonValueServiceInterface
  • AddonValueStorageFactoryInterface
  • AddressBlockInterface
  • AddressBookServiceInterface
  • AddressClassInterface
  • AddressFormatProviderInterface
  • AssetCollectionInterface
  • AssetInterface
  • AttachmentCollectionInterface
  • AttachmentNameInterface
  • AttachmentPathInterface
  • AttachmentsHandlerInterface
  • CategoryFactoryInterface
  • CategoryInterface
  • CategoryListProviderFactoryInterface
  • CategoryListProviderInterface
  • CategoryObjectServiceInterface
  • CategoryReadServiceInterface
  • CategoryRepositoryDeleterInterface
  • CategoryRepositoryInterface
  • CategoryRepositoryReaderInterface
  • CategoryRepositoryWriterInterface
  • CategoryServiceSettingsInterface
  • CategorySettingsInterface
  • CategorySettingsRepositoryInterface
  • CategorySettingsRepositoryReaderInterface
  • CategorySettingsRepositoryWriterInterface
  • CategoryWriteServiceInterface
  • ContactCollectionInterface
  • ContactNameInterface
  • ContactTypeInterface
  • ContentViewInterface
  • CountryServiceInterface
  • CrossCuttingLoaderInterface
  • CrossCuttingObjectInterface
  • CustomerAccountInputValidatorInterface
  • CustomerAddressDeleterInterface
  • CustomerAddressInputValidatorInterface
  • CustomerAddressInterface
  • CustomerAddressReaderInterface
  • CustomerAddressRepositoryInterface
  • CustomerAddressWriterInterface
  • CustomerB2BStatusInterface
  • CustomerCallNumberInterface
  • CustomerCityInterface
  • CustomerCompanyInterface
  • CustomerCountryInterface
  • CustomerCountryIso2Interface
  • CustomerCountryIso3Interface
  • CustomerCountryNameInterface
  • CustomerCountryReaderInterface
  • CustomerCountryRepositoryInterface
  • CustomerCountryZoneInterface
  • CustomerCountryZoneIsoCodeInterface
  • CustomerCountryZoneNameInterface
  • CustomerCountryZoneReaderInterface
  • CustomerCountryZoneRepositoryInterface
  • CustomerDeleterInterface
  • CustomerEmailInterface
  • CustomerFirstnameInterface
  • CustomerGenderInterface
  • CustomerInputValidatorInterface
  • CustomerInputValidatorSettingsInterface
  • CustomerInterface
  • CustomerLastnameInterface
  • CustomerNumberInterface
  • CustomerPasswordInterface
  • CustomerPostcodeInterface
  • CustomerReaderInterface
  • CustomerReadServiceInterface
  • CustomerRegistrationInputValidatorServiceInterface
  • CustomerRepositoryInterface
  • CustomerServiceInterface
  • CustomerServiceSettingsInterface
  • CustomerStatusProviderInterface
  • CustomerStreetInterface
  • CustomerSuburbInterface
  • CustomerVatNumberInterface
  • CustomerWriterInterface
  • CustomerWriteServiceInterface
  • EmailAddressInterface
  • EmailAttachmentInterface
  • EmailCollectionInterface
  • EmailContactInterface
  • EmailContentInterface
  • EmailDeleterInterface
  • EmailFactoryInterface
  • EmailInterface
  • EmailReaderInterface
  • EmailRepositoryInterface
  • EmailServiceInterface
  • EmailSubjectInterface
  • EmailWriterInterface
  • GXCoreLoaderInterface
  • GXCoreLoaderSettingsInterface
  • HttpContextInterface
  • HttpContextReaderInterface
  • HttpControllerResponseInterface
  • HttpDispatcherInterface
  • HttpResponseProcessorInterface
  • HttpServiceFactoryInterface
  • HttpServiceInterface
  • HttpViewControllerFactoryInterface
  • HttpViewControllerInterface
  • HttpViewControllerRegistryInterface
  • IdInterface
  • LanguageProviderInterface
  • MailerAdapterInterface
  • OrderFactoryInterface
  • OrderInterface
  • OrderItemAttributeFactoryInterface
  • OrderItemAttributeInterface
  • OrderItemAttributeRepositoryDeleterInterface
  • OrderItemAttributeRepositoryFactoryInterface
  • OrderItemAttributeRepositoryInterface
  • OrderItemAttributeRepositoryReaderInterface
  • OrderItemAttributeRepositoryWriterInterface
  • OrderItemFactoryInterface
  • OrderItemInterface
  • OrderItemPropertyFactoryInterface
  • OrderItemPropertyRepositoryDeleterInterface
  • OrderItemPropertyRepositoryReaderInterface
  • OrderItemPropertyRepositoryWriterInterface
  • OrderItemRepositoryDeleterInterface
  • OrderItemRepositoryInterface
  • OrderItemRepositoryReaderInterface
  • OrderItemRepositoryWriterInterface
  • OrderListGeneratorInterface
  • OrderObjectServiceInterface
  • OrderPaymentTypeInterface
  • OrderReadServiceInterface
  • OrderRepositoryDeleterInterface
  • OrderRepositoryInterface
  • OrderRepositoryReaderInterface
  • OrderRepositoryWriterInterface
  • OrderServiceSettingsInterface
  • OrderShippingTypeInterface
  • OrderStatusHistoryReaderInterface
  • OrderStatusHistoryWriterInterface
  • OrderTotalFactoryInterface
  • OrderTotalInterface
  • OrderTotalRepositoryDeleterInterface
  • OrderTotalRepositoryInterface
  • OrderTotalRepositoryReaderInterface
  • OrderTotalRepositoryWriterInterface
  • OrderWriteServiceInterface
  • ProductAttributeFactoryInterface
  • ProductAttributeInterface
  • ProductAttributeObjectServiceInterface
  • ProductAttributeRepositoryDeleterInterface
  • ProductAttributeRepositoryInterface
  • ProductAttributeRepositoryReaderInterface
  • ProductAttributeRepositoryWriterInterface
  • ProductAttributeServiceInterface
  • ProductCategoryLinkerInterface
  • ProductFactoryInterface
  • ProductImageContainerInterface
  • ProductImageContainerRepositoryInterface
  • ProductImageInterface
  • ProductImagePathsSettingsInterface
  • ProductImageProcessingInterface
  • ProductInterface
  • ProductListProviderFactoryInterface
  • ProductListProviderInterface
  • ProductObjectServiceInterface
  • ProductPermissionSetterInterface
  • ProductReadServiceInterface
  • ProductRepositoryDeleterInterface
  • ProductRepositoryInterface
  • ProductRepositoryReaderInterface
  • ProductRepositoryWriterInterface
  • ProductSettingsInterface
  • ProductSettingsRepositoryInterface
  • ProductSettingsRepositoryReaderInterface
  • ProductSettingsRepositoryWriterInterface
  • ProductWriteServiceInterface
  • StatisticsServiceInterface
  • StoredCategoryInterface
  • StoredOrderItemAttributeInterface
  • StoredOrderItemInterface
  • StoredOrderTotalInterface
  • StoredProductAttributeInterface
  • StoredProductInterface
  • UserConfigurationReaderInterface
  • UserConfigurationServiceInterface
  • UserConfigurationWriterInterface
  • VatNumberValidatorInterface

Exceptions

  • AjaxException
  • AttachmentNotFoundException
  • FileNotFoundException
  • HttpApiV2Exception
  • MissingControllerNameException
  • UnknownEnvironmentException
  1 <?php
  2 /* --------------------------------------------------------------
  3    OrderItemRepository.inc.php 2015-12-22
  4    Gambio GmbH
  5    http://www.gambio.de
  6    Copyright (c) 2015 Gambio GmbH
  7    Released under the GNU General Public License (Version 2)
  8    [http://www.gnu.org/licenses/gpl-2.0.html]
  9    --------------------------------------------------------------
 10 */
 11 
 12 MainFactory::load_class('OrderItemRepositoryInterface');
 13 
 14 /**
 15  * Class OrderItemRepository
 16  *
 17  * @category   System
 18  * @package    Order
 19  * @subpackage Repositories
 20  */
 21 class OrderItemRepository implements OrderItemRepositoryInterface
 22 {
 23     /**
 24      * Order item attribute repository factory.
 25      * @var OrderItemAttributeRepositoryFactoryInterface
 26      */
 27     protected $orderItemAttributeRepositoryFactory;
 28     
 29     /**
 30      * Order item repository reader.
 31      * @var OrderItemRepositoryReaderInterface
 32      */
 33     protected $orderItemRepositoryReader;
 34     
 35     /**
 36      * Order item repository writer.
 37      * @var OrderItemRepositoryWriterInterface
 38      */
 39     protected $orderItemRepositoryWriter;
 40     
 41     /**
 42      * Order item repository deleter.
 43      * @var OrderItemRepositoryDeleterInterface
 44      */
 45     protected $orderItemRepositoryDeleter;
 46     
 47     /**
 48      * Addon value service.
 49      * @var AddonValueServiceInterface
 50      */
 51     protected $addonValueService;
 52     
 53     
 54     /**
 55      * OrderItemRepository constructor.
 56      *
 57      * @param OrderItemAttributeRepositoryFactoryInterface $orderItemAttributeRepositoryFactory  Factory to create
 58      *                                                                                           order item attribute
 59      *                                                                                           repositories.
 60      * @param OrderItemRepositoryReaderInterface           $orderItemRepositoryReader            Db reader for order
 61      *                                                                                           item repository.
 62      * @param OrderItemRepositoryWriterInterface           $orderItemRepositoryWriter            Db writer for order
 63      *                                                                                           item repository.
 64      * @param OrderItemRepositoryDeleterInterface          $orderItemRepositoryDeleter           Db deleter for order
 65      *                                                                                           item repository.
 66      * @param AddonValueServiceInterface                   $addonValueService                    Addon value service.
 67      */
 68     public function __construct(OrderItemAttributeRepositoryFactoryInterface $orderItemAttributeRepositoryFactory,
 69                                 OrderItemRepositoryReaderInterface $orderItemRepositoryReader,
 70                                 OrderItemRepositoryWriterInterface $orderItemRepositoryWriter,
 71                                 OrderItemRepositoryDeleterInterface $orderItemRepositoryDeleter,
 72                                 AddonValueServiceInterface $addonValueService)
 73     {
 74         $this->orderItemAttributeRepositoryFactory = $orderItemAttributeRepositoryFactory;
 75         $this->orderItemRepositoryReader           = $orderItemRepositoryReader;
 76         $this->orderItemRepositoryWriter           = $orderItemRepositoryWriter;
 77         $this->orderItemRepositoryDeleter          = $orderItemRepositoryDeleter;
 78         $this->addonValueService                   = $addonValueService;
 79     }
 80     
 81     
 82     /**
 83      * Adds an order item to the order item repository.
 84      *
 85      * @param IdType             $orderId   Order ID.
 86      * @param OrderItemInterface $orderItem Order item to add.
 87      *
 88      * @return int ID of the StoredOrderItem
 89      */
 90     public function addToOrder(IdType $orderId, OrderItemInterface $orderItem)
 91     {
 92         $storedOrderItemId = $this->orderItemRepositoryWriter->insertIntoOrder($orderId, $orderItem);
 93         
 94         /** @var AddonValueContainerInterface $storedOrderItem */
 95         $storedOrderItem = $this->getItemById(new IdType($storedOrderItemId));
 96         $storedOrderItem->addAddonValues($orderItem->getAddonValues());
 97         $this->addonValueService->storeAddonValues($storedOrderItem);
 98         
 99         $this->_delegateToAttributeRepositories($orderItem, $storedOrderItemId);
100         
101         return $storedOrderItemId;
102     }
103     
104     
105     /**
106      * Saves the order item in the repository.
107      *
108      * @param StoredOrderItemInterface $storedOrderItem Order item to save.
109      *
110      * @return OrderItemRepository Same instance for method chaining.
111      */
112     public function store(StoredOrderItemInterface $storedOrderItem)
113     {
114         $this->orderItemRepositoryWriter->update($storedOrderItem);
115         $this->addonValueService->storeAddonValues($storedOrderItem);
116         
117         return $this->_delegateToAttributeRepositories($storedOrderItem);
118     }
119     
120     
121     /**
122      * Returns a stored order ID by the given order item ID.
123      *
124      * @param IdType $orderItemId ID of the stored order item.
125      *
126      * @return StoredOrderItemInterface Stored order item.
127      */
128     public function getItemById(IdType $orderItemId)
129     {
130         /** @var StoredOrderItemInterface|AddonValueContainerInterface $storedOrderItem */
131         $storedOrderItem = $this->orderItemRepositoryReader->getItemById($orderItemId);
132         $repositoryArray = $this->orderItemAttributeRepositoryFactory->createRepositoryArray();
133         
134         /** @var StoredOrderItemAttributeCollection $attributeCollection */
135         $attributeCollection = null;
136         foreach($repositoryArray as $repository)
137         {
138             if(null === $attributeCollection)
139             {
140                 $attributeCollection = $repository->getItemAttributesByOrderItemId(new IdType($storedOrderItem->getOrderItemId()));
141             }
142             else
143             {
144                 $newCollection = $repository->getItemAttributesByOrderItemId(new IdType($storedOrderItem->getOrderItemId()));
145                 $attributeCollection->addCollection($newCollection);
146             }
147         }
148         
149         $storedOrderItem->setAttributes($attributeCollection);
150         $this->addonValueService->loadAddonValues($storedOrderItem);
151         
152         return $storedOrderItem;
153     }
154     
155     
156     /**
157      * Returns a stored order item collection by the given order ID.
158      *
159      * @param IdType $orderId ID of the order.
160      *
161      * @return StoredOrderItemCollection Stored order item collection.
162      */
163     public function getItemsByOrderId(IdType $orderId)
164     {
165         $orderItemCollection      = $this->orderItemRepositoryReader->getItemsByOrderId($orderId);
166         $attributeRepositoryArray = $this->orderItemAttributeRepositoryFactory->createRepositoryArray();
167         
168         /** @var StoredOrderItemInterface|AddonValueContainerInterface $orderItem */
169         foreach($orderItemCollection->getArray() as $orderItem)
170         {
171             $orderItemId = $orderItem->getOrderItemId();
172             
173             /** @var StoredOrderItemAttributeCollection $attributeCollection */
174             $attributeCollection = null;
175             foreach($attributeRepositoryArray as $attributeRepository)
176             {
177                 if(null === $attributeCollection)
178                 {
179                     $attributeCollection = $attributeRepository->getItemAttributesByOrderItemId(new IdType($orderItemId));
180                 }
181                 else
182                 {
183                     $newCollection = $attributeRepository->getItemAttributesByOrderItemId(new IdType($orderItemId));
184                     $attributeCollection->addCollection($newCollection);
185                 }
186             }
187             
188             $orderItem->setAttributes($attributeCollection);
189             $this->addonValueService->loadAddonValues($orderItem);
190         }
191         
192         return $orderItemCollection;
193     }
194     
195     
196     /**
197      * Deletes an order item from the repository by the given order item ID.
198      *
199      * @param IdType $orderItemId Order item ID.
200      *
201      * @return OrderItemRepository Same instance for method chaining.
202      */
203     public function deleteItemById(IdType $orderItemId)
204     {
205         $repositoryArray = $this->orderItemAttributeRepositoryFactory->createRepositoryArray();
206         
207         foreach($repositoryArray as $repository)
208         {
209             $repository->deleteItemAttributesByOrderItemId($orderItemId);
210         }
211         
212         /** @var AddonValueContainerInterface $orderItem */
213         $orderItem = $this->orderItemRepositoryReader->getItemById($orderItemId);
214         $this->addonValueService->deleteAddonValues($orderItem);
215         
216         $this->orderItemRepositoryDeleter->deleteItemById($orderItemId);
217         
218         return $this;
219     }
220     
221     
222     /**
223      * Deletes order items from the repository by the given order ID.
224      *
225      * @param IdType $orderId Order ID.
226      *
227      * @return OrderItemRepository Same instance for method chaining.
228      */
229     public function deleteItemsByOrderId(IdType $orderId)
230     {
231         $orderItemCollection = $this->orderItemRepositoryReader->getItemsByOrderId($orderId);
232         
233         /** @var StoredOrderItemInterface $orderItem */
234         foreach($orderItemCollection->getArray() as $orderItem)
235         {
236             $this->deleteItemById(new IdType($orderItem->getOrderItemId()));
237         }
238         
239         return $this;
240     }
241     
242     
243     /**
244      * Delegate to the attribute repository and save the attributes of the passed order item.
245      *
246      * @param OrderItemInterface $orderItem          Order item which contain the attributes.
247      * @param int|null           $storedOrderItemId  (Optional) Id of order item. When not set, its get by stored order
248      *                                               item.
249      *
250      * @return $this Same instance to make chained method calls possible.
251      */
252     protected function _delegateToAttributeRepositories(OrderItemInterface $orderItem, $storedOrderItemId = null)
253     {
254         if(null === $storedOrderItemId && $orderItem instanceof StoredOrderItemInterface)
255         {
256             $storedOrderItemId = $orderItem->getOrderItemId();
257         }
258         $collection     = $orderItem->getAttributes();
259         $attributeArray = $collection->getArray();
260         
261         foreach($attributeArray as $attribute)
262         {
263             $repository = $this->orderItemAttributeRepositoryFactory->createRepositoryByAttributeObject($attribute);
264             
265             if($attribute instanceof StoredOrderItemAttributeInterface)
266             {
267                 $repository->store($attribute);
268             }
269             else
270             {
271                 $repository->addToOrderItem(new IdType($storedOrderItemId), $attribute);
272             }
273         }
274         
275         return $this;
276     }
277     
278 }
API documentation generated by ApiGen