Version Notes
Bug fixes
Download this release
Release Info
Developer | Boutiika Labs |
Extension | SKUIQ |
Version | 1.2.5 |
Comparing to | |
See all releases |
Code changes from version 1.2.4 to 1.2.5
- app/code/local/Skuiq/.DS_Store +0 -0
- app/code/local/Skuiq/LogProductUpdate/Model/Observer.php +51 -35
- app/code/local/Skuiq/LogProductUpdate/etc/config.xml +2 -2
- app/code/local/Skuiq/SendSaleInfo/Model/Observer.php +47 -70
- app/code/local/Skuiq/SendSaleInfo/etc/config.xml +4 -26
- app/code/local/Skuiq/SimpleConfigRelation/Model/Api.php +15 -10
- package.xml +11 -10
app/code/local/Skuiq/.DS_Store
DELETED
Binary file
|
app/code/local/Skuiq/LogProductUpdate/Model/Observer.php
CHANGED
@@ -3,6 +3,7 @@ class Skuiq_LogProductUpdate_Model_Observer
|
|
3 |
{
|
4 |
public function logUpdate(Varien_Event_Observer $observer)
|
5 |
{
|
|
|
6 |
$product = $observer->getEvent()->getProduct();
|
7 |
$name = $product->getName();
|
8 |
$sku = $product->getSku();
|
@@ -11,12 +12,16 @@ class Skuiq_LogProductUpdate_Model_Observer
|
|
11 |
$product->getResource()->getTypeId();
|
12 |
$prod_type = $product->getTypeId();
|
13 |
Mage::log("{$id} {$name} ({$sku}) type={$prod_type} has been updated", null, 'product-updates.txt');
|
|
|
|
|
|
|
14 |
}
|
15 |
|
16 |
public function jsonFile(Varien_Event_Observer $observer)
|
17 |
{
|
|
|
18 |
$apiRunning = Mage::getSingleton('api/server')->getAdapter() != null;
|
19 |
-
Mage::log("API IS RUNNING? (1 if 'YES', '' if NO) '{$apiRunning}'", null, 'product-updates.txt');
|
20 |
|
21 |
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
22 |
$uri = "https://api.skuiq.com/magento/webhooks/products";
|
@@ -52,12 +57,17 @@ class Skuiq_LogProductUpdate_Model_Observer
|
|
52 |
$client->setParameterPost('product', $json);
|
53 |
$response = $client->request('POST');
|
54 |
}
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
public function stockChange(Varien_Event_Observer $observer)
|
58 |
{
|
|
|
59 |
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
60 |
$uri = "https://api.skuiq.com/magento/webhooks/cancel_order";
|
|
|
61 |
|
62 |
$event = $observer->getEvent();
|
63 |
$_item = $event->getItem();
|
@@ -75,45 +85,51 @@ class Skuiq_LogProductUpdate_Model_Observer
|
|
75 |
$response = $client->request('POST');
|
76 |
Mage::log(" Stock Change - Cancel - {$json} ", null, 'product-updates.txt');
|
77 |
}
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
public function refundOrderInventory(Varien_Event_Observer $observer)
|
81 |
{
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
116 |
}
|
|
|
|
|
117 |
}
|
118 |
}
|
119 |
}
|
3 |
{
|
4 |
public function logUpdate(Varien_Event_Observer $observer)
|
5 |
{
|
6 |
+
try {
|
7 |
$product = $observer->getEvent()->getProduct();
|
8 |
$name = $product->getName();
|
9 |
$sku = $product->getSku();
|
12 |
$product->getResource()->getTypeId();
|
13 |
$prod_type = $product->getTypeId();
|
14 |
Mage::log("{$id} {$name} ({$sku}) type={$prod_type} has been updated", null, 'product-updates.txt');
|
15 |
+
} catch (Exception $e) {
|
16 |
+
Mage::log("Error in logUpdate", null, 'product-updates.txt');
|
17 |
+
}
|
18 |
}
|
19 |
|
20 |
public function jsonFile(Varien_Event_Observer $observer)
|
21 |
{
|
22 |
+
try {
|
23 |
$apiRunning = Mage::getSingleton('api/server')->getAdapter() != null;
|
24 |
+
Mage::log("SKU IQ: API IS RUNNING? (1 if 'YES', '' if NO) '{$apiRunning}'", null, 'product-updates.txt');
|
25 |
|
26 |
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
27 |
$uri = "https://api.skuiq.com/magento/webhooks/products";
|
57 |
$client->setParameterPost('product', $json);
|
58 |
$response = $client->request('POST');
|
59 |
}
|
60 |
+
} catch (Exception $e) {
|
61 |
+
Mage::log("Error in jsonFile", null, 'product-updates.txt');
|
62 |
+
}
|
63 |
}
|
64 |
|
65 |
public function stockChange(Varien_Event_Observer $observer)
|
66 |
{
|
67 |
+
try {
|
68 |
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
69 |
$uri = "https://api.skuiq.com/magento/webhooks/cancel_order";
|
70 |
+
Mage::log("SKU IQ: stockChange", null, 'product-updates.txt');
|
71 |
|
72 |
$event = $observer->getEvent();
|
73 |
$_item = $event->getItem();
|
85 |
$response = $client->request('POST');
|
86 |
Mage::log(" Stock Change - Cancel - {$json} ", null, 'product-updates.txt');
|
87 |
}
|
88 |
+
} catch (Exception $e) {
|
89 |
+
Mage::log("Error in stockChange", null, 'product-updates.txt');
|
90 |
+
}
|
91 |
}
|
92 |
|
93 |
public function refundOrderInventory(Varien_Event_Observer $observer)
|
94 |
{
|
95 |
+
try {
|
96 |
+
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
97 |
+
$uri = "https://api.skuiq.com/magento/webhooks/cancel_order";
|
98 |
+
|
99 |
+
$creditmemo = $observer->getEvent()->getCreditmemo();
|
100 |
+
|
101 |
+
$cr_uri = "https://api.skuiq.com/magento/webhooks/credit_memo";
|
102 |
+
$cr_memo_id = $creditmemo->getIncrementId();
|
103 |
+
Mage::log(" Credit Memo ID:{$cr_memo_id}", null, 'product-updates.txt');
|
104 |
+
|
105 |
+
$cr_client = new Zend_Http_Client($uri);
|
106 |
+
$cr_client->setHeaders('Content-type', 'application/json');
|
107 |
+
$cr_client->setParameterPost('base_url', $base_url);
|
108 |
+
$cr_client->setParameterPost('credit_memo_id', $cr_memo_id);
|
109 |
+
$response = $cr_client->request('POST');
|
110 |
+
|
111 |
+
$items = array();
|
112 |
+
foreach ($creditmemo->getAllItems() as $item) {
|
113 |
+
$qty = $item->getQty();
|
114 |
+
$product_id = $item->getProductId();
|
115 |
+
$return = $item->getBackToStock();
|
116 |
+
$incrementId = $creditmemo->getIncrementId();
|
117 |
+
|
118 |
+
if ($return == 1) {
|
119 |
+
Mage::log(" Stock Change - Credit Memo - Quantity:{$qty} Product ID:{$product} Return: {$return}", null, 'product-updates.txt');
|
120 |
+
$product["children"] = "";
|
121 |
+
$_item = Mage::getModel('catalog/product')->load($product_id);
|
122 |
+
$json = Mage::helper('core')->jsonEncode($_item);
|
123 |
+
$client = new Zend_Http_Client($uri);
|
124 |
+
$client->setHeaders('Content-type', 'application/json');
|
125 |
+
$client->setParameterPost('base_url', $base_url);
|
126 |
+
$client->setParameterPost('product', $json);
|
127 |
+
$client->setParameterPost('reason', 'credit_memo');
|
128 |
+
$response = $client->request('POST');
|
129 |
+
}
|
130 |
}
|
131 |
+
} catch (Exception $e) {
|
132 |
+
Mage::log("Error in refundOrderInventory", null, 'product-updates.txt');
|
133 |
}
|
134 |
}
|
135 |
}
|
app/code/local/Skuiq/LogProductUpdate/etc/config.xml
CHANGED
@@ -58,10 +58,10 @@
|
|
58 |
// Send stock adj. to SKU IQ
|
59 |
<sales_order_creditmemo_save_after>
|
60 |
<observers>
|
61 |
-
<
|
62 |
<class>skuiq_logproductupdate/observer</class>
|
63 |
<method>refundOrderInventory</method>
|
64 |
-
</
|
65 |
</observers>
|
66 |
</sales_order_creditmemo_save_after>
|
67 |
</events>
|
58 |
// Send stock adj. to SKU IQ
|
59 |
<sales_order_creditmemo_save_after>
|
60 |
<observers>
|
61 |
+
<skuiq_stockupdate>
|
62 |
<class>skuiq_logproductupdate/observer</class>
|
63 |
<method>refundOrderInventory</method>
|
64 |
+
</skuiq_stockupdate>
|
65 |
</observers>
|
66 |
</sales_order_creditmemo_save_after>
|
67 |
</events>
|
app/code/local/Skuiq/SendSaleInfo/Model/Observer.php
CHANGED
@@ -3,75 +3,52 @@ class Skuiq_SendSaleInfo_Model_Observer
|
|
3 |
{
|
4 |
public function sendSale(Varien_Event_Observer $observer)
|
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 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
$ordered_items = Mage::helper('core')->jsonEncode($i);
|
54 |
-
$item[] = $ordered_items;
|
55 |
-
endforeach;
|
56 |
-
$shippingAddress = $order->getShippingAddress();
|
57 |
-
|
58 |
-
|
59 |
-
$json_order = Mage::helper('core')->jsonEncode($order);
|
60 |
-
$json_order_items = $item;
|
61 |
-
$json_ship_add = Mage::helper('core')->jsonEncode($shippingAddress);
|
62 |
-
|
63 |
-
$client->setHeaders('Content-type', 'application/json');
|
64 |
-
$client->setParameterPost('base_url', $base_url);
|
65 |
-
$client->setParameterPost('order', $json_order);
|
66 |
-
$client->setParameterPost('items', $json_order_items);
|
67 |
-
$client->setParameterPost('ship_add', $json_ship_add);
|
68 |
-
|
69 |
-
$client->setParameterPost('order_id', $last_orderid);
|
70 |
-
$client->setParameterPost('status', $order_status);
|
71 |
-
$client->setParameterPost('tracking', $shipId);
|
72 |
-
|
73 |
-
$response = $client->request('POST');
|
74 |
-
|
75 |
-
Mage::log(" UPDATE TO ORDER ID {$last_orderid} - STATUS IS NOW : {$order_status} - Tracking Number : {$shipId} ", null, 'product-updates.txt');
|
76 |
}
|
77 |
}
|
3 |
{
|
4 |
public function sendSale(Varien_Event_Observer $observer)
|
5 |
{
|
6 |
+
try {
|
7 |
+
Mage::log("SKU IQ: A sale has been saved or updated", null, 'sale-updates.txt');
|
8 |
+
$order = $observer->getEvent()->getOrder();
|
9 |
+
$uri = "https://api.skuiq.com/magento/webhooks/sales";
|
10 |
+
$client = new Zend_Http_Client($uri);
|
11 |
+
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
12 |
+
|
13 |
+
$ordered_items = $order->getAllItems();
|
14 |
+
foreach($ordered_items as $i):
|
15 |
+
$ordered_items = Mage::helper('core')->jsonEncode($i);
|
16 |
+
$item[] = $ordered_items;
|
17 |
+
endforeach;
|
18 |
+
$shippingAddress = $order->getShippingAddress();
|
19 |
+
|
20 |
+
$json_order = Mage::helper('core')->jsonEncode($order);
|
21 |
+
$json_order_items = $item;
|
22 |
+
$json_ship_add = Mage::helper('core')->jsonEncode($shippingAddress);
|
23 |
+
|
24 |
+
$client->setHeaders('Content-type', 'application/json');
|
25 |
+
$client->setParameterPost('base_url', $base_url);
|
26 |
+
$client->setParameterPost('order', $json_order);
|
27 |
+
$client->setParameterPost('items', $json_order_items);
|
28 |
+
$client->setParameterPost('ship_add', $json_ship_add);
|
29 |
+
|
30 |
+
/*
|
31 |
+
$last_orderid = $order->getId();
|
32 |
+
$order_status = $order->getStatus();
|
33 |
+
$shipmentCollection = $order->getShipmentsCollection();
|
34 |
+
foreach ($shipmentCollection as $shipment) {
|
35 |
+
foreach($shipment->getAllTracks() as $tracknum)
|
36 |
+
{
|
37 |
+
$tracknums[]=$tracknum->getNumber();
|
38 |
+
}
|
39 |
+
};
|
40 |
+
$shipId = serialize($tracknums);
|
41 |
+
|
42 |
+
$client->setParameterPost('order_id', $last_orderid);
|
43 |
+
$client->setParameterPost('status', $order_status);
|
44 |
+
$client->setParameterPost('tracking', $shipId);
|
45 |
+
*/
|
46 |
+
|
47 |
+
$response = $client->request('POST');
|
48 |
+
} catch (Mage_Core_Exception $e) {
|
49 |
+
Mage::log("SKU IQ: Magento core error in sendSale", null, 'sale-updates.txt');
|
50 |
+
} catch (Exception $e) {
|
51 |
+
Mage::log("SKU IQ: Error in sendSale", null, 'sale-updates.txt');
|
52 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
}
|
app/code/local/Skuiq/SendSaleInfo/etc/config.xml
CHANGED
@@ -14,36 +14,14 @@
|
|
14 |
</models>
|
15 |
|
16 |
<events>
|
17 |
-
<
|
18 |
<observers>
|
19 |
<skuiq_sendsaleinfo>
|
20 |
-
|
21 |
-
|
22 |
</skuiq_sendsaleinfo>
|
23 |
</observers>
|
24 |
-
</
|
25 |
-
|
26 |
-
<sales_order_save_after>
|
27 |
-
<observers>
|
28 |
-
<skuiq_sendsaleinfo2>
|
29 |
-
<class>skuiq_sendsaleinfo/observer</class>
|
30 |
-
<method>updateSale</method>
|
31 |
-
</skuiq_sendsaleinfo2>
|
32 |
-
</observers>
|
33 |
-
</sales_order_save_after>
|
34 |
</events>
|
35 |
</global>
|
36 |
-
|
37 |
-
<frontend>
|
38 |
-
<events>
|
39 |
-
<sales_order_save_after>
|
40 |
-
<observers>
|
41 |
-
<skuiq_sendsaleinfo3>
|
42 |
-
<class>skuiq_sendsaleinfo/observer</class>
|
43 |
-
<method>sendSale</method>
|
44 |
-
</skuiq_sendsaleinfo3>
|
45 |
-
</observers>
|
46 |
-
</sales_order_save_after>
|
47 |
-
</events>
|
48 |
-
</frontend>
|
49 |
</config>
|
14 |
</models>
|
15 |
|
16 |
<events>
|
17 |
+
<sales_order_save_commit_after>
|
18 |
<observers>
|
19 |
<skuiq_sendsaleinfo>
|
20 |
+
<class>skuiq_sendsaleinfo/observer</class>
|
21 |
+
<method>sendSale</method>
|
22 |
</skuiq_sendsaleinfo>
|
23 |
</observers>
|
24 |
+
</sales_order_save_commit_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
</events>
|
26 |
</global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
</config>
|
app/code/local/Skuiq/SimpleConfigRelation/Model/Api.php
CHANGED
@@ -3,19 +3,23 @@ class Skuiq_SimpleConfigRelation_Model_Api extends Mage_Catalog_Model_Api_Resour
|
|
3 |
{
|
4 |
public function getRelationship($productId, $storeId = null)
|
5 |
{
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
|
|
|
|
|
|
19 |
}
|
20 |
|
21 |
public function addRelationship($configurableProduct, $childProduct)
|
@@ -29,6 +33,7 @@ class Skuiq_SimpleConfigRelation_Model_Api extends Mage_Catalog_Model_Api_Resour
|
|
29 |
$result = Mage::getResourceSingleton('catalog/product_type_configurable')->saveProducts($_product, $new_children);
|
30 |
return true;
|
31 |
} catch (Exception $e) {
|
|
|
32 |
return false;
|
33 |
}
|
34 |
}
|
3 |
{
|
4 |
public function getRelationship($productId, $storeId = null)
|
5 |
{
|
6 |
+
try {
|
7 |
+
$result = array();
|
8 |
+
$this->_configProductId = $productId;
|
9 |
+
$product = $this->_getProduct($productId, $storeId);
|
10 |
+
$this->_getProduct = Mage::getModel('catalog/product');
|
11 |
|
12 |
+
// $this->_getProduct->setStoreId($storeId);
|
13 |
+
$this->_getProduct->load($productId);
|
14 |
|
15 |
+
if ($this->_getProduct->getId()) {
|
16 |
+
$result['optiondata']=$this->alldropdownData();
|
17 |
+
}
|
18 |
|
19 |
+
return $result;
|
20 |
+
} catch (Exception $e) {
|
21 |
+
Mage::log("Error in getRelationship", null, 'config-relations.txt');
|
22 |
+
}
|
23 |
}
|
24 |
|
25 |
public function addRelationship($configurableProduct, $childProduct)
|
33 |
$result = Mage::getResourceSingleton('catalog/product_type_configurable')->saveProducts($_product, $new_children);
|
34 |
return true;
|
35 |
} catch (Exception $e) {
|
36 |
+
Mage::log("Error in addRelationship", null, 'config-relations.txt');
|
37 |
return false;
|
38 |
}
|
39 |
}
|
package.xml
CHANGED
@@ -1,19 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>SKUIQ</name>
|
4 |
-
<version>1.2.
|
5 |
<stability>stable</stability>
|
6 |
<license>Open</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
|
12 |
-
|
13 |
-
<
|
14 |
-
<
|
15 |
-
<
|
16 |
-
<
|
|
|
17 |
<compatible/>
|
18 |
-
<dependencies><required><php><min>5.0.0</min><max>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>SKUIQ</name>
|
4 |
+
<version>1.2.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>Open</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Sync products and sales from Magento to your in-store POS.</summary>
|
10 |
+
<description>Sync products and sales from Magento to your in-store POS.
|
11 |
+

