├── .github └── workflows │ └── main.yml ├── .gitignore ├── Api ├── CategoryRepositoryInterface.php ├── CheckoutFormRepositoryInterface.php ├── Consumer │ └── MessageInterface.php ├── ConsumerInterface.php ├── Data │ ├── AllegroReservationsInterface.php │ ├── CategoryInterface.php │ ├── CheckoutForm │ │ ├── AmountInterface.php │ │ ├── BuyerInterface.php │ │ ├── Delivery │ │ │ ├── AddressInterface.php │ │ │ ├── CostInterface.php │ │ │ ├── MethodInterface.php │ │ │ ├── PickupPoint │ │ │ │ └── AddressInterface.php │ │ │ └── PickupPointInterface.php │ │ ├── DeliveryInterface.php │ │ ├── Invoice │ │ │ ├── Address │ │ │ │ ├── CompanyInterface.php │ │ │ │ └── NaturalPersonInterface.php │ │ │ └── AddressInterface.php │ │ ├── InvoiceInterface.php │ │ ├── LineItemInterface.php │ │ ├── PaymentInterface.php │ │ └── SummaryInterface.php │ ├── CheckoutFormInterface.php │ ├── DeliveryMethodInterface.php │ ├── EventInterface.php │ ├── ImageInterface.php │ ├── ImpliedWarrantyInterface.php │ ├── Offer │ │ ├── AfterSalesServicesInterface.php │ │ └── LocationInterface.php │ ├── OfferInterface.php │ ├── OrderLogInterface.php │ ├── Parameter │ │ ├── RangeInterface.php │ │ ├── ValuesIdsInterface.php │ │ └── ValuesInterface.php │ ├── ParameterDefinition │ │ ├── DictionaryItemInterface.php │ │ └── RestrictionInterface.php │ ├── ParameterDefinitionInterface.php │ ├── ParameterInterface.php │ ├── ParameterInterfaceFactoryInterface.php │ ├── PublicationCommandInterface.php │ ├── ReservationInterface.php │ ├── ReturnPolicyInterface.php │ ├── Sales │ │ └── Order │ │ │ └── PickupPointExtensionAttributesInterface.php │ ├── ShippingRateInterface.php │ ├── TokenInterface.php │ └── WarrantyInterface.php ├── DeliveryMethodRepositoryInterface.php ├── EventRepositoryInterface.php ├── ImageRepositoryInterface.php ├── ImpliedWarrantyRepositoryInterface.php ├── OfferRepositoryInterface.php ├── OrderLogRepositoryInterface.php ├── OrderRepositoryInterface.php ├── ParameterDefinitionRepositoryInterface.php ├── PriceCommandInterface.php ├── ProductRepositoryInterface.php ├── PublicationCommandRepositoryInterface.php ├── QuantityCommandInterface.php ├── ReservationRepositoryInterface.php ├── ReturnPolicyRepositoryInterface.php ├── ShippingRateRepositoryInterface.php └── WarrantyRepositoryInterface.php ├── Block ├── Adminhtml │ ├── Config │ │ └── Form │ │ │ └── Field │ │ │ ├── DeliveryMethods.php │ │ │ ├── OrderStatuses.php │ │ │ └── Renderer │ │ │ ├── AllegroDeliveryMethods.php │ │ │ ├── AllegroOrderStatuses.php │ │ │ ├── MagentoOrderStatuses.php │ │ │ └── MethodCodes.php │ ├── HideAddressInformation.php │ ├── Offer │ │ ├── BackButton.php │ │ ├── EndButton.php │ │ ├── PublishButton.php │ │ └── SaveButton.php │ ├── System │ │ └── Authenticate.php │ └── ViewProductButton.php └── OriginOrderData.php ├── Console └── Command │ ├── AbstractImportOrders.php │ ├── CleanOffersMapping.php │ ├── ImportOrder.php │ ├── ImportOrders.php │ └── ImportOrdersWithErrors.php ├── Controller └── Adminhtml │ ├── Offer.php │ ├── Offer │ ├── Context.php │ ├── Create.php │ ├── Edit.php │ ├── End.php │ ├── Publish.php │ └── Save.php │ ├── Orders │ ├── Delete.php │ ├── Import.php │ └── Index.php │ ├── Reservations │ ├── Delete.php │ └── Index.php │ └── System │ └── Authenticate.php ├── Cron ├── CleanOffersMapping.php ├── CleanReservations.php ├── ImportOrders.php ├── ImportOrdersWithErrors.php └── RefreshToken.php ├── LICENSE ├── Logger ├── ApiHandler.php ├── ExceptionHandler.php ├── HttpRequestHandler.php └── Logger.php ├── Model ├── AbstractOrderImporter.php ├── AllegroOrderStatus.php ├── AllegroPrice.php ├── AllegroPriceGettingException.php ├── Api │ ├── Auth.php │ ├── Auth │ │ └── Data │ │ │ ├── Token.php │ │ │ ├── TokenSerializer.php │ │ │ └── TokenSerializerException.php │ ├── Client.php │ ├── ClientException.php │ ├── ClientResponseErrorException.php │ ├── ClientResponseException.php │ ├── Credentials.php │ ├── Request.php │ └── TokenProvider.php ├── Cache │ └── Type.php ├── CategoryRepository.php ├── CheckoutFormRepository.php ├── Config │ ├── Backend │ │ ├── DeliveryMethods.php │ │ └── OrderStatuses.php │ ├── CommentText │ │ └── CallbackUrl.php │ └── Source │ │ ├── ActivePaymentMethods.php │ │ ├── ActiveSippingMethods.php │ │ ├── AllegroAttribute.php │ │ ├── DeliveryMethods.php │ │ ├── HandlingTime.php │ │ ├── ImpliedWarranty.php │ │ ├── PaymentsInvoice.php │ │ ├── ProductAttributes.php │ │ ├── Province.php │ │ ├── ReturnPolicy.php │ │ ├── ShippingRates.php │ │ ├── State.php │ │ └── Warranty.php ├── Configuration.php ├── Consumer.php ├── Consumer │ └── Message.php ├── Data │ ├── Category.php │ ├── CheckoutForm.php │ ├── CheckoutForm │ │ ├── Amount.php │ │ ├── Buyer.php │ │ ├── Delivery.php │ │ ├── Delivery │ │ │ ├── Address.php │ │ │ ├── Cost.php │ │ │ ├── Method.php │ │ │ ├── PickupPoint.php │ │ │ └── PickupPoint │ │ │ │ └── Address.php │ │ ├── Invoice.php │ │ ├── Invoice │ │ │ ├── Address.php │ │ │ └── Address │ │ │ │ ├── Company.php │ │ │ │ └── NaturalPerson.php │ │ ├── LineItem.php │ │ ├── Payment.php │ │ └── Summary.php │ ├── DeliveryMethod.php │ ├── Event.php │ ├── Image.php │ ├── ImpliedWarranty.php │ ├── Offer.php │ ├── Offer │ │ ├── AfterSalesServices.php │ │ └── Location.php │ ├── Parameter.php │ ├── Parameter │ │ ├── Range.php │ │ ├── Values.php │ │ └── ValuesIds.php │ ├── ParameterDefinition.php │ ├── ParameterDefinition │ │ ├── DictionaryItem.php │ │ └── Restriction.php │ ├── ParameterFactory.php │ ├── ParameterFactoryException.php │ ├── PublicationCommand.php │ ├── ReturnPolicy.php │ ├── Sales │ │ └── Order │ │ │ └── PickupPointExtensionAttributes.php │ ├── ShippingRate.php │ └── Warranty.php ├── DeliveryMethodRepository.php ├── EventRepository.php ├── Guid.php ├── ImageRepository.php ├── ImpliedWarrantyRepository.php ├── LastEventIdInitializer.php ├── OfferRepository.php ├── OffersMapping.php ├── OrderImporter.php ├── OrderImporter │ ├── AllegroReservation.php │ ├── Creator.php │ ├── CreatorItemsException.php │ ├── Info.php │ ├── Invoice.php │ ├── OrderProcessingException.php │ ├── OriginOfOrder.php │ ├── Payment.php │ ├── Processor.php │ ├── Product.php │ ├── ReservationPlacingException.php │ ├── Shipping.php │ └── Status.php ├── OrderLog.php ├── OrderLogRepository.php ├── OrderRepository.php ├── OrderWithErrorImporter.php ├── ParameterDefinitionRepository.php ├── PickupPoint.php ├── PriceCommand.php ├── ProductRepository.php ├── PublicationCommandRepository.php ├── QuantityCommand.php ├── Reservation.php ├── ReservationRepository.php ├── ResourceModel │ ├── AbstractResource.php │ ├── Order.php │ ├── Order │ │ ├── CheckoutForm.php │ │ ├── EventStats.php │ │ └── Events.php │ ├── OrderLog.php │ ├── OrderLog │ │ └── Collection.php │ ├── PickupPoint.php │ ├── Product.php │ ├── Reservation.php │ ├── Reservation │ │ ├── Collection.php │ │ └── Collection │ │ │ └── Grid.php │ └── Sale │ │ ├── AfterSaleServices.php │ │ ├── Categories.php │ │ ├── DeliveryMethod.php │ │ ├── Images.php │ │ ├── Offers.php │ │ └── ShippingRates.php ├── ReturnPolicyRepository.php ├── ShippingRateRepository.php ├── System │ └── Message │ │ ├── AllegroConnectionStatusMessage.php │ │ └── AllegroOrdersWithErrorsMessage.php └── WarrantyRepository.php ├── Observer ├── ConfigCredentialsChangeObserver.php ├── CopyFieldsFromQuoteToOrderObserver.php ├── OrderObserver.php ├── QtyChangeObserver.php ├── SaveOrderAfterObserver.php ├── SaveShippingAfterObserver.php └── SaveShippingBeforeObserver.php ├── Plugin ├── InventorySourceItemSaveMultiple.php ├── OrderGet.php ├── OrderSave.php ├── RemoveDiscountCalculation.php └── UpdateShippingRatePrice.php ├── Preference └── Model │ └── ResourceModel │ └── SaveMultiple.php ├── README.md ├── README ├── addToAllegroButton.png ├── allegroConnectionConfiguration.png ├── allegroDebugMode.png ├── allegroOfferCreateConfiguration.png ├── allegroOfferForm.png ├── allegroOfferId1.png ├── allegroOfferId2.png ├── allegroOrderImporterConfiguration.png ├── allegroOrdersMenu.png ├── allegroOrdersWithErrorsGrid.png ├── allegroPricePolicyConfiguration.png ├── allegroReservationsGrid.png ├── apiKeys.png ├── applicationRegistration.png ├── categoriesAndParameters.png ├── deliveryAndPaymentMapping.png ├── imageRole.png ├── orderStatusesMapping.png ├── ordersConfiguration.png ├── originConfiguration.png ├── publishButton.png ├── sendTrackingInformation1.png ├── sendTrackingInformation2.png └── stockInventorySynchronizationDiagram.png ├── Service └── MessageQtyChange.php ├── Setup ├── Patch │ └── Data │ │ ├── ImageRoles.php │ │ ├── ImageRolesNotFilterable.php │ │ └── OrderStatuses.php └── UpgradeData.php ├── Ui ├── AllegroOffer │ └── Form │ │ ├── CreateDataProvider.php │ │ └── EditDataProvider.php └── Component │ └── Listing │ └── Columns │ └── OrdersActions.php ├── composer.json ├── etc ├── acl.xml ├── adminhtml │ ├── di.xml │ ├── events.xml │ ├── menu.xml │ ├── routes.xml │ └── system.xml ├── cache.xml ├── communication.xml ├── config.xml ├── crontab.xml ├── db_schema.xml ├── db_schema_whitelist.json ├── di.xml ├── events.xml ├── extension_attributes.xml ├── fieldset.xml ├── module.xml ├── queue_consumer.xml ├── queue_publisher.xml ├── queue_topology.xml └── webapi.xml ├── i18n └── pl_PL.csv ├── registration.php └── view └── adminhtml ├── layout ├── allegro_offer_create.xml ├── allegro_offer_edit.xml ├── allegro_orders_index.xml ├── allegro_reservations_index.xml ├── catalog_product_edit.xml └── sales_order_view.xml ├── templates ├── info.phtml ├── order │ └── view │ │ └── allegro_pickup_point_info.phtml └── origin_order_data.phtml ├── ui_component ├── allegro_offer_form_create.xml ├── allegro_offer_form_edit.xml ├── allegro_orders_listing.xml ├── allegro_reservations_listing.xml └── sales_order_grid.xml └── web ├── js └── allegro_offer │ ├── form │ └── field │ │ ├── attributes-table.js │ │ ├── attributes-table │ │ ├── abstract-attribute.js │ │ ├── range.js │ │ ├── validator.js │ │ ├── values-ids.js │ │ └── values.js │ │ ├── category.js │ │ ├── description.js │ │ ├── ean.js │ │ └── name-length-counter.js │ └── validation │ ├── description-subnet.js │ ├── description-tags-attributes.js │ ├── description-tags.js │ ├── ean.js │ └── name-length.js └── template └── allegro_offer └── form └── field ├── attributes-table.html ├── attributes-table ├── range.html ├── values-ids.html └── values.html ├── category.html └── name-length-counter.html /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Continous Integration 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | static: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v1 9 | - uses: extdn/github-actions-m2/magento-coding-standard@master 10 | 11 | phpmd: 12 | name: Magento 2 - Phpmd 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v1 16 | - uses: extdn/github-actions-m2/magento-mess-detector@master 17 | 18 | integration: 19 | name: Static Code Analysis 20 | runs-on: ubuntu-latest 21 | container: 22 | image: duhon/php:7.3-alpine 23 | 24 | services: 25 | mysql: 26 | image: mysql:5.7 27 | env: 28 | MYSQL_ROOT_PASSWORD: password 29 | MYSQL_DATABASE: magento2 30 | ports: 31 | - 3306 32 | options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 33 | 34 | steps: 35 | - uses: actions/checkout@v1 36 | with: 37 | fetch-depth: 1 38 | - uses: extdn/github-actions-m2/install-m2-from-mirror@master 39 | with: 40 | ce-version: 2.3.3 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /Api/CategoryRepositoryInterface.php: -------------------------------------------------------------------------------- 1 | RangeInterface::class, 13 | ParameterDefinitionInterface::FRONTEND_TYPE_VALUES => ValuesInterface::class, 14 | ParameterDefinitionInterface::FRONTEND_TYPE_VALUES_IDS => ValuesIdsInterface::class, 15 | ]; 16 | 17 | /** 18 | * @param string $type 19 | * @return RangeInterface|ValuesIdsInterface|ValuesInterface 20 | */ 21 | public function create(string $type): ParameterInterface; 22 | 23 | /** 24 | * @param ParameterDefinitionInterface $parameterDefinition 25 | * @return RangeInterface|ValuesIdsInterface|ValuesInterface 26 | */ 27 | public function createFromDefinition(ParameterDefinitionInterface $parameterDefinition): ParameterInterface; 28 | } 29 | -------------------------------------------------------------------------------- /Api/Data/PublicationCommandInterface.php: -------------------------------------------------------------------------------- 1 | deliveryMethods = $deliveryMethods; 29 | } 30 | 31 | /** 32 | * @param string $value 33 | * @return $this 34 | */ 35 | public function setInputName($value) 36 | { 37 | return $this->setName($value); 38 | } 39 | 40 | /** 41 | * @return Select 42 | */ 43 | protected function _prepareLayout() 44 | { 45 | $this->setOptions( 46 | $this->deliveryMethods->toOptionArray() 47 | ); 48 | return parent::_prepareLayout(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Block/Adminhtml/Config/Form/Field/Renderer/AllegroOrderStatuses.php: -------------------------------------------------------------------------------- 1 | setName($value); 16 | } 17 | 18 | /** 19 | * @return array 20 | */ 21 | public function getAllegroOrderStatuses() 22 | { 23 | return [ 24 | 'NEW' => __('NEW'), 25 | 'PROCESSING' => __('PROCESSING'), 26 | 'READY_FOR_SHIPMENT' => __('READY FOR SHIPMENT'), 27 | 'READY_FOR_PICKUP' => __('READY FOR PICKUP'), 28 | 'SENT' => __('SENT'), 29 | 'PICKED_UP' => __('PICKED UP'), 30 | 'CANCELLED' => __('CANCELLED') 31 | ]; 32 | } 33 | /** 34 | * @return Select 35 | */ 36 | protected function _prepareLayout() 37 | { 38 | $this->setOptions( 39 | $this->getAllegroOrderStatuses() 40 | ); 41 | return parent::_prepareLayout(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Block/Adminhtml/Config/Form/Field/Renderer/MagentoOrderStatuses.php: -------------------------------------------------------------------------------- 1 | orderStatusCollectionFactory = $orderStatusCollectionFactory; 28 | } 29 | 30 | /** 31 | * @param $value 32 | * @return $this 33 | */ 34 | public function setInputName($value) 35 | { 36 | return $this->setName($value); 37 | } 38 | 39 | /** 40 | * @return $this 41 | */ 42 | protected function _prepareLayout() 43 | { 44 | $collection = $this->orderStatusCollectionFactory->create()->joinStates(); 45 | foreach ($collection as $item) { 46 | $this->addOption($item->getStatus(), __($item->getLabel())); 47 | } 48 | 49 | return parent::_prepareLayout(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Block/Adminhtml/HideAddressInformation.php: -------------------------------------------------------------------------------- 1 | getOrder(); 21 | // TODO use ExtensionAttributesInterface 22 | if ($order->getData('order_from') === self::ALLEGRO) { 23 | $shippingAddress = $order->getShippingAddress(); 24 | $firstName = $shippingAddress->getFirstname(); 25 | $lastName = $shippingAddress->getLastname(); 26 | if ($firstName === $lastName && $firstName === 'unknown') { 27 | return false; 28 | } 29 | } 30 | return true; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Block/Adminhtml/Offer/SaveButton.php: -------------------------------------------------------------------------------- 1 | urlBuilder = $context->getUrlBuilder(); 37 | $this->registry = $registry; 38 | } 39 | 40 | /** 41 | * Return button attributes array 42 | */ 43 | public function getButtonData() 44 | { 45 | return [ 46 | 'label' => __('Save'), 47 | 'class' => 'save primary', 48 | 'data_attribute' => [ 49 | 'mage-init' => ['button' => ['event' => 'save']], 50 | 'form-role' => 'save', 51 | ], 52 | 'sort_order' => 10, 53 | ]; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Block/OriginOrderData.php: -------------------------------------------------------------------------------- 1 | context = $context; 38 | $this->registry = $registry; 39 | $this->order = $this->registry->registry('sales_order'); 40 | } 41 | 42 | /** 43 | * @return mixed 44 | */ 45 | public function getOrderOrigin() 46 | { 47 | // TODO use ExtensionAttributesInterface 48 | return $this->order->getData('order_from'); 49 | } 50 | 51 | /** 52 | * @return mixed 53 | */ 54 | public function getExternalID() 55 | { 56 | // TODO use ExtensionAttributesInterface 57 | return $this->order->getData('external_id'); 58 | } 59 | 60 | /** 61 | * @return mixed 62 | */ 63 | public function getBuyerLogin() 64 | { 65 | return $this->order->getData('allegro_buyer_login'); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Console/Command/AbstractImportOrders.php: -------------------------------------------------------------------------------- 1 | state = $state; 27 | parent::__construct(); 28 | } 29 | 30 | /** 31 | * @param InputInterface $input 32 | * @param OutputInterface $output 33 | * @return int|void|null 34 | * @throws LocalizedException 35 | */ 36 | protected function execute(InputInterface $input, OutputInterface $output) 37 | { 38 | try { 39 | $this->state->getAreaCode(); 40 | } catch (LocalizedException $exception) { 41 | $this->state->setAreaCode(Area::AREA_GLOBAL); 42 | } 43 | 44 | $output->writeln('Order import start'); 45 | 46 | $info = $this->createOrderImporter()->execute(); 47 | 48 | $output->writeln($info->getMessage()); 49 | } 50 | 51 | /** 52 | * @return AbstractOrderImporter 53 | */ 54 | abstract protected function createOrderImporter(): AbstractOrderImporter; 55 | } 56 | -------------------------------------------------------------------------------- /Console/Command/ImportOrders.php: -------------------------------------------------------------------------------- 1 | orderImporterFactory = $orderImporterFactory; 30 | parent::__construct($state); 31 | } 32 | 33 | /** 34 | * {@inheritdoc} 35 | */ 36 | protected function configure() 37 | { 38 | $this->setName('macopedia:allegro:orders-import'); 39 | $this->setDescription("Import orders from Allegro account "); 40 | } 41 | 42 | /** 43 | * @return AbstractOrderImporter 44 | */ 45 | protected function createOrderImporter(): AbstractOrderImporter 46 | { 47 | return $this->orderImporterFactory->create(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Console/Command/ImportOrdersWithErrors.php: -------------------------------------------------------------------------------- 1 | orderImporterFactory = $orderImporterFactory; 30 | parent::__construct($state); 31 | } 32 | 33 | /** 34 | * {@inheritdoc} 35 | */ 36 | protected function configure() 37 | { 38 | $this->setName('macopedia:allegro:orders-with-errors-import'); 39 | $this->setDescription("Import orders with errors from Allegro account"); 40 | } 41 | 42 | /** 43 | * @return AbstractOrderImporter 44 | */ 45 | protected function createOrderImporter(): AbstractOrderImporter 46 | { 47 | return $this->orderImporterFactory->create(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Offer/Create.php: -------------------------------------------------------------------------------- 1 | getRequest()->getParam('product'); 24 | if (!$productId) { 25 | throw new LocalizedException(__('Requested product does not exists')); 26 | } 27 | 28 | $this->credentials->getToken(); 29 | 30 | $product = $this->productRepository->getById($productId); 31 | 32 | // TODO use ExtensionAttributesInterface 33 | $offerId = $product->getData('allegro_offer_id'); 34 | 35 | if ($offerId) { 36 | throw new LocalizedException(__('Offer for requested product already exists')); 37 | } 38 | 39 | $this->registry->register('product', $product); 40 | \Magento\Framework\Profiler::stop(__CLASS__ . '::' . __METHOD__); 41 | 42 | return $this->createPageResult(); 43 | } catch (LocalizedException $e) { 44 | $this->logger->critical($e); 45 | $this->messageManager->addExceptionMessage($e); 46 | } catch (\Exception $e) { 47 | $this->logger->critical($e); 48 | $this->messageManager->addErrorMessage("Something went wrong"); 49 | } 50 | 51 | return $this->createForwardNoRouteResult(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Offer/Edit.php: -------------------------------------------------------------------------------- 1 | getRequest()->getParam('id'); 24 | if (!$offerId) { 25 | throw new LocalizedException(__('Requested offer does not exists')); 26 | } 27 | 28 | $this->credentials->getToken(); 29 | 30 | $offer = $this->offerRepository->get($offerId); 31 | $product = $this->productRepository->getByAllegroOfferId($offer['id']); 32 | 33 | $this->registry->register('offer', $offer); 34 | $this->registry->register('product', $product); 35 | 36 | return $this->createPageResult(); 37 | 38 | } catch (LocalizedException $e) { 39 | $this->logger->critical($e); 40 | $this->messageManager->addExceptionMessage($e); 41 | } catch (\Exception $e) { 42 | $this->logger->critical($e); 43 | $this->messageManager->addErrorMessage(__('Something went wrong')); 44 | } 45 | 46 | return $this->createForwardNoRouteResult(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Orders/Index.php: -------------------------------------------------------------------------------- 1 | resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE); 21 | $resultPage->getConfig()->getTitle()->prepend(__('Orders with errors')); 22 | return $resultPage; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Reservations/Index.php: -------------------------------------------------------------------------------- 1 | resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE); 24 | $resultPage->getConfig()->getTitle()->prepend(__('Allegro reservations')); 25 | return $resultPage; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cron/CleanOffersMapping.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 35 | $this->scopeConfig = $scopeConfig; 36 | $this->offersMapping = $offersMapping; 37 | } 38 | 39 | public function execute() 40 | { 41 | if ($this->scopeConfig->getValue(self::OFFERS_MAPPING_CRON_CONFIG_KEY)) { 42 | $this->logger->addInfo("Cronjob clean offers mapping is executed."); 43 | try { 44 | $this->offersMapping->clean(); 45 | } catch (\Exception $e) { 46 | $this->logger->error('Error while trying to clean old offers mapping: ' . $e->getMessage()); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Cron/CleanReservations.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 38 | $this->scopeConfig = $scopeConfig; 39 | $this->allegroReservation = $allegroReservation; 40 | } 41 | 42 | public function execute() 43 | { 44 | if ($this->scopeConfig->getValue(self::RESERVATIONS_CRON_CONFIG_KEY)) { 45 | $this->logger->addInfo("Cronjob clean reservations is executed."); 46 | $this->allegroReservation->cleanOldReservations(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Cron/ImportOrders.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 38 | $this->orderImporter = $orderImporter; 39 | $this->scopeConfig = $scopeConfig; 40 | } 41 | 42 | /** 43 | * @throws \Exception 44 | */ 45 | public function execute() 46 | { 47 | if ($this->scopeConfig->getValue(self::ORDER_IMPORT_CONFIG_KEY)) { 48 | $this->logger->addInfo("Cronjob imported orders is executed."); 49 | $this->orderImporter->execute(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Cron/ImportOrdersWithErrors.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 38 | $this->orderImporter = $orderImporter; 39 | $this->scopeConfig = $scopeConfig; 40 | } 41 | 42 | /** 43 | * @throws \Exception 44 | */ 45 | public function execute() 46 | { 47 | if ($this->scopeConfig->getValue(self::ORDER_IMPORT_CONFIG_KEY)) { 48 | $this->logger->addInfo("Cronjob imported orders with errors is executed."); 49 | $this->orderImporter->execute(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Cron/RefreshToken.php: -------------------------------------------------------------------------------- 1 | tokenProvider = $tokenProvider; 27 | } 28 | 29 | /** 30 | * @throws \Exception 31 | */ 32 | public function execute() 33 | { 34 | $this->tokenProvider->forceRefreshToken(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Macopedia.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Logger/ApiHandler.php: -------------------------------------------------------------------------------- 1 | error($exception->getMessage(), [self::IS_EXCEPTION_KEY => true, 'exception' => $exception]); 15 | if ($message) { 16 | $this->error($message, [self::IS_EXCEPTION_KEY => false]); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Model/AllegroPriceGettingException.php: -------------------------------------------------------------------------------- 1 | auth = $auth; 27 | $this->credentials = $credentials; 28 | } 29 | 30 | /** 31 | * @return TokenInterface 32 | * @throws ClientException 33 | * @throws \Exception 34 | */ 35 | public function getCurrent() 36 | { 37 | $token = $this->credentials->getToken(); 38 | 39 | if ($token->isExpired()) { 40 | $token = $this->refreshToken($token); 41 | } 42 | 43 | return $token; 44 | } 45 | 46 | /** 47 | * @return void 48 | * @throws ClientException 49 | * @throws \Exception 50 | */ 51 | public function forceRefreshToken() 52 | { 53 | $this->credentials->saveToken( 54 | $this->auth->refreshToken( 55 | $this->credentials->getToken() 56 | ) 57 | ); 58 | } 59 | 60 | /** 61 | * @param TokenInterface $token 62 | * @return TokenInterface 63 | * @throws \Exception 64 | */ 65 | private function refreshToken(TokenInterface $token) 66 | { 67 | $token = $this->auth->refreshToken($token); 68 | $this->credentials->saveToken($token); 69 | return $token; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Model/Cache/Type.php: -------------------------------------------------------------------------------- 1 | get(self::TYPE_IDENTIFIER), self::CACHE_TAG); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Model/Config/CommentText/CallbackUrl.php: -------------------------------------------------------------------------------- 1 | url = $url; 25 | } 26 | 27 | public function getCommentText($elementValue) 28 | { 29 | $this->url->setNoSecret(true); 30 | return $this->url->getUrl('allegro/system/authenticate'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Model/Config/Source/ActivePaymentMethods.php: -------------------------------------------------------------------------------- 1 | scopeConfig = $scopeConfig; 28 | $this->paymentConfig = $paymentConfig; 29 | } 30 | 31 | /** 32 | * @return array 33 | */ 34 | public function toOptionArray() 35 | { 36 | $methods = [['value' => '', 'label' => '']]; 37 | $payments = $this->paymentConfig->getActiveMethods(); 38 | foreach ($payments as $paymentCode => $paymentModel) { 39 | $paymentTitle = $this->scopeConfig->getValue( 40 | 'payment/' . $paymentCode . '/title', 41 | ScopeInterface::SCOPE_STORE 42 | ); 43 | 44 | $methods[$paymentCode] = [ 45 | 'label' => $paymentTitle, 46 | 'value' => $paymentCode 47 | ]; 48 | } 49 | 50 | return $methods; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Model/Config/Source/AllegroAttribute.php: -------------------------------------------------------------------------------- 1 | 'id', 19 | 'name' => 'name' 20 | ]; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Model/Config/Source/DeliveryMethods.php: -------------------------------------------------------------------------------- 1 | deliveryMethodRepository = $deliveryMethodRepository; 25 | } 26 | 27 | /** 28 | * @return array 29 | */ 30 | public function toOptionArray() 31 | { 32 | $options = []; 33 | 34 | try { 35 | $deliveryMethods = $this->deliveryMethodRepository->getList(); 36 | } catch (ClientException $e) { 37 | return $options; 38 | } 39 | 40 | foreach ($deliveryMethods as $deliveryMethod) { 41 | $options[] = [ 42 | 'value' => $deliveryMethod->getId(), 43 | 'label' => $deliveryMethod->getName() . ' - ' . $deliveryMethod->getPaymentPolicy() 44 | ]; 45 | } 46 | return $options; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Model/Config/Source/HandlingTime.php: -------------------------------------------------------------------------------- 1 | getOptions() as $value => $label) { 14 | $options[] = [ 15 | 'value' => $value, 16 | 'label' => $label 17 | ]; 18 | } 19 | return $options; 20 | } 21 | 22 | public function getOptions() 23 | { 24 | return [ 25 | 'PT0S' => __('Instantly'), 26 | 'PT24H' => __('%1 hours', 24), 27 | 'PT48H' => __('%1 days', 2), 28 | 'PT72H' => __('%1 days', 3), 29 | 'PT96H' => __('%1 days', 4), 30 | 'PT120H' => __('%1 days', 5), 31 | 'PT144H' => __('%1 days', 7), 32 | 'PT240H' => __('%1 days', 10), 33 | 'PT336H' => __('%1 days', 14), 34 | 'PT576H' => __('%1 days', 21), 35 | 'PT720H' => __('%1 days', 30), 36 | 'PT1440H' => __('%1 days', 60), 37 | ]; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Model/Config/Source/ImpliedWarranty.php: -------------------------------------------------------------------------------- 1 | impliedWarrantyRepository = $impliedWarrantyRepository; 25 | } 26 | 27 | /** 28 | * @return array 29 | */ 30 | public function toOptionArray() 31 | { 32 | $options = []; 33 | 34 | try { 35 | $impliedWarranties = $this->impliedWarrantyRepository->getList(); 36 | } catch (ClientException $e) { 37 | return $options; 38 | } 39 | 40 | foreach ($impliedWarranties as $impliedWarranty) { 41 | $options[] = [ 42 | 'value' => $impliedWarranty->getId(), 43 | 'label' => $impliedWarranty->getName() 44 | ]; 45 | } 46 | return $options; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Model/Config/Source/PaymentsInvoice.php: -------------------------------------------------------------------------------- 1 | getOptions() as $value => $label) { 14 | $options[] = [ 15 | 'value' => $value, 16 | 'label' => $label 17 | ]; 18 | } 19 | return $options; 20 | } 21 | 22 | public function getOptions() 23 | { 24 | return [ 25 | 'VAT' => __('Invoice'), 26 | 'VAT_MARGIN' => __('Invoice Margin'), 27 | 'WITHOUT_VAT' => __('Invoice without VAT'), 28 | 'NO_INVOICE' => __('I don\'t issue invoices') 29 | ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Model/Config/Source/Province.php: -------------------------------------------------------------------------------- 1 | getOptions() as $value => $label) { 14 | $options[] = [ 15 | 'value' => $value, 16 | 'label' => $label 17 | ]; 18 | } 19 | return $options; 20 | } 21 | 22 | public function getOptions() 23 | { 24 | return [ 25 | '' => __('--Please Select--'), 26 | 'DOLNOSLASKIE' => 'Dolnośląskie', 27 | 'KUJAWSKO_POMORSKIE' => 'Kujawsko-pomorskie', 28 | 'LUBELSKIE' => 'Lubelskie', 29 | 'LUBUSKIE' => 'Lubuskie', 30 | 'LODZKIE' => 'Łódzkie', 31 | 'MALOPOLSKIE' => 'Małopolskie', 32 | 'MAZOWIECKIE' => 'Mazowieckie', 33 | 'OPOLSKIE' => 'Opolskie', 34 | 'PODKARPACKIE' => 'Podkarpackie', 35 | 'PODLASKIE' => 'Podlaskie', 36 | 'POMORSKIE' => 'Pomorskie', 37 | 'SLASKIE' => 'Śląskie', 38 | 'SWIETOKRZYSKIE' => 'Świętokrzyskie', 39 | 'WARMINSKO_MAZURSKIE' => 'Warmińsko-mazurskie', 40 | 'WIELKOPOLSKIE' => 'Wielkopolskie', 41 | 'ZACHODNIOPOMORSKIE' => 'Zachodniopomorskie', 42 | ]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Model/Config/Source/ReturnPolicy.php: -------------------------------------------------------------------------------- 1 | returnPolicyRepository = $returnPolicyRepository; 27 | } 28 | 29 | /** 30 | * @return array 31 | */ 32 | public function toOptionArray() 33 | { 34 | $options = []; 35 | 36 | try { 37 | $returnPolicies = $this->returnPolicyRepository->getList(); 38 | } catch (ClientException $e) { 39 | return $options; 40 | } 41 | 42 | foreach ($returnPolicies as $returnPolicy) { 43 | $options[] = [ 44 | 'value' => $returnPolicy->getId(), 45 | 'label' => $returnPolicy->getName() 46 | ]; 47 | } 48 | return $options; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Model/Config/Source/ShippingRates.php: -------------------------------------------------------------------------------- 1 | shippingRateRepository = $shippingRateRepository; 22 | } 23 | 24 | /** 25 | * @return array 26 | */ 27 | public function toOptionArray() 28 | { 29 | $options = []; 30 | 31 | try { 32 | 33 | $shippingRates = $this->shippingRateRepository->getList(); 34 | 35 | } catch (ClientException $e) { 36 | return $options; 37 | } 38 | 39 | foreach ($shippingRates as $shippingRate) { 40 | $options[] = [ 41 | 'value' => $shippingRate->getId(), 42 | 'label' => $shippingRate->getName() 43 | ]; 44 | } 45 | return $options; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Model/Config/Source/State.php: -------------------------------------------------------------------------------- 1 | orderStatusCollectionFactory = $orderStatusCollectionFactory; 27 | } 28 | 29 | /** 30 | * @return array 31 | */ 32 | public function toOptionArray() 33 | { 34 | $collection = $this->orderStatusCollectionFactory->create()->joinStates(); 35 | $options = []; 36 | foreach ($collection as $item) { 37 | $options[] = [ 38 | 'value' => $item->getStatus() . Status::STATUS_STATE_SEPARATOR . $item->getState(), 39 | 'label' => __($item->getLabel()) 40 | ]; 41 | } 42 | 43 | return $options; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Model/Config/Source/Warranty.php: -------------------------------------------------------------------------------- 1 | warrantyRepository = $warrantyRepository; 26 | } 27 | 28 | /** 29 | * @return array 30 | */ 31 | public function toOptionArray() 32 | { 33 | $options = []; 34 | 35 | try { 36 | $warranties = $this->warrantyRepository->getList(); 37 | } catch (ClientException $e) { 38 | return $options; 39 | } 40 | 41 | foreach ($warranties as $warranty) { 42 | $options[] = [ 43 | 'value' => $warranty->getId(), 44 | 'label' => $warranty->getName() 45 | ]; 46 | } 47 | return $options; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Model/Consumer/Message.php: -------------------------------------------------------------------------------- 1 | productId = $productId; 23 | } 24 | 25 | /** 26 | * {@inheritdoc} 27 | */ 28 | public function getProductId(): int 29 | { 30 | return $this->productId; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Model/Data/CheckoutForm/Amount.php: -------------------------------------------------------------------------------- 1 | setData(self::AMOUNT_FIELD_NAME, $amount); 20 | } 21 | 22 | /** 23 | * @return float 24 | */ 25 | public function getAmount(): ?float 26 | { 27 | return $this->getData(self::AMOUNT_FIELD_NAME); 28 | } 29 | 30 | /** 31 | * @param array $rawData 32 | */ 33 | public function setRawData(array $rawData) 34 | { 35 | if (isset($rawData['amount'])) { 36 | $this->setAmount($rawData['amount']); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Model/Data/CheckoutForm/Delivery/Cost.php: -------------------------------------------------------------------------------- 1 | setData(self::AMOUNT_FIELD_NAME, $amount); 16 | } 17 | 18 | public function getAmount(): ?float 19 | { 20 | return $this->getData(self::AMOUNT_FIELD_NAME); 21 | } 22 | 23 | public function setRawData(array $rawData) 24 | { 25 | if (isset($rawData['amount'])) { 26 | $this->setAmount($rawData['amount']); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Model/Data/CheckoutForm/Delivery/Method.php: -------------------------------------------------------------------------------- 1 | setData(self::ID_FIELD_NAME, $id); 20 | } 21 | 22 | /** 23 | * @return string 24 | */ 25 | public function getId(): ?string 26 | { 27 | return $this->getData(self::ID_FIELD_NAME); 28 | } 29 | 30 | /** 31 | * @param array $rawData 32 | * @return void 33 | */ 34 | public function setRawData(array $rawData) 35 | { 36 | if (isset($rawData['id'])) { 37 | $this->setId($rawData['id']); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Model/Data/CheckoutForm/Invoice/Address/Company.php: -------------------------------------------------------------------------------- 1 | setData(self::NAME_FIELD_NAME, $name); 17 | } 18 | 19 | public function setVatId(string $vatId) 20 | { 21 | $this->setData(self::VAT_ID_FIELD_NAME, $vatId); 22 | } 23 | 24 | public function getName(): ?string 25 | { 26 | return $this->getData(self::NAME_FIELD_NAME); 27 | } 28 | 29 | public function getVatId(): ?string 30 | { 31 | return $this->getData(self::VAT_ID_FIELD_NAME); 32 | } 33 | 34 | public function setRawData(array $rawData) 35 | { 36 | if (isset($rawData['name'])) { 37 | $this->setName($rawData['name']); 38 | } 39 | if (isset($rawData['taxId'])) { 40 | $this->setVatId($rawData['taxId']); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Model/Data/CheckoutForm/Invoice/Address/NaturalPerson.php: -------------------------------------------------------------------------------- 1 | setData(self::FIRST_NAME_FIELD_NAME, $firstName); 17 | } 18 | 19 | public function setLastName(string $lastName) 20 | { 21 | $this->setData(self::LAST_NAME_FIELD_NAME, $lastName); 22 | } 23 | 24 | public function getFirstName(): ?string 25 | { 26 | return $this->getData(self::FIRST_NAME_FIELD_NAME); 27 | } 28 | 29 | public function getLastName(): ?string 30 | { 31 | return $this->getData(self::LAST_NAME_FIELD_NAME); 32 | } 33 | 34 | public function setRawData(array $rawData) 35 | { 36 | if (isset($rawData['firstName'])) { 37 | $this->setFirstName($rawData['firstName']); 38 | } 39 | if (isset($rawData['lastName'])) { 40 | $this->setLastName($rawData['lastName']); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Model/Data/CheckoutForm/Summary.php: -------------------------------------------------------------------------------- 1 | amountFactory = $amountFactory; 25 | } 26 | 27 | /** 28 | * @param AmountInterface $totalToPay 29 | */ 30 | public function setTotalToPay(AmountInterface $totalToPay) 31 | { 32 | $this->setData(self::TOTAL_TO_PAY_FIELD_NAME, $totalToPay); 33 | } 34 | 35 | /** 36 | * @return AmountInterface 37 | */ 38 | public function getTotalToPay(): AmountInterface 39 | { 40 | return $this->getData(self::TOTAL_TO_PAY_FIELD_NAME); 41 | } 42 | 43 | /** 44 | * @param array $rawData 45 | */ 46 | public function setRawData(array $rawData) 47 | { 48 | $this->setTotalToPay($this->mapAmountData($rawData['totalToPay'] ?? [])); 49 | } 50 | 51 | /** 52 | * @param array $data 53 | * @return AmountInterface|null 54 | */ 55 | private function mapAmountData(array $data): AmountInterface 56 | { 57 | /** @var AmountInterface $amount */ 58 | $amount = $this->amountFactory->create(); 59 | $amount->setRawData($data); 60 | return $amount; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Model/Data/Image.php: -------------------------------------------------------------------------------- 1 | setData(self::URL_FIELD_NAME, $url); 21 | } 22 | 23 | /** 24 | * @param int $status 25 | * @return void 26 | */ 27 | public function setStatus(int $status) 28 | { 29 | $this->setData(self::STATUS_FIELD_NAME, $status); 30 | } 31 | 32 | /** 33 | * @return string 34 | */ 35 | public function getUrl(): ?string 36 | { 37 | return $this->getData(self::URL_FIELD_NAME); 38 | } 39 | 40 | /** 41 | * @return string 42 | */ 43 | public function getStatus(): ?int 44 | { 45 | return $this->getData(self::STATUS_FIELD_NAME); 46 | } 47 | 48 | /** 49 | * @param array $rawData 50 | * @return void 51 | */ 52 | public function setRawData(array $rawData) 53 | { 54 | $this->setData($rawData); 55 | $this->setStatus(self::STATUS_UPLOADED); 56 | } 57 | 58 | /** 59 | * @return array 60 | */ 61 | public function getRawData(): array 62 | { 63 | return $this->getData(); 64 | } 65 | 66 | /** 67 | * @return string 68 | */ 69 | public function getPath() 70 | { 71 | return $this->getData(self::PATH); 72 | } 73 | 74 | /** 75 | * @param string $path 76 | * @return Image 77 | */ 78 | public function setPath($path) 79 | { 80 | return $this->setData(self::PATH, $path); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Model/Data/ImpliedWarranty.php: -------------------------------------------------------------------------------- 1 | setData(self::ID_FIELD_NAME, $id); 20 | } 21 | 22 | /** 23 | * @param string $name 24 | * @return void 25 | */ 26 | public function setName(string $name) 27 | { 28 | $this->setData(self::NAME_FIELD_NAME, $name); 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getId(): ?string 35 | { 36 | return $this->getData(self::ID_FIELD_NAME); 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function getName(): ?string 43 | { 44 | return $this->getData(self::NAME_FIELD_NAME); 45 | } 46 | 47 | /** 48 | * @param array $rawData 49 | * @return void 50 | */ 51 | public function setRawData(array $rawData) 52 | { 53 | if (isset($rawData['id'])) { 54 | $this->setId($rawData['id']); 55 | } 56 | if (isset($rawData['name'])) { 57 | $this->setName($rawData['name']); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Model/Data/Parameter.php: -------------------------------------------------------------------------------- 1 | setData(self::ID_FIELD_NAME, $id); 21 | } 22 | 23 | /** 24 | * @return int 25 | */ 26 | public function getId(): ?int 27 | { 28 | return $this->getData(self::ID_FIELD_NAME); 29 | } 30 | 31 | /** 32 | * @param array $rawData 33 | */ 34 | public function setRawData(array $rawData) 35 | { 36 | if (isset($rawData['id'])) { 37 | $this->setId($rawData['id']); 38 | } 39 | } 40 | 41 | /** 42 | * @param string[] $values 43 | * @return string[] 44 | */ 45 | protected function stripEmptyValues(array $values): array 46 | { 47 | $result = []; 48 | foreach ($values as $value) { 49 | if ($value === null || $value === '') { 50 | continue; 51 | } 52 | $result[] = $value; 53 | } 54 | return $result; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Model/Data/Parameter/Values.php: -------------------------------------------------------------------------------- 1 | setData(self::VALUE_FIELD_NAME, $this->stripEmptyValues($value)); 20 | } 21 | 22 | /** 23 | * @return string[] 24 | */ 25 | public function getValue(): array 26 | { 27 | return $this->getData(self::VALUE_FIELD_NAME); 28 | } 29 | 30 | /** 31 | * @param array $rawData 32 | */ 33 | public function setRawData(array $rawData) 34 | { 35 | parent::setRawData($rawData); 36 | $this->setValue($rawData['values'] ?? []); 37 | } 38 | 39 | /** 40 | * @return bool 41 | */ 42 | public function isValueEmpty(): bool 43 | { 44 | return count($this->getValue()) < 1; 45 | } 46 | 47 | /** 48 | * @return array 49 | */ 50 | public function getRawData(): array 51 | { 52 | return [ 53 | 'id' => $this->getId(), 54 | 'valuesIds' => [], 55 | 'values' => $this->getValue(), 56 | 'rangeValue' => null 57 | ]; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Model/Data/Parameter/ValuesIds.php: -------------------------------------------------------------------------------- 1 | setData(self::VALUE_FIELD_NAME, $this->stripEmptyValues($value)); 20 | } 21 | 22 | /** 23 | * @return int[] 24 | */ 25 | public function getValue(): array 26 | { 27 | return $this->getData(self::VALUE_FIELD_NAME); 28 | } 29 | 30 | /** 31 | * @return bool 32 | */ 33 | public function isValueEmpty(): bool 34 | { 35 | return count($this->getValue()) < 1; 36 | } 37 | 38 | /** 39 | * @param array $rawData 40 | */ 41 | public function setRawData(array $rawData) 42 | { 43 | parent::setRawData($rawData); 44 | $this->setValue($rawData['valuesIds'] ?? []); 45 | } 46 | 47 | /** 48 | * @return array 49 | */ 50 | public function getRawData(): array 51 | { 52 | return [ 53 | 'id' => $this->getId(), 54 | 'valuesIds' => $this->getValue(), 55 | 'value' => [], 56 | 'rangeValue' => null 57 | ]; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Model/Data/ParameterDefinition/DictionaryItem.php: -------------------------------------------------------------------------------- 1 | setData(self::VALUE_FIELD_NAME, $value); 21 | } 22 | 23 | /** 24 | * @param string $label 25 | */ 26 | public function setLabel(string $label) 27 | { 28 | $this->setData(self::LABEL_FIELD_NAME, $label); 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getValue(): ?string 35 | { 36 | return $this->getData(self::VALUE_FIELD_NAME); 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function getLabel(): ?string 43 | { 44 | return $this->getData(self::LABEL_FIELD_NAME); 45 | } 46 | 47 | /** 48 | * @param array $rawData 49 | * @return void 50 | */ 51 | public function setRawData(array $rawData) 52 | { 53 | if (isset($rawData['id'])) { 54 | $this->setValue($rawData['id']); 55 | } 56 | if (isset($rawData['value'])) { 57 | $this->setLabel($rawData['value']); 58 | } 59 | } 60 | 61 | /** 62 | * @return array 63 | */ 64 | public function getRawData(): array 65 | { 66 | return [ 67 | 'id' => $this->getValue(), 68 | 'value' => $this->getLabel() 69 | ]; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Model/Data/ParameterDefinition/Restriction.php: -------------------------------------------------------------------------------- 1 | setData(self::TYPE_FIELD_NAME, $type); 20 | } 21 | 22 | /** 23 | * @param mixed $value 24 | */ 25 | public function setValue($value) 26 | { 27 | $this->setData(self::VALUE_FIELD_NAME, $value); 28 | } 29 | 30 | /** 31 | * @return string|null 32 | */ 33 | public function getType(): ?string 34 | { 35 | return $this->getData(self::TYPE_FIELD_NAME); 36 | } 37 | 38 | /** 39 | * @return mixed 40 | */ 41 | public function getValue() 42 | { 43 | return $this->getData(self::VALUE_FIELD_NAME); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Model/Data/ParameterFactoryException.php: -------------------------------------------------------------------------------- 1 | setData(self::OFFER_ID_FIELD_NAME, $offerId); 21 | } 22 | 23 | /** 24 | * @param string $action 25 | * @return void 26 | */ 27 | public function setAction(string $action) 28 | { 29 | $this->setData(self::ACTION_FIELD_NAME, $action); 30 | } 31 | 32 | /** 33 | * @return string 34 | */ 35 | public function getOfferId(): ?string 36 | { 37 | return $this->getData(self::OFFER_ID_FIELD_NAME); 38 | } 39 | 40 | /** 41 | * @return string 42 | */ 43 | public function getAction(): ?string 44 | { 45 | return $this->getData(self::ACTION_FIELD_NAME); 46 | } 47 | 48 | /** 49 | * @return array 50 | */ 51 | public function getRawData(): array 52 | { 53 | return [ 54 | 'offerCriteria' => [ 55 | [ 56 | 'offers' => [ 57 | [ 58 | 'id' => $this->getOfferId() 59 | ] 60 | ], 61 | 'type' => 'CONTAINS_OFFERS' 62 | ] 63 | ], 64 | 'publication' => [ 65 | 'action' => $this->getAction() 66 | ] 67 | ]; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Model/Data/ReturnPolicy.php: -------------------------------------------------------------------------------- 1 | setData(self::ID_FIELD_NAME, $id); 20 | } 21 | 22 | /** 23 | * @param string $name 24 | * @return void 25 | */ 26 | public function setName(string $name) 27 | { 28 | $this->setData(self::NAME_FIELD_NAME, $name); 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getId(): ?string 35 | { 36 | return $this->getData(self::ID_FIELD_NAME); 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function getName(): ?string 43 | { 44 | return $this->getData(self::NAME_FIELD_NAME); 45 | } 46 | 47 | /** 48 | * @param array $rawData 49 | * @return void 50 | */ 51 | public function setRawData(array $rawData) 52 | { 53 | if (isset($rawData['id'])) { 54 | $this->setId($rawData['id']); 55 | } 56 | if (isset($rawData['name'])) { 57 | $this->setName($rawData['name']); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Model/Data/ShippingRate.php: -------------------------------------------------------------------------------- 1 | setData(self::ID_FIELD_NAME, $id); 20 | } 21 | 22 | /** 23 | * @param string $name 24 | */ 25 | public function setName(string $name) 26 | { 27 | $this->setData(self::NAME_FIELD_NAME, $name); 28 | } 29 | 30 | /** 31 | * @return string|null 32 | */ 33 | public function getId(): ?string 34 | { 35 | return $this->getData(self::ID_FIELD_NAME); 36 | } 37 | 38 | /** 39 | * @return string|null 40 | */ 41 | public function getName(): ?string 42 | { 43 | return $this->getData(self::NAME_FIELD_NAME); 44 | } 45 | 46 | /** 47 | * @param array $rawData 48 | */ 49 | public function setRawData(array $rawData) 50 | { 51 | if (isset($rawData['id'])) { 52 | $this->setId($rawData['id']); 53 | } 54 | if (isset($rawData['name'])) { 55 | $this->setName($rawData['name']); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Model/Data/Warranty.php: -------------------------------------------------------------------------------- 1 | setData(self::ID_FIELD_NAME, $id); 20 | } 21 | 22 | /** 23 | * @param string $name 24 | * @return void 25 | */ 26 | public function setName(string $name) 27 | { 28 | $this->setData(self::NAME_FIELD_NAME, $name); 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getId(): ?string 35 | { 36 | return $this->getData(self::ID_FIELD_NAME); 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function getName(): ?string 43 | { 44 | return $this->getData(self::NAME_FIELD_NAME); 45 | } 46 | 47 | /** 48 | * @param array $rawData 49 | * @return void 50 | */ 51 | public function setRawData(array $rawData) 52 | { 53 | if (isset($rawData['id'])) { 54 | $this->setId($rawData['id']); 55 | } 56 | if (isset($rawData['name'])) { 57 | $this->setName($rawData['name']); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Model/Guid.php: -------------------------------------------------------------------------------- 1 | images = $images; 25 | } 26 | 27 | /** 28 | * @param ImageInterface $image 29 | * @throws CouldNotSaveException 30 | */ 31 | public function save(ImageInterface $image) 32 | { 33 | if ($image->getStatus() == ImageInterface::STATUS_UPLOADED) { 34 | throw new CouldNotSaveException(__( 35 | 'Image with url "%1" is already uploaded to allegro', 36 | $image->getPath() 37 | )); 38 | } 39 | 40 | try { 41 | $response = $this->images->postImage($image->getPath()); 42 | } catch (\Exception $e) { 43 | throw new CouldNotSaveException( 44 | __('Image with url "%1" could not be saved Reason: %2', $image->getPath(), $e->getMessage()), 45 | $e 46 | ); 47 | } 48 | 49 | $image->setUrl($response['location']); 50 | $image->setStatus(ImageInterface::STATUS_UPLOADED); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Model/OrderImporter/CreatorItemsException.php: -------------------------------------------------------------------------------- 1 | successIds = $successIds; 28 | return $this; 29 | } 30 | 31 | /** 32 | * @param array $errorsIds 33 | * @return Info 34 | */ 35 | public function setErrorsIds(array $errorsIds): Info 36 | { 37 | $this->errorsIds = $errorsIds; 38 | return $this; 39 | } 40 | 41 | /** 42 | * @param array $skippedIds 43 | * @return Info 44 | */ 45 | public function setSkippedIds(array $skippedIds): Info 46 | { 47 | $this->skippedIds = $skippedIds; 48 | return $this; 49 | } 50 | 51 | /** 52 | * @return string 53 | */ 54 | public function getMessage() 55 | { 56 | return sprintf( 57 | "Created orders:\n%s\nOrders with errors:\n%s\nSkipped orders:\n%s", 58 | implode("\n", $this->successIds), 59 | implode("\n", $this->errorsIds), 60 | implode("\n", $this->skippedIds) 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Model/OrderImporter/Invoice.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 35 | $this->invoiceService = $invoiceService; 36 | $this->transaction = $transaction; 37 | } 38 | 39 | /** 40 | * @param Order $order 41 | */ 42 | public function create(Order $order) 43 | { 44 | if (!$order->canInvoice() || $order->hasInvoices()) { 45 | return; 46 | } 47 | try { 48 | $invoice = $this->invoiceService->prepareInvoice($order); 49 | $invoice->register(); 50 | $transactionSave = $this->transaction 51 | ->addObject($invoice) 52 | ->addObject($invoice->getOrder()); 53 | $transactionSave->save(); 54 | } catch (\Exception $exception) { 55 | $this->logger->exception($exception, 'Error while creating invoice'); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Model/OrderImporter/OrderProcessingException.php: -------------------------------------------------------------------------------- 1 | getOrderFrom(), self::ALLEGRO) !== false) { 22 | return true; 23 | } 24 | 25 | $extensionAttributes = $order->getExtensionAttributes(); 26 | if ($extensionAttributes && stripos($extensionAttributes->getOrderFrom(), self::ALLEGRO) !== false) { 27 | return true; 28 | } 29 | 30 | return false; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Model/OrderImporter/ReservationPlacingException.php: -------------------------------------------------------------------------------- 1 | _init(ResourceModel::class); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Model/PriceCommand.php: -------------------------------------------------------------------------------- 1 | offers = $offers; 23 | } 24 | 25 | /** 26 | * @param string $offerId 27 | * @param float $price 28 | * @return array 29 | * @throws Api\ClientResponseErrorException 30 | * @throws ClientException 31 | * @throws ClientResponseException 32 | */ 33 | public function change(string $offerId, float $price) 34 | { 35 | return $this->offers->changePrice($offerId, $price); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Model/PublicationCommandRepository.php: -------------------------------------------------------------------------------- 1 | offers = $offers; 25 | } 26 | 27 | /** 28 | * @param PublicationCommandInterface $publication 29 | * @throws ClientException 30 | * @throws CouldNotSaveException 31 | */ 32 | public function save(PublicationCommandInterface $publication) 33 | { 34 | try { 35 | 36 | $this->offers->changeOfferStatus($publication->getRawData()); 37 | 38 | } catch (ClientResponseException $e) { 39 | throw new CouldNotSaveException(__('Could not send publication request Reason: %1', $e->getMessage()), $e); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Model/QuantityCommand.php: -------------------------------------------------------------------------------- 1 | offers = $offers; 26 | } 27 | 28 | /** 29 | * @param $offerId 30 | * @param $qty 31 | * @return array 32 | * @throws Api\ClientResponseErrorException 33 | * @throws ClientException 34 | * @throws ClientResponseException 35 | */ 36 | public function change($offerId, $qty) 37 | { 38 | return $this->offers->changeQuantity($offerId, $qty); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Model/ResourceModel/Order.php: -------------------------------------------------------------------------------- 1 | getConnection(); 17 | 18 | $select = $connection->select() 19 | ->from(['e' => 'sales_order'], 'e.entity_id') 20 | ->where('e.external_id = :externalId'); 21 | 22 | $bind = [ 23 | ':externalId' => (string)$checkoutFormId, 24 | ]; 25 | 26 | return $connection->fetchOne($select, $bind); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Model/ResourceModel/Order/CheckoutForm.php: -------------------------------------------------------------------------------- 1 | requestGet('order/checkout-forms/' . $checkoutFormId, []); 25 | } 26 | 27 | /** 28 | * @param $checkoutFormId 29 | * @param array $shippingData 30 | * @return array 31 | * @throws ClientException 32 | * @throws ClientResponseErrorException 33 | * @throws ClientResponseException 34 | */ 35 | public function shipment($checkoutFormId, array $shippingData) 36 | { 37 | return $this->requestPost('order/checkout-forms/' . $checkoutFormId . '/shipments', $shippingData); 38 | } 39 | 40 | /** 41 | * @param $checkoutFormId 42 | * @param string $status 43 | * @return array 44 | * @throws ClientException 45 | * @throws ClientResponseErrorException 46 | * @throws ClientResponseException 47 | */ 48 | public function changeOrderStatus($checkoutFormId, string $status) 49 | { 50 | return $this->requestPut('order/checkout-forms/' . $checkoutFormId . '/fulfillment', ['status' => $status]); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Model/ResourceModel/Order/EventStats.php: -------------------------------------------------------------------------------- 1 | requestGet('/order/event-stats', []); 23 | return $response['latestEvent'] ?? []; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Model/ResourceModel/Order/Events.php: -------------------------------------------------------------------------------- 1 | requestGet('/order/events', []); 22 | return $response['events'] ?? []; 23 | } 24 | 25 | /** 26 | * @param string $from 27 | * @return mixed 28 | * @throws ClientException 29 | * @throws \Macopedia\Allegro\Model\Api\ClientResponseErrorException 30 | * @throws \Macopedia\Allegro\Model\Api\ClientResponseException 31 | */ 32 | public function getListFrom(string $from) 33 | { 34 | $response = $this->requestGet('/order/events?from=' . $from, []); 35 | return $response['events'] ?? []; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Model/ResourceModel/OrderLog.php: -------------------------------------------------------------------------------- 1 | _init('allegro_orders_with_errors', 'entity_id'); 15 | } 16 | 17 | /** 18 | * @param string $checkoutFormId 19 | */ 20 | public function deleteByCheckoutFormId(string $checkoutFormId) 21 | { 22 | $this->getConnection()->delete( 23 | 'allegro_orders_with_errors', 24 | [Model::CHECKOUT_FORM_ID_FIELD . ' = ?' => $checkoutFormId] 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Model/ResourceModel/OrderLog/Collection.php: -------------------------------------------------------------------------------- 1 | _init(OrderLog::class, Resource::class); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Model/ResourceModel/PickupPoint.php: -------------------------------------------------------------------------------- 1 | _init('sales_order_pickup_point', 'entity_id'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Model/ResourceModel/Reservation.php: -------------------------------------------------------------------------------- 1 | _init('allegro_reservations', 'entity_id'); 15 | } 16 | 17 | /** 18 | * @param int $reservationId 19 | */ 20 | public function deleteByReservationId(int $reservationId) 21 | { 22 | $this->getConnection()->delete( 23 | 'allegro_reservations', 24 | [Model::RESERVATION_ID_FIELD . ' = ?' => $reservationId] 25 | ); 26 | } 27 | 28 | public function deleteBySkuAndCheckoutFormId(string $sku, string $checkoutFormId) 29 | { 30 | $this->getConnection()->delete( 31 | 'allegro_reservations', 32 | [ 33 | Model::SKU_FIELD . ' = ?' => $sku, 34 | Model::CHECKOUT_FORM_ID_FIELD . ' = ?' => $checkoutFormId 35 | ] 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Model/ResourceModel/Reservation/Collection.php: -------------------------------------------------------------------------------- 1 | _init(Reservation::class, Resource::class); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Model/ResourceModel/Sale/AfterSaleServices.php: -------------------------------------------------------------------------------- 1 | cachedRequestGet( 18 | '/after-sales-service-conditions/implied-warranties?seller.id=' . $this->getCurrentUserId() 19 | ); 20 | return $result['impliedWarranties']; 21 | } 22 | 23 | /** 24 | * @return array 25 | * @throws \Macopedia\Allegro\Model\Api\ClientException 26 | * @throws \Macopedia\Allegro\Model\Api\ClientResponseErrorException 27 | * @throws \Macopedia\Allegro\Model\Api\ClientResponseException 28 | */ 29 | public function getReturnPoliciesList() 30 | { 31 | $result = $this->cachedRequestGet( 32 | '/after-sales-service-conditions/return-policies?seller.id=' . $this->getCurrentUserId() 33 | ); 34 | return $result['returnPolicies']; 35 | } 36 | 37 | /** 38 | * @return array 39 | * @throws \Macopedia\Allegro\Model\Api\ClientException 40 | * @throws \Macopedia\Allegro\Model\Api\ClientResponseErrorException 41 | * @throws \Macopedia\Allegro\Model\Api\ClientResponseException 42 | */ 43 | public function getWarrantiesList() 44 | { 45 | $result = $this->cachedRequestGet( 46 | '/after-sales-service-conditions/warranties?seller.id=' . $this->getCurrentUserId() 47 | ); 48 | return $result['warranties']; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Model/ResourceModel/Sale/DeliveryMethod.php: -------------------------------------------------------------------------------- 1 | cachedRequestGet('/sale/delivery-methods'); 23 | return $response['deliveryMethods'] ?? []; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Model/ResourceModel/Sale/Images.php: -------------------------------------------------------------------------------- 1 | file = $file; 34 | } 35 | 36 | /** 37 | * @param string $imagePath 38 | * @return array 39 | * @throws ClientException 40 | * @throws ClientResponseErrorException 41 | * @throws ClientResponseException 42 | * @throws FileSystemException 43 | */ 44 | public function postImage(string $imagePath) 45 | { 46 | return $this->sendRawRequest( 47 | 'sale/images', 48 | MagentoRequest::HTTP_METHOD_POST, 49 | $this->file->fileGetContents($imagePath), 50 | \mime_content_type($imagePath) 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Model/ResourceModel/Sale/ShippingRates.php: -------------------------------------------------------------------------------- 1 | cachedRequestGet('/sale/shipping-rates?seller.id=' . $this->getCurrentUserId()); 19 | return $response['shippingRates'] ?? []; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Model/ShippingRateRepository.php: -------------------------------------------------------------------------------- 1 | shippingRates = $shippingRates; 29 | $this->shippingRateFactory = $shippingRateFactory; 30 | } 31 | 32 | /** 33 | * @return ShippingRateInterface[] 34 | * @throws ClientException 35 | */ 36 | public function getList(): array 37 | { 38 | try { 39 | 40 | $shippingRatesData = $this->shippingRates->getList(); 41 | 42 | } catch (ClientResponseException $e) { 43 | return []; 44 | } 45 | 46 | $shippingRates = []; 47 | foreach ($shippingRatesData as $shippingRateData) { 48 | /** @var ShippingRateInterface $shippingRate */ 49 | $shippingRate = $this->shippingRateFactory->create(); 50 | $shippingRate->setRawData($shippingRateData); 51 | $shippingRates[] = $shippingRate; 52 | } 53 | 54 | return $shippingRates; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Model/WarrantyRepository.php: -------------------------------------------------------------------------------- 1 | afterSaleServices = $afterSaleServices; 31 | $this->warrantyFactory = $warrantyFactory; 32 | } 33 | 34 | /** 35 | * @return WarrantyInterface[] 36 | * @throws ClientException 37 | */ 38 | public function getList(): array 39 | { 40 | try { 41 | 42 | $warrantiesData = $this->afterSaleServices->getWarrantiesList(); 43 | 44 | } catch (ClientResponseException $e) { 45 | return []; 46 | } 47 | 48 | $warranties = []; 49 | foreach ($warrantiesData as $warrantyData) { 50 | /** @var WarrantyInterface $warranty */ 51 | $warranty = $this->warrantyFactory->create(); 52 | $warranty->setRawData($warrantyData); 53 | $warranties[] = $warranty; 54 | } 55 | return $warranties; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Observer/CopyFieldsFromQuoteToOrderObserver.php: -------------------------------------------------------------------------------- 1 | objectCopyService = $objectCopyService; 25 | } 26 | 27 | /** 28 | * @param \Magento\Framework\Event\Observer $observer 29 | * @return CopyFieldsFromQuoteToOrderObserver 30 | */ 31 | public function execute(\Magento\Framework\Event\Observer $observer) 32 | { 33 | /* @var \Magento\Sales\Model\Order $order */ 34 | $order = $observer->getEvent()->getData('order'); 35 | /* @var \Magento\Quote\Model\Quote $quote */ 36 | $quote = $observer->getEvent()->getData('quote'); 37 | 38 | $cartExtensions = $quote->getExtensionAttributes(); 39 | if ($cartExtensions) { 40 | $order->setData('external_id', $cartExtensions->getExternalId()); 41 | $order->setData('order_from', $cartExtensions->getOrderFrom()); 42 | $order->setData('allegro_buyer_login', $cartExtensions->getAllegroBuyerLogin()); 43 | } 44 | 45 | $this->objectCopyService->copyFieldsetToTarget('sales_convert_quote', 'to_order', $quote, $order); 46 | 47 | return $this; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Observer/QtyChangeObserver.php: -------------------------------------------------------------------------------- 1 | messageQtyChange = $messageQtyChange; 26 | } 27 | 28 | /** 29 | * @param Observer $observer 30 | * @return void 31 | */ 32 | public function execute(Observer $observer) 33 | { 34 | $productId = $observer->getEvent()->getData('item')->getProductId(); 35 | $this->messageQtyChange->execute($productId); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Observer/SaveOrderAfterObserver.php: -------------------------------------------------------------------------------- 1 | orderOrigin = $orderOrigin; 31 | $this->allegroOrderStatus = $allegroOrderStatus; 32 | } 33 | 34 | /** 35 | * @param Observer $observer 36 | * @return $this 37 | */ 38 | public function execute(Observer $observer) 39 | { 40 | $order = $observer->getEvent()->getOrder(); 41 | 42 | if (!$order->getId() || !$this->orderOrigin->isOrderFromAllegro($order)) { 43 | return $this; 44 | } 45 | $this->allegroOrderStatus->updateOrderStatus($order); 46 | 47 | return $this; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Plugin/RemoveDiscountCalculation.php: -------------------------------------------------------------------------------- 1 | registry = $registry; 23 | } 24 | 25 | public function aroundGetCollectors(Subject $subject, \Closure $proceed, $storeId) 26 | { 27 | $result = $proceed($storeId); 28 | 29 | if (!$this->registry->registry('is_allegro_order')) { 30 | return $result; 31 | } 32 | 33 | unset($result['discount'], $result['shipping_discount']); 34 | 35 | return $result; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Plugin/UpdateShippingRatePrice.php: -------------------------------------------------------------------------------- 1 | getAllItems(); 24 | if (count($allItems) < 1) { 25 | return $result; 26 | } 27 | 28 | /** @var Quote $quote */ 29 | $quote = reset($allItems)->getQuote(); 30 | if (!$quote->getExtensionAttributes()->getOrderFrom() 31 | || !$quote->getExtensionAttributes()->getExternalId() 32 | || !$quote->hasAllegroShippingPrice() 33 | ) { 34 | return $result; 35 | } 36 | 37 | $shippingMethod = $quote->getShippingAddress()->getShippingMethod(); 38 | $allegroShippingPrice = $quote->getAllegroShippingPrice(); 39 | 40 | /** @var \Magento\Quote\Model\Quote\Address\RateResult\Method $item */ 41 | foreach ($result->getResult()->getAllRates() as $item) { 42 | if ($item->getCarrier() . '_' . $item->getMethod() !== $shippingMethod) { 43 | continue; 44 | } 45 | $item->setPrice($allegroShippingPrice); 46 | break; 47 | } 48 | 49 | return $result; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /README/addToAllegroButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/addToAllegroButton.png -------------------------------------------------------------------------------- /README/allegroConnectionConfiguration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroConnectionConfiguration.png -------------------------------------------------------------------------------- /README/allegroDebugMode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroDebugMode.png -------------------------------------------------------------------------------- /README/allegroOfferCreateConfiguration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroOfferCreateConfiguration.png -------------------------------------------------------------------------------- /README/allegroOfferForm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroOfferForm.png -------------------------------------------------------------------------------- /README/allegroOfferId1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroOfferId1.png -------------------------------------------------------------------------------- /README/allegroOfferId2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroOfferId2.png -------------------------------------------------------------------------------- /README/allegroOrderImporterConfiguration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroOrderImporterConfiguration.png -------------------------------------------------------------------------------- /README/allegroOrdersMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroOrdersMenu.png -------------------------------------------------------------------------------- /README/allegroOrdersWithErrorsGrid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroOrdersWithErrorsGrid.png -------------------------------------------------------------------------------- /README/allegroPricePolicyConfiguration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroPricePolicyConfiguration.png -------------------------------------------------------------------------------- /README/allegroReservationsGrid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/allegroReservationsGrid.png -------------------------------------------------------------------------------- /README/apiKeys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/apiKeys.png -------------------------------------------------------------------------------- /README/applicationRegistration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/applicationRegistration.png -------------------------------------------------------------------------------- /README/categoriesAndParameters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/categoriesAndParameters.png -------------------------------------------------------------------------------- /README/deliveryAndPaymentMapping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/deliveryAndPaymentMapping.png -------------------------------------------------------------------------------- /README/imageRole.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/imageRole.png -------------------------------------------------------------------------------- /README/orderStatusesMapping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/orderStatusesMapping.png -------------------------------------------------------------------------------- /README/ordersConfiguration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/ordersConfiguration.png -------------------------------------------------------------------------------- /README/originConfiguration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/originConfiguration.png -------------------------------------------------------------------------------- /README/publishButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/publishButton.png -------------------------------------------------------------------------------- /README/sendTrackingInformation1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/sendTrackingInformation1.png -------------------------------------------------------------------------------- /README/sendTrackingInformation2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/sendTrackingInformation2.png -------------------------------------------------------------------------------- /README/stockInventorySynchronizationDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/macopedia/magento2-allegro/403ed93af304bb97d613a2a369c18ad100d05271/README/stockInventorySynchronizationDiagram.png -------------------------------------------------------------------------------- /Setup/Patch/Data/ImageRolesNotFilterable.php: -------------------------------------------------------------------------------- 1 | moduleDataSetup = $moduleDataSetup; 31 | $this->eavSetupFactory = $eavSetupFactory; 32 | } 33 | 34 | /** 35 | * @return array|string[] 36 | */ 37 | public static function getDependencies() 38 | { 39 | return [ 40 | ImageRoles::class 41 | ]; 42 | } 43 | 44 | /** 45 | * @return array|string[] 46 | */ 47 | public function getAliases() 48 | { 49 | return []; 50 | } 51 | 52 | /** 53 | * @return DataPatchInterface|void 54 | */ 55 | public function apply() 56 | { 57 | /** @var EavSetup $eavSetup */ 58 | $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]); 59 | 60 | $eavSetup->updateAttribute( 61 | \Magento\Catalog\Model\Product::ENTITY, 62 | 'allegro_image', 63 | 'is_filterable', 64 | 0 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "macopedia/magento2-allegro", 3 | "description": "Magento2 module responsible for integration with Allegro API, developed by Macopedia.com", 4 | "type": "magento2-module", 5 | "keywords": [ 6 | "Magento2", 7 | "Allegro" 8 | ], 9 | "license": [ 10 | "MIT" 11 | ], 12 | "authors": [ 13 | { 14 | "name": "Macopedia team", 15 | "role": "Developer", 16 | "email": "extensions@macopedia.pl" 17 | } 18 | ], 19 | "autoload": { 20 | "files": [ 21 | "registration.php" 22 | ], 23 | "psr-4": { 24 | "Macopedia\\Allegro\\": "" 25 | } 26 | }, 27 | "require": { 28 | "php": "^7.1", 29 | "guzzlehttp/guzzle": "*", 30 | "ext-fileinfo": "*", 31 | "ext-json": "*" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /etc/acl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /etc/adminhtml/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Macopedia\Allegro\Model\System\Message\AllegroConnectionStatusMessage 7 | Macopedia\Allegro\Model\System\Message\AllegroOrdersWithErrorsMessage 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /etc/adminhtml/events.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /etc/adminhtml/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /etc/adminhtml/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /etc/cache.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /etc/communication.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | https://allegro.pl/auth/oauth 8 | https://allegro.pl.allegrosandbox.pl/auth/oauth 9 | 10 | 11 | 12 | 13 | 14 | 1 15 | 1 16 | 1 17 | 1 18 | 0 19 | allegro_overpayment:new 20 | allegro_underpayment:new 21 | 22 | 23 | 0 24 | 25 | 26 | 0 27 | 28 | 29 | sku 30 | description 31 | price 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /etc/crontab.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | */5 * * * * 6 | 7 | 8 | 0 * * * * 9 | 10 | 11 | 0 */6 * * * 12 | 13 | 14 | 0 12 * * * 15 | 16 | 17 | 0 10 * * * 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /etc/events.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /etc/extension_attributes.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | point_id 20 | name 21 | description 22 | street 23 | zip_code 24 | city 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /etc/fieldset.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /etc/queue_consumer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /etc/queue_publisher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /etc/queue_topology.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /etc/webapi.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /registration.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /view/adminhtml/layout/allegro_offer_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /view/adminhtml/layout/allegro_orders_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /view/adminhtml/layout/allegro_reservations_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /view/adminhtml/layout/catalog_product_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /view/adminhtml/layout/sales_order_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Macopedia_Allegro::info.phtml 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /view/adminhtml/templates/order/view/allegro_pickup_point_info.phtml: -------------------------------------------------------------------------------- 1 | getOrder(); 8 | $extensionAttributes = $order->getExtensionAttributes(); 9 | $pickupPoint = $extensionAttributes->getPickupPoint(); 10 | ?> 11 | 12 | getIsVirtual()): return ''; 13 | endif; ?> 14 | 16 | 17 |
18 |
19 | escapeHtml(__('Pickup Point')) ?> 20 |
21 |
22 |

23 | escapeHtml(__('ID')) ?>: 24 | escapeHtml($pickupPoint->getPointId()) ?> 25 |

26 |

27 | escapeHtml(__('Name')) ?>: 28 | escapeHtml($pickupPoint->getName()) ?> 29 |

30 |

31 | escapeHtml(__('Description')) ?>: 32 | escapeHtml($pickupPoint->getDescription()) ?> 33 |

34 |

35 | escapeHtml(__('Street')) ?>: 36 | escapeHtml($pickupPoint->getStreet()) ?> 37 |

38 |

39 | escapeHtml(__('Zip Code')) ?>: 40 | escapeHtml($pickupPoint->getZipCode()) ?> 41 |

42 |

43 | escapeHtml(__('City')) ?>: 44 | escapeHtml($pickupPoint->getCity()) ?> 45 |

46 |
47 |
48 | -------------------------------------------------------------------------------- /view/adminhtml/templates/origin_order_data.phtml: -------------------------------------------------------------------------------- 1 | 6 | getExternalId()): ?> 7 |
8 | 9 | escapeHtml(__('Origin of the order')) ?> 10 | 11 |
12 |

escapeHtml(__('External service')) ?>: 13 | escapeHtml($block->getOrderOrigin()) ?>

14 |

escapeHtml(__('External ID')) ?>: 15 | escapeHtml($block->getExternalId()) ?>

16 |

escapeHtml(__('Buyer login')) ?>: 17 | escapeHtml($block->getBuyerLogin()) ?>

18 | 19 | -------------------------------------------------------------------------------- /view/adminhtml/ui_component/sales_order_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | text 10 | true 11 | Origin of the order 12 | 13 | 14 | 15 | 16 | 17 | 18 | text 19 | true 20 | External ID 21 | 22 | 23 | 24 | 25 | 26 | 27 | text 28 | true 29 | Buyer login 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /view/adminhtml/web/js/allegro_offer/form/field/attributes-table/range.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'jquery', 3 | 'knockout', 4 | 'Macopedia_Allegro/js/allegro_offer/form/field/attributes-table/abstract-attribute', 5 | ], function ($, ko, abstract) { 6 | 'use strict'; 7 | 8 | return abstract.extend({ 9 | 10 | defaults: { 11 | template: 'Macopedia_Allegro/allegro_offer/form/field/attributes-table/range', 12 | }, 13 | 14 | initialize: function() { 15 | this.inputValueMin = ko.observable(""); 16 | this.inputValueMax = ko.observable(""); 17 | this._super(); 18 | }, 19 | 20 | _computedValue: function () { 21 | return { 22 | minValue: this.inputValueMin(), 23 | maxValue: this.inputValueMax() 24 | }; 25 | }, 26 | 27 | initializeValue: function (value) { 28 | if (value === undefined || value === null || (Array.isArray(value) && value.length < 1)) { 29 | return; 30 | } 31 | this.inputValueMin = value.minValue; 32 | this.inputValueMin = value.maxValue; 33 | } 34 | 35 | }); 36 | 37 | }); -------------------------------------------------------------------------------- /view/adminhtml/web/js/allegro_offer/form/field/attributes-table/values-ids.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'jquery', 3 | 'knockout', 4 | 'Macopedia_Allegro/js/allegro_offer/form/field/attributes-table/abstract-attribute', 5 | ], function ($, ko, abstract) { 6 | 'use strict'; 7 | 8 | return abstract.extend({ 9 | 10 | defaults: { 11 | template: 'Macopedia_Allegro/allegro_offer/form/field/attributes-table/values-ids', 12 | }, 13 | 14 | initialize: function() { 15 | this.inputValue = ko.observable(""); 16 | this._super(); 17 | }, 18 | 19 | initializeValue: function (value) { 20 | if (value === undefined || value === null || (Array.isArray(value) && value.length < 1)) { 21 | return; 22 | } 23 | if (this.hasRestriction('multipleChoices') && this.getRestrictionValue('multipleChoices')) { 24 | this.inputValue(value); 25 | return; 26 | } 27 | this.inputValue(value[0]); 28 | }, 29 | 30 | _computedValue: function () { 31 | var val = this.inputValue(); 32 | 33 | if (val === "" || val === undefined) { 34 | return []; 35 | } 36 | if (this.hasRestriction('multipleChoices') && this.getRestrictionValue('multipleChoices')) { 37 | return val; 38 | } 39 | return [val]; 40 | } 41 | 42 | }); 43 | 44 | }); -------------------------------------------------------------------------------- /view/adminhtml/web/js/allegro_offer/form/field/attributes-table/values.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'jquery', 3 | 'knockout', 4 | 'Macopedia_Allegro/js/allegro_offer/form/field/attributes-table/abstract-attribute', 5 | ], function ($, ko, abstract) { 6 | 'use strict'; 7 | 8 | return abstract.extend({ 9 | 10 | defaults: { 11 | template: 'Macopedia_Allegro/allegro_offer/form/field/attributes-table/values', 12 | }, 13 | 14 | initialize: function() { 15 | this.inputValue= ko.observable([]); 16 | this._super(); 17 | }, 18 | 19 | initializeValue: function (value) { 20 | if (value === undefined || value === null || (Array.isArray(value) && value.length < 1)) { 21 | this.addNextValue(); 22 | return; 23 | } 24 | var self = this; 25 | $.each(value, function (k, v) { 26 | self.addNextValue(v); 27 | }); 28 | }, 29 | 30 | _computedValue: function () { 31 | var result = []; 32 | $.each(this.inputValue(), function (index, value) { 33 | result.push(value()); 34 | }); 35 | return result; 36 | }, 37 | 38 | addNextValue: function (value) { 39 | if (value === undefined) { 40 | value = ""; 41 | } 42 | var inputValue = [...this.inputValue()]; 43 | inputValue.push(ko.observable(value)); 44 | this.inputValue(inputValue); 45 | }, 46 | 47 | removeValue: function (index) { 48 | var inputValue = [...this.inputValue()]; 49 | inputValue.splice(index, 1); 50 | this.inputValue(inputValue); 51 | } 52 | 53 | }); 54 | 55 | }); -------------------------------------------------------------------------------- /view/adminhtml/web/js/allegro_offer/form/field/ean.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'Magento_Ui/js/form/element/abstract', 3 | 'Macopedia_Allegro/js/allegro_offer/validation/ean' 4 | ], function (Input) { 5 | return Input.extend({ 6 | initialize: function () { 7 | this._super(); 8 | this.validation = this.validation || {}; 9 | this.validation['allegro-ean'] = true; 10 | this.validation['max_text_length'] = 18; 11 | } 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /view/adminhtml/web/js/allegro_offer/form/field/name-length-counter.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'Magento_Ui/js/form/element/abstract', 3 | 'Macopedia_Allegro/js/allegro_offer/validation/name-length' 4 | ], function (Input) { 5 | return Input.extend({ 6 | allegroNameLength: function (value) { 7 | /** 8 | * https://github.com/allegro/allegro-api/issues/919#issuecomment-458847412 9 | */ 10 | var allegroEscapeList = { 11 | '&': '&', 12 | '"': '"', 13 | '<': '<', 14 | '>': '>' 15 | }; 16 | return value.replace(/./g, function(c) { 17 | return allegroEscapeList.hasOwnProperty(c) ? allegroEscapeList[c] : c 18 | }).length 19 | } 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /view/adminhtml/web/js/allegro_offer/validation/description-subnet.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'Magento_Ui/js/lib/validation/validator', 3 | 'jquery', 4 | 'mage/translate' 5 | ], function (validator, $) { 6 | 7 | validator.addRule( 8 | 'allegro-offer-description-subnet', 9 | function (value) { 10 | let regex = /(\<)([^\<]*?)\>[^\<]*\<\/([^\<]*?)\>/gm; 11 | 12 | while (regex.test(value)) { 13 | value = value.replace(regex, ''); 14 | } 15 | 16 | value = value.replace(/\s*/gm, ''); 17 | 18 | if (value.length > 0) { 19 | return false; 20 | } 21 | 22 | return true; 23 | } 24 | ,$.mage.__("Allegro disallows text without HTML tags.") 25 | ); 26 | 27 | }); 28 | -------------------------------------------------------------------------------- /view/adminhtml/web/js/allegro_offer/validation/description-tags-attributes.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'Magento_Ui/js/lib/validation/validator', 3 | 'jquery', 4 | 'mage/translate' 5 | ], function (validator, $) { 6 | 7 | validator.addRule( 8 | 'allegro-offer-description-tags-attributes', 9 | function (value) { 10 | if (/\<([^\>\s]+?)(\s+[^\>\s]+)+\>/gm.test(value)) { 11 | return false; 12 | } 13 | return true; 14 | } 15 | ,$.mage.__('Allegro disallows HTML tags with attributes like class, name, id etc.') 16 | ); 17 | 18 | }); 19 | -------------------------------------------------------------------------------- /view/adminhtml/web/js/allegro_offer/validation/description-tags.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'Magento_Ui/js/lib/validation/validator', 3 | 'jquery', 4 | 'mage/translate' 5 | ], function (validator, $) { 6 | 7 | validator.addRule( 8 | 'allegro-offer-description-tags', 9 | function (value) { 10 | if (/\<(?!\/?(h1|h2|p|b|ul|ol|li)(\s+.*)?\/?\>).*?\>/gm.test(value)) { 11 | return false; 12 | } 13 | return true; 14 | } 15 | ,$.mage.__("Allegro allows only the use of specific HTML tags: h1, h2, p, b, ul, ol, li.") 16 | ); 17 | 18 | }); 19 | -------------------------------------------------------------------------------- /view/adminhtml/web/js/allegro_offer/validation/ean.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'Magento_Ui/js/lib/validation/validator', 3 | 'jquery', 4 | 'mage/translate' 5 | ], function (validator, $) { 6 | validator.addRule( 7 | 'allegro-ean', 8 | function (value) { 9 | if (value === '') { 10 | return true; 11 | } 12 | if (/[^0-9]/g.test(value)) { 13 | return false; 14 | } 15 | let tab = value.strip(""); 16 | let sum = 0; 17 | for (let i = tab.length - 2; i >= 0; i -= 2) { 18 | sum = sum + parseInt(tab[i], 10) * 3; 19 | if (i >= 1) { 20 | sum = sum + parseInt(tab[i - 1], 10); 21 | } 22 | } 23 | return ((10 - (sum % 10)) % 10 === parseInt(tab[tab.length - 1], 10)); 24 | }, 25 | $.mage.__('This is not a valid EAN number') 26 | ); 27 | }); -------------------------------------------------------------------------------- /view/adminhtml/web/js/allegro_offer/validation/name-length.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'Magento_Ui/js/lib/validation/validator', 3 | 'jquery', 4 | 'mage/translate' 5 | ], function (validator, $) { 6 | validator.addRule( 7 | 'allegro-name-length', 8 | function (value) { 9 | /** 10 | * https://github.com/allegro/allegro-api/issues/919#issuecomment-458847412 11 | */ 12 | var allegroEscapeList = { 13 | '&': '&', 14 | '"': '"', 15 | '<': '<', 16 | '>': '>' 17 | }; 18 | 19 | var valueLength = value.replace(/./g, function(c) { 20 | return allegroEscapeList.hasOwnProperty(c) ? allegroEscapeList[c] : c 21 | }).length; 22 | 23 | if (valueLength > 50) { 24 | return false 25 | } 26 | return true 27 | }, 28 | $.mage.__('Maximum name length cannot exceed 50 characters, but some characters are counted as longer: &, "", <, >') 29 | ); 30 | }); 31 | -------------------------------------------------------------------------------- /view/adminhtml/web/template/allegro_offer/form/field/attributes-table.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |
6 |
7 | 8 |
9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |

