From ddccef182abd51bc8c26f68a3faf704c2930f0be Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Wed, 4 Jul 2018 11:02:14 -0300 Subject: [PATCH 1/8] #HOTFIX - fix problem Element type when running any command using the magento shell --- etc/di.xml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/etc/di.xml b/etc/di.xml index 76168e1..08d8452 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,20 +1,20 @@ - - - + - + + + + Intelipost\Quote\Model\Resource\Shipment\Grid\Collection + + + + intelipost_shipment intelipost_quote_grid_collection - intelipost_grid_collection + intelipost_grid_collection Intelipost\Quote\Model\Resource\Shipment - + @@ -22,4 +22,4 @@ - \ No newline at end of file + From 26ccaf5803105d9a5935b59f7efb24c1e5497a58 Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Wed, 4 Jul 2018 11:14:11 -0300 Subject: [PATCH 2/8] #HOTFIX - fix problem Element type when running any command using the magento shell --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index abe537e..8fad1ff 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,13 @@ { - "name": "intelipost/magento2-push", - "description": "Intelipost Push", + "name": "luanet/magento2-push", + "description": "Fork Intelipost Push", "type": "magento2-module", "version": "1.0.0", "authors": [ { - "name": "Alex Restani", - "email": "integracoes@intelipost.com.br", - "homepage": "http://www.intelipost.com.br/" + "name": "Lucas Santos", + "email": "lsantos@lua.net", + "homepage": "http://lua.net/" } ], "license": [ @@ -26,4 +26,4 @@ "Intelipost\\Push\\": "" } } -} \ No newline at end of file +} From 39d5a8000b2e39375a4b4fed2efa7034a28d42b8 Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Wed, 4 Jul 2018 11:28:51 -0300 Subject: [PATCH 3/8] #HOTFIX - up version with composer for v1.0.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8fad1ff..bd8eebc 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "luanet/magento2-push", "description": "Fork Intelipost Push", "type": "magento2-module", - "version": "1.0.0", + "version": "1.0.3", "authors": [ { "name": "Lucas Santos", From 86859d27e230a5ee413d8c2da30b5fa46a5c4c13 Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Wed, 4 Jul 2018 12:52:16 -0300 Subject: [PATCH 4/8] #HOTFIX - changing source_model to retrieve customer attributes instead of product --- .gitignore | 2 + Model/Config/Source/Customer/Attributes.php | 60 +++++++++++++++++++++ composer.json | 2 +- etc/adminhtml/system.xml | 2 +- 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Model/Config/Source/Customer/Attributes.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4438f37 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/* +.idea diff --git a/Model/Config/Source/Customer/Attributes.php b/Model/Config/Source/Customer/Attributes.php new file mode 100644 index 0000000..578d22a --- /dev/null +++ b/Model/Config/Source/Customer/Attributes.php @@ -0,0 +1,60 @@ +setAttributeCollectionFactory($attributeCollectionFactory); + } + + /** + * @return array + */ + public function toOptionArray() + { + $attributeCollection = $this->getAttributeCollectionFactory()->create(); + $attributeCollection->setAttributeSetFilter(self::CUSTOMER_ATTRIBUTE_SET); + $attributeCollection->getSelect()->order('frontend_label'); + + $options = []; + foreach ($attributeCollection as $attribute) { + $result [] = ['value' => $attribute->getAttributeCode(), 'label' => $attribute->getFrontendLabel()]; + } + + return $options; + } + + /** + * @return AttributeCollectionFactory + */ + protected function getAttributeCollectionFactory() + { + return $this->attributeCollectionFactory; + } + + /** + * @param AttributeCollectionFactory $attributeCollectionFactory + * @return Attributes + */ + protected function setAttributeCollectionFactory($attributeCollectionFactory) + { + $this->attributeCollectionFactory = $attributeCollectionFactory; + return $this; + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index bd8eebc..866de16 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "luanet/magento2-push", "description": "Fork Intelipost Push", "type": "magento2-module", - "version": "1.0.3", + "version": "1.0.4", "authors": [ { "name": "Lucas Santos", diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 6bf9f5f..3d08e14 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -20,7 +20,7 @@ - Intelipost\Quote\Model\Config\Source\Attribute + Intelipost\Push\Model\Config\Source\Customer\Attributes Select CPF attribute From 9a34a3d91ed261fb9ed5abc9f882fcbd218dc2ac Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Wed, 4 Jul 2018 13:07:27 -0300 Subject: [PATCH 5/8] #HOTFIX - changing source_model to retrieve customer attributes instead of product --- Model/Config/Source/Customer/Attributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Config/Source/Customer/Attributes.php b/Model/Config/Source/Customer/Attributes.php index 578d22a..92e1b6a 100644 --- a/Model/Config/Source/Customer/Attributes.php +++ b/Model/Config/Source/Customer/Attributes.php @@ -34,7 +34,7 @@ public function toOptionArray() $options = []; foreach ($attributeCollection as $attribute) { - $result [] = ['value' => $attribute->getAttributeCode(), 'label' => $attribute->getFrontendLabel()]; + $options[] = ['value' => $attribute->getAttributeCode(), 'label' => $attribute->getFrontendLabel()]; } return $options; From c61cf5b74e6f09005059f12a5db78de8aac2e8aa Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Wed, 4 Jul 2018 13:09:47 -0300 Subject: [PATCH 6/8] #HOTFIX - changing source_model to retrieve customer attributes instead of product --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 866de16..00ecfa1 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "luanet/magento2-push", "description": "Fork Intelipost Push", "type": "magento2-module", - "version": "1.0.4", + "version": "1.0.6", "authors": [ { "name": "Lucas Santos", From bd01db3807338a9d94fee4aca5addf1473756665 Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Fri, 19 Apr 2019 23:21:26 -0300 Subject: [PATCH 7/8] #v1.0.7 --- Model/Request/ShipmentOrder/Invoice.php | 100 ++++++++++++------------ Observer/OrderSaveAfter.php | 10 +-- 2 files changed, 56 insertions(+), 54 deletions(-) diff --git a/Model/Request/ShipmentOrder/Invoice.php b/Model/Request/ShipmentOrder/Invoice.php index 5213fd6..807c64b 100644 --- a/Model/Request/ShipmentOrder/Invoice.php +++ b/Model/Request/ShipmentOrder/Invoice.php @@ -3,62 +3,64 @@ namespace Intelipost\Push\Model\Request\ShipmentOrder; use Magento\Framework\Model\AbstractModel; +use Magento\Sales\Api\OrderRepositoryInterface; class Invoice extends AbstractModel { - private $invoice_number; - private $invoice_series; - private $invoice_key; - private $invoice_date; - private $invoice_total_value; - private $invoice_products_value; - private $invoice_cfop; + private $invoice_number; + private $invoice_series; + private $invoice_key; + private $invoice_date; + private $invoice_total_value; + private $invoice_products_value; + private $invoice_cfop; - protected $_collectionFactory; - protected $_helper; + protected $_collectionFactory; + protected $_helper; - public function __construct( - \Intelipost\Push\Model\Resource\Invoice\CollectionFactory $collectionFactory - ) - { - $this->_collectionFactory = $collectionFactory; - } + /** @var OrderRepositoryInterface $orderRepository */ + protected $orderRepository; - public function getInformation($order_number) - { - $invoiceCollection = $this->getInvoiceCollection($order_number); - foreach($invoiceCollection as $invoice) - { - $this->invoice_number = $invoice['invoice_number']; - $this->invoice_series = $invoice['invoice_series']; - $this->invoice_key = $invoice['invoice_key']; - $this->invoice_date = str_replace(' ', 'T', $invoice['invoice_date']); - $this->invoice_total_value = $invoice['invoice_total_value']; - $this->invoice_products_value = $invoice['invoice_products_value']; - $this->invoice_cfop = $invoice['invoice_cfop']; - } - $shipment_order_volume_invoice_obj = $this->preapreInvoiceObj(); - return $shipment_order_volume_invoice_obj; - } + /** + * Invoice constructor. + * @param \Intelipost\Push\Model\Resource\Invoice\CollectionFactory $collectionFactory + * @param OrderRepositoryInterface $orderRepository + */ + public function __construct( + \Intelipost\Push\Model\Resource\Invoice\CollectionFactory $collectionFactory, + OrderRepositoryInterface $orderRepository + ) + { + $this->_collectionFactory = $collectionFactory; + $this->orderRepository = $orderRepository; + } - public function getInvoiceCollection($order_number) - { - $iCollection = $this->_collectionFactory->create(); - $iCollection->addFieldToFilter('order_number', array('eq' => $order_number)); - return $iCollection->getData(); - } + public function getInformation($orderId) + { + $order = $this->orderRepository->get((int) $orderId); - public function preapreInvoiceObj() - { - $shipment_order_volume_invoice = new \Stdclass(); - $shipment_order_volume_invoice->invoice_number = $this->invoice_number; - $shipment_order_volume_invoice->invoice_series = $this->invoice_series; - $shipment_order_volume_invoice->invoice_key = $this->invoice_key; - $shipment_order_volume_invoice->invoice_date = $this->invoice_date; - $shipment_order_volume_invoice->invoice_total_value = $this->invoice_total_value; - $shipment_order_volume_invoice->invoice_products_value = $this->invoice_products_value; - $shipment_order_volume_invoice->invoice_cfop = $this->invoice_cfop; + $this->invoice_number = $order->getEntityId(); + $this->invoice_series = $order->getIncrementId(); + $this->invoice_key = '01234567890123456789012345678901234567891234'; + $this->invoice_date = str_replace(' ', 'T', $order->getCreatedAt()); + $this->invoice_total_value = number_format($order->getGrandTotal(), '2', '.', ''); + $this->invoice_products_value = number_format($order->getSubtotalInclTax(), '2', '.', ''); + $this->invoice_cfop = "1612"; - return $shipment_order_volume_invoice; - } + $shipment_order_volume_invoice_obj = $this->preapreInvoiceObj(); + return $shipment_order_volume_invoice_obj; + } + + public function preapreInvoiceObj() + { + $shipment_order_volume_invoice = new \Stdclass(); + $shipment_order_volume_invoice->invoice_number = $this->invoice_number; + $shipment_order_volume_invoice->invoice_series = $this->invoice_series; + $shipment_order_volume_invoice->invoice_date = $this->invoice_date; + $shipment_order_volume_invoice->invoice_total_value = $this->invoice_total_value; + $shipment_order_volume_invoice->invoice_products_value = $this->invoice_products_value; + $shipment_order_volume_invoice->invoice_cfop = $this->invoice_cfop; + + return $shipment_order_volume_invoice; + } } \ No newline at end of file diff --git a/Observer/OrderSaveAfter.php b/Observer/OrderSaveAfter.php index 791daad..311e0f1 100644 --- a/Observer/OrderSaveAfter.php +++ b/Observer/OrderSaveAfter.php @@ -45,7 +45,7 @@ public function execute(Observer $observer) $order = $observer->getOrder(); $magentoStatus = $order->getStatus(); $entity_id = $order->getEntityId(); - + $statusToCreate = $this->_scopeConfig->getValue('intelipost_push/order_status/status_to_create'); $magentoStatusAfterCreate = $this->_scopeConfig->getValue('intelipost_push/order_status/magento_status_after_create'); $createAndShip = $this->_scopeConfig->getValue('intelipost_push/order_status/create_and_ship'); @@ -57,18 +57,18 @@ public function execute(Observer $observer) //Apenas uma entrega if(sizeof($shipmentObj) == 1) - { + { foreach($colData as $shipment) { //criação do pedido if($magentoStatus == $statusToCreate && $shipment['intelipost_status'] == 'pending') { $col = $this->_shipmentOrder->create(); - $col->shipmentOrder($shipment); + $col->shipmentOrder($shipment); } //despacho do pedido - if(!$createAndShip && $magentoStatus == $statusToShip && $shipment['intelipost_status'] == 'created') + if(!$createAndShip && $magentoStatus == $statusToShip) { $col = $this->_shipped->create(); $col->shippedRequestBody($shipment); @@ -84,7 +84,7 @@ public function execute(Observer $observer) $this->_helper->logIntelipost(json_encode('duas entregas')); //criação do pedidos foreach($colData as $shipment) - { + { //fazer o match dos skus e criar as entregas relativas na Intelipost } From 882fb94bc878b518441b41669ddf0ed01d1264cf Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Mon, 27 May 2019 18:04:19 -0300 Subject: [PATCH 8/8] #HOTFIX envio de pedido para intelipost --- Model/Request/ShipmentOrder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Request/ShipmentOrder.php b/Model/Request/ShipmentOrder.php index c42c57a..b9c7b52 100644 --- a/Model/Request/ShipmentOrder.php +++ b/Model/Request/ShipmentOrder.php @@ -82,7 +82,7 @@ public function shipmentOrder($collectionData) $this->scheduling_window_end = $collectionData['scheduling_window_end']; $this->shipment_order_type = $collectionData['shipment_order_type']; $this->shipment_order_sub_type = $collectionData['shipment_order_sub_type']; - $this->shipment_order_volume_invoice = $invoiceObj->getInformation($collectionData['order_number']); + $this->shipment_order_volume_invoice = $invoiceObj->getInformation($collectionData['entity_id']); $this->shipment_order_volume_array = $volObj->getInformation($collectionData['volumes'], $this->shipment_order_volume_invoice); $this->end_customer = $ecObj->getInformation($collectionData['entity_id'], $collectionData['customer_taxvat']); if($this->_scopeConfig->getValue('intelipost_push/order_status/create_and_ship')){ @@ -209,4 +209,4 @@ public function getNowDateTime() $now = str_replace(' ', 'T', $localizedDateTimeISO); return $now; } -} \ No newline at end of file +}