|
12 |
+
For more details, please visit http://www.skuiq.com.</description>
|
13 |
+
<notes>Bug fixes</notes>
|
14 |
+
<authors><author><name>Boutiika Labs</name><user>skuiq</user><email>dev@skuiq.com</email></author></authors>
|
15 |
+
<date>2015-10-02</date>
|
16 |
+
<time>18:47:49</time>
|
17 |
+
<contents><target name="magelocal"><dir name="Skuiq"><dir name="LogProductUpdate"><dir name="Model"><file name="Observer.php" hash="d3b2f2c8a36c7c3e7ac4d35dbcedf09b"/></dir><dir name="etc"><file name="config.xml" hash="3d9854ee30632315ac81e8aa8ad4e21d"/></dir><file name=".DS_Store" hash="5c077e7e7765c52ee6bd8ea1883d84d5"/></dir><dir name="SendSaleInfo"><dir name="Model"><file name="Observer.php" hash="a53a3e71500fafa6ca031c21edd4246e"/></dir><dir name="etc"><file name="config.xml" hash="5dc7eb82b2a4b3a427d70e4e1fd25b8a"/></dir></dir><dir name="SimpleConfigRelation"><dir name="Helper"><file name="Data.php" hash="3ef946f780001355f51a05c238c14886"/></dir><dir name="Model"><file name="Api.php" hash="8a11f2f88423736f47dd7a75c815303d"/></dir><dir name="etc"><file name="api.xml" hash="4cc6bbf973cd7d7af47c6ea14af1e927"/><file name="config.xml" hash="1e37ab2f32d83b47ada846be90083f2a"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Skuiq_LogProductUpdate.xml" hash="6dbf41f8fd94ccccdd630f978a85b9ac"/><file name="Skuiq_SendSaleInfo.xml" hash="111d7a25f091d22b0ee6da65c3a8c58b"/><file name="Skuiq_SimpleConfigRelation.xml" hash="1a7141d7f82993c75e5e40e7a7df4ded"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|