diff --git a/Api/CategoryManagementInterface.php b/Api/CategoryManagementInterface.php new file mode 100644 index 0000000..97b1630 --- /dev/null +++ b/Api/CategoryManagementInterface.php @@ -0,0 +1,24 @@ +create('Magento\Catalog\Model\Category')->load($categoryId); + + if (!$category->getId()) + throw new Exception("Category does not exist"); + + $category->setPosition($new); + + $objectManager->get('\Magento\Catalog\Api\CategoryRepositoryInterface')->save($category); + + return true; + } + +} \ No newline at end of file diff --git a/Model/Magento.php b/Model/Magento.php new file mode 100644 index 0000000..1ae14d5 --- /dev/null +++ b/Model/Magento.php @@ -0,0 +1,24 @@ +productMetadata = $productMetadata; + } + + /** + * Get current Magento version + * + * @api + * @return string + */ + public function getMagentoVersion(){ + return $this->productMetadata->getVersion(); + } +} \ No newline at end of file diff --git a/Model/PaymentMethod.php b/Model/PaymentMethod.php new file mode 100644 index 0000000..da124d5 --- /dev/null +++ b/Model/PaymentMethod.php @@ -0,0 +1,43 @@ +paymentConfig= $paymentConfig; + $this->scopeConfig = $scopeConfig; + } + + /** + * Get active payment methods + * + * @api + * @return object + */ + public function getActiveMethods(){ + + $activeMethods = $this->paymentConfig->getActiveMethods(); + $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE; + $methods = array(); + + foreach($activeMethods as $paymentCode => $paymentModel) + { + $paymentTitle = $this->scopeConfig->getValue('payment/'.$paymentCode.'/title'); + $methods[$paymentCode] = array( + 'label' => $paymentTitle, + 'value' => $paymentCode + ); + } + + return $methods; + } +} \ No newline at end of file diff --git a/Model/Sales.php b/Model/Sales.php new file mode 100644 index 0000000..2abcc85 --- /dev/null +++ b/Model/Sales.php @@ -0,0 +1,49 @@ +statusFactory = $statusFactory; + $this->statusResourceFactory = $statusResourceFactory; + } + + /** + * Post a new order status to make sure Magento knows the status NAV/BC is using + * + * @api + * @param string $statusCode + * @param string $statusLabel + * @return boolean + */ + public function createOrderStatus($statusCode, $statusLabel) + { + $statusResource = $this->statusResourceFactory->create(); + $status = $this->statusFactory->create(); + $status->setData([ + 'status' => $statusCode, + 'label' => $statusLabel, + ]); + + try { + $statusResource->save($status); + } catch (AlreadyExistsException $exception) { + return; + } + + $status->assignState(Order::STATE_PROCESSING, false, true); + + return true; + } +} diff --git a/Model/ShippingMethod.php b/Model/ShippingMethod.php new file mode 100644 index 0000000..e20e9bf --- /dev/null +++ b/Model/ShippingMethod.php @@ -0,0 +1,50 @@ +shipmentConfig = $shipmentConfig; + $this->scopeConfig = $scopeConfig; + } + + /** + * Get active carriers / shipping methods + * + * @api + * @return object + */ + public function getActiveMethods(){ + + $activeCarriers = $this->shipmentConfig->getActiveCarriers(); + $methods = array(); + + foreach($activeCarriers as $carrierCode => $carrierModel) + { + $carrierTitle =$this->scopeConfig->getValue('carriers/'.$carrierCode.'/title'); + + if( $carrierMethods = $carrierModel->getAllowedMethods() ) + { + foreach ($carrierMethods as $methodCode => $method) + { + $code= $carrierCode.'_'.$methodCode; + $methods[]=array( + 'label'=>$carrierTitle, + 'value'=>$code + ); + } + } + } + + return $methods; + } +} \ No newline at end of file diff --git a/Plugin/ProductAttributeExtensionAttributes.php b/Plugin/ProductAttributeExtensionAttributes.php new file mode 100644 index 0000000..bf6e194 --- /dev/null +++ b/Plugin/ProductAttributeExtensionAttributes.php @@ -0,0 +1,25 @@ +getExtensionAttributes(); + if($attribute->getAttributeGroupId()){ + $extensionAttributes->setAttributeGroupId($attribute->getAttributeGroupId()); + $extensionAttributes->setEntityAttributeId($attribute->getEntityAttributeId()); + $extensionAttributes->setSortOrder($attribute->getSortOrder()); + } + $attribute->setExtensionAttributes($extensionAttributes); + } + return $searchResult; + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..92f89bb --- /dev/null +++ b/composer.json @@ -0,0 +1,21 @@ +{ + "name": "commerce365/module-apiextensions", + "version": "1.0.0", + "description": "N/A", + "type": "magento2-module", + "require": { + "magento/framework": "*", + "magento/module-sales": "*" + }, + "license": [ + "" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Commerce365\\MagentoApiExtensions\\\\": "" + } + } +} diff --git a/etc/di.xml b/etc/di.xml new file mode 100644 index 0000000..063cc3e --- /dev/null +++ b/etc/di.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/etc/extension_attributes.xml b/etc/extension_attributes.xml new file mode 100644 index 0000000..c200b73 --- /dev/null +++ b/etc/extension_attributes.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml new file mode 100644 index 0000000..81ebccf --- /dev/null +++ b/etc/module.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/etc/webapi.xml b/etc/webapi.xml new file mode 100644 index 0000000..84d7082 --- /dev/null +++ b/etc/webapi.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/etc/webapi_rest/di.xml b/etc/webapi_rest/di.xml new file mode 100644 index 0000000..1fcdb7f --- /dev/null +++ b/etc/webapi_rest/di.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/registration.php b/registration.php new file mode 100644 index 0000000..6b5cf78 --- /dev/null +++ b/registration.php @@ -0,0 +1,6 @@ +