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 /* --------------------------------------------------------------
  4    ProductsLinksApiV2Controller.inc.php 2016-03-07
  5    Gambio GmbH
  6    http://www.gambio.de
  7    Copyright (c) 2016 Gambio GmbH
  8    Released under the GNU General Public License (Version 2)
  9    [http://www.gnu.org/licenses/gpl-2.0.html]
 10    --------------------------------------------------------------
 11 */
 12 
 13 MainFactory::load_class('HttpApiV2Controller');
 14 
 15 /**
 16  * Class ProductsLinksApiV2Controller
 17  *
 18  * Provides an API interface for managing the product links.
 19  *
 20  * Notice: This controller is a subresource of the ProductsApiV2Controller.
 21  *
 22  * @category System
 23  * @package  ApiV2Controllers
 24  */
 25 class ProductsLinksApiV2Controller extends HttpApiV2Controller
 26 {
 27     /**
 28      * Product write service.
 29      * 
 30      * @var ProductWriteService
 31      */
 32     protected $productWriteService;
 33 
 34     /**
 35      * Product read service.
 36      * 
 37      * @var ProductReadService
 38      */
 39     protected $productReadService;
 40 
 41 
 42     /**
 43      * Initialize API Controller
 44      *
 45      * @throws HttpApiV2Exception
 46      */
 47     protected function __initialize()
 48     {
 49         if(!isset($this->uri[1]) || !is_numeric($this->uri[1]))
 50         {
 51             throw new HttpApiV2Exception('Product record ID was not provided or is invalid: ' . gettype($this->uri[1]),
 52                                          400);
 53         }
 54 
 55         $this->productWriteService = StaticGXCoreLoader::getService('ProductWrite');
 56         $this->productReadService  = StaticGXCoreLoader::getService('ProductRead');
 57     }
 58 
 59 
 60     /**
 61      * @api        {post} /products/:id/links Create Product Link
 62      * @apiVersion 2.1.0
 63      * @apiName    CreateProductLink
 64      * @apiGroup   Products
 65      *
 66      * @apiDescription
 67      * Creates a new 'product to category' record in the system.
 68      *
 69      * @apiParamExample {json} Request-Body
 70      * {
 71      *   "categoryId": 1
 72      * }
 73      *
 74      * @apiSuccessExample {json} Success-Response
 75      * {
 76      *   "code": 201,
 77      *   "status": "success",
 78      *   "action": "create",
 79      *   "resource": "ProductLink",
 80      *   "productId": 1,
 81      *   "categoryId": 1
 82      * }
 83      */
 84     public function post()
 85     {
 86         $json = json_decode($this->api->request->getBody());
 87 
 88         $productId  = new IdType($this->uri[1]);
 89         $categoryId = new IdType($json->categoryId);
 90 
 91         $this->productWriteService->linkProduct($productId, $categoryId);
 92 
 93         $response = array(
 94             'code'       => 201,
 95             'status'     => 'success',
 96             'action'     => 'create',
 97             'resource'      => 'ProductLink',
 98             'productId'  => (int)$this->uri[1],
 99             'categoryId' => (int)$json->categoryId
100         );
101 
102         $this->_writeResponse($response, 201);
103     }
104 
105 
106     /**
107      * @api        {put} /products/:id/links Update Product Link
108      * @apiVersion 2.1.0
109      * @apiName    ChangeProductLink
110      * @apiGroup   Products
111      *
112      * @apiDescription
113      * Changes an existing 'product to category' link.
114      *
115      * @apiParamExample {json} Request-Body
116      * {
117      *   "oldCategoryId": 1,
118      *   "newCategoryId": 2
119      * }
120      *
121      * @apiSuccessExample {json} Success-Response
122      * {
123      *   "code": 200,
124      *   "status": "success",
125      *   "action": "update",
126      *   "resource": "ProductLink",
127      *   "productId": 1,
128      *   "oldCategoryId": 1,
129      *   "newCategoryId": 2
130      * }
131      */
132     public function put()
133     {
134         $json = json_decode($this->api->request->getBody());
135 
136         $productId     = new IdType($this->uri[1]);
137         $oldCategoryId = new IdType($json->oldCategoryId);
138         $newCategoryId = new IdType($json->newCategoryId);
139 
140         $this->productWriteService->changeProductLink($productId, $oldCategoryId, $newCategoryId);
141 
142         $response = array(
143             'code'          => 200,
144             'status'        => 'success',
145             'action'        => 'update',
146             'resource'      => 'ProductLink',
147             'productId'     => (int)$this->uri[1],
148             'oldCategoryId' => (int)$json->oldCategoryId,
149             'newCategoryId' => (int)$json->newCategoryId
150         );
151 
152         $this->_writeResponse($response);
153     }
154 
155 
156     /**
157      * @api        {delete} /products/:id/links Delete Product Link
158      * @apiVersion 2.1.0
159      * @apiName    CreateProductLink
160      * @apiGroup   Products
161      *
162      * @apiDescription
163      * Deletes an existing 'product to category' link.
164      * If there is no categoryId property set, all the product links will be removed.
165      *
166      * @apiExample {curl} Delete product link for Product with ID = 1 in Category with ID = 1
167      *             curl -X DELETE --user admin@shop.de:12345 http://shop.de/api.php/v2/products/1/links
168      *
169      * @apiSuccessExample {json} Success-Response
170      * {
171      *   "code": 200,
172      *   "status": "success",
173      *   "action": "delete",
174      *   "resource": "ProductLink",
175      *   "productId": 1
176      * }
177      */
178     public function delete()
179     {
180         $json = json_decode($this->api->request->getBody());
181 
182         $productId = new IdType($this->uri[1]);
183 
184         if($json->categoryId !== null)
185         {
186             $categoryId = new IdType($json->categoryId);
187             $this->productWriteService->deleteProductLink($productId, $categoryId);
188         }
189         else
190         {
191             $this->productWriteService->deleteProductLinks($productId);
192         }
193 
194         $response = array(
195             'code'       => 200,
196             'status'     => 'success',
197             'action'     => 'delete',
198             'resource'   => 'ProductLink',
199             'productId'  => (int)$this->uri[1]
200         );
201 
202         $this->_writeResponse($response);
203     }
204 
205 
206     /**
207      * @api        {get} /products/:id/links Get Product Links
208      * @apiVersion 2.1.0
209      * @apiName    CreateProductLink
210      * @apiGroup   Products
211      *
212      * @apiDescription
213      * Get all 'product to category' links for associated with a specific product.
214      *
215      * @apiExample {curl} Get product links for product with ID = 1
216      *             curl -i --user admin@shop.de:12345 http://shop.de/api.php/v2/products/1/links
217      *
218      * @apiSuccessExample {json} Success-Response
219      * [
220      *   0,
221      *   1
222      * ]
223      */
224     public function get()
225     {
226         $productId = new IdType($this->uri[1]);
227 
228         $response = array();
229         $categoriesArray = $this->productReadService->getProductLinks($productId)->getArray();
230 
231         foreach($categoriesArray as $categoryId)
232         {
233             $response[] = $categoryId->asInt();
234         }
235 
236         $this->_writeResponse($response);
237     }
238 }
239 
API documentation generated by ApiGen