Selected category does not contain additional parameters.

17 | 18 | 19 | 20 |
21 |
22 | 26 |
27 |
28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 |
37 | 38 |
39 | 40 | 41 | 42 | 43 |
44 | -------------------------------------------------------------------------------- /view/adminhtml/web/template/allegro_offer/form/field/attributes-table/range.html: -------------------------------------------------------------------------------- 1 |
2 | Min: 3 | 10 | 11 | Max: 12 | 19 | 20 | 21 | 26 | 27 | 28 |
-------------------------------------------------------------------------------- /view/adminhtml/web/template/allegro_offer/form/field/attributes-table/values-ids.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 13 | 14 | 15 | 16 | 26 | 27 | 28 | 29 | 34 | 35 |
-------------------------------------------------------------------------------- /view/adminhtml/web/template/allegro_offer/form/field/attributes-table/values.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 11 | 12 | 20 | 21 | 22 | 23 | 24 | 25 | 33 | 34 | 35 | 36 | 41 | 42 |
-------------------------------------------------------------------------------- /view/adminhtml/web/template/allegro_offer/form/field/category.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |
6 |
7 | 8 |
9 |
10 | 11 | 12 | 13 | 14 | 23 |
24 | 25 | 33 | 43 |
44 | 45 | 46 | 47 | 48 | 49 |
50 | -------------------------------------------------------------------------------- /view/adminhtml/web/template/allegro_offer/form/field/name-length-counter.html: -------------------------------------------------------------------------------- 1 | 7 |
8 | 22 |
23 | 24 |
25 |
26 | --------------------------------------------------------------------------------