Version Notes
Now includes inventory tracking for cancelled and fully or partially credited sales.
Download this release
Release Info
Developer | Boutiika Labs |
Extension | SKUIQ |
Version | 1.2.2 |
Comparing to | |
See all releases |
Version 1.2.2
- app/code/local/Skuiq/.DS_Store +0 -0
- app/code/local/Skuiq/LogProductUpdate/.DS_Store +0 -0
- app/code/local/Skuiq/LogProductUpdate/Model/Observer.php +116 -0
- app/code/local/Skuiq/LogProductUpdate/etc/config.xml +69 -0
- app/code/local/Skuiq/SendSaleInfo/Model/Observer.php +68 -0
- app/code/local/Skuiq/SendSaleInfo/etc/config.xml +49 -0
- app/code/local/Skuiq/SimpleConfigRelation/.DS_Store +0 -0
- app/code/local/Skuiq/SimpleConfigRelation/Helper/Data.php +2 -0
- app/code/local/Skuiq/SimpleConfigRelation/Model/.DS_Store +0 -0
- app/code/local/Skuiq/SimpleConfigRelation/Model/Api.php +113 -0
- app/code/local/Skuiq/SimpleConfigRelation/etc/api.xml +50 -0
- app/code/local/Skuiq/SimpleConfigRelation/etc/config.xml +21 -0
- app/etc/modules/Skuiq_LogProductUpdate.xml +9 -0
- app/etc/modules/Skuiq_SendSaleInfo.xml +9 -0
- app/etc/modules/Skuiq_SimpleConfigRelation.xml +13 -0
- package.xml +18 -0
app/code/local/Skuiq/.DS_Store
ADDED
Binary file
|
app/code/local/Skuiq/LogProductUpdate/.DS_Store
ADDED
Binary file
|
app/code/local/Skuiq/LogProductUpdate/Model/Observer.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Our class name should follow the directory structure of
|
4 |
+
* our Observer.php model, starting from the namespace,
|
5 |
+
* replacing directory separators with underscores.
|
6 |
+
* i.e. app/code/local/Skuiq/LogProductUpdate/Model/Observer.php
|
7 |
+
*/
|
8 |
+
class Skuiq_LogProductUpdate_Model_Observer
|
9 |
+
{
|
10 |
+
public function logUpdate(Varien_Event_Observer $observer)
|
11 |
+
{
|
12 |
+
$product = $observer->getEvent()->getProduct();
|
13 |
+
$name = $product->getName();
|
14 |
+
$sku = $product->getSku();
|
15 |
+
$id = $product->getId();
|
16 |
+
|
17 |
+
$product->getResource()->getTypeId();
|
18 |
+
$prod_type = $product->getTypeId();
|
19 |
+
Mage::log("{$id} {$name} ({$sku}) type={$prod_type} has been updated", null, 'product-updates.txt');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function jsonFile(Varien_Event_Observer $observer)
|
23 |
+
{
|
24 |
+
$apiRunning = Mage::getSingleton('api/server')->getAdapter() != null;
|
25 |
+
Mage::log("API IS RUNNING? (1 if 'YES', '' if NO) '{$apiRunning}'", null, 'product-updates.txt');
|
26 |
+
|
27 |
+
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
28 |
+
$uri = "https://api.skuiq.com/magento/webhooks/products";
|
29 |
+
|
30 |
+
if ($apiRunning != 1) {
|
31 |
+
|
32 |
+
$product = $observer->getEvent()->getProduct();
|
33 |
+
$product->getResource()->getTypeId();
|
34 |
+
$prodType = $product->getTypeId();
|
35 |
+
|
36 |
+
if ($prodType == 'configurable') {
|
37 |
+
Mage::log("Is configurable", null, 'product-updates.txt');
|
38 |
+
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
|
39 |
+
$childArray = array();
|
40 |
+
$i = 0;
|
41 |
+
foreach($childProducts as $child) {
|
42 |
+
Mage::log(($child), null, 'product-updates.txt');
|
43 |
+
$cID = $child->getID();
|
44 |
+
$qty = intval(Mage::getModel('cataloginventory/stock_item')->loadByProduct($cID)->getQty());
|
45 |
+
$childArray[$i]["childID"] = $cID;
|
46 |
+
$childArray[$i]["quantity"] = $qty;
|
47 |
+
Mage::log(" QTY IS {$qty} for Child ID {$cID}", null, 'product-updates.txt');
|
48 |
+
//$childArray = array_merge($childArray, $tmpArray);
|
49 |
+
$i++;
|
50 |
+
}
|
51 |
+
Mage::log((array_values($childArray)), null, 'product-updates.txt');
|
52 |
+
}
|
53 |
+
|
54 |
+
$product["children"] = $childArray;
|
55 |
+
$json = Mage::helper('core')->jsonEncode($product);
|
56 |
+
$client = new Zend_Http_Client($uri);
|
57 |
+
$client->setHeaders('Content-type', 'application/json');
|
58 |
+
$client->setParameterPost('base_url', $base_url);
|
59 |
+
$client->setParameterPost('product', $json);
|
60 |
+
$response = $client->request('POST');
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
// Called if a sale is cancelled
|
65 |
+
public function stockChange(Varien_Event_Observer $observer)
|
66 |
+
{
|
67 |
+
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
68 |
+
$uri = "https://api.skuiq.com/magento/webhooks/cancel_order";
|
69 |
+
|
70 |
+
$event = $observer->getEvent();
|
71 |
+
$_item = $event->getItem();
|
72 |
+
|
73 |
+
if ((int)$_item->getData('qty') != (int)$_item->getOrigData('qty')) {
|
74 |
+
$prod_id = $_item->getPoductId();
|
75 |
+
|
76 |
+
$product["children"] = "";
|
77 |
+
$json = Mage::helper('core')->jsonEncode($_item);
|
78 |
+
$client = new Zend_Http_Client($uri);
|
79 |
+
$client->setHeaders('Content-type', 'application/json');
|
80 |
+
$client->setParameterPost('base_url', $base_url);
|
81 |
+
$client->setParameterPost('product', $json);
|
82 |
+
$client->setParameterPost('reason', 'cancel');
|
83 |
+
$response = $client->request('POST');
|
84 |
+
Mage::log(" Stock Change - Cancel - {$json} ", null, 'product-updates.txt');
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
// Called if a credit memo is created to cancel a sale
|
89 |
+
public function refundOrderInventory(Varien_Event_Observer $observer)
|
90 |
+
{
|
91 |
+
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
92 |
+
$uri = "https://api.skuiq.com/magento/webhooks/cancel_order";
|
93 |
+
|
94 |
+
$creditmemo = $observer->getEvent()->getCreditmemo();
|
95 |
+
$items = array();
|
96 |
+
foreach ($creditmemo->getAllItems() as $item) {
|
97 |
+
$qty = $item->getQty();
|
98 |
+
$product_id = $item->getProductId();
|
99 |
+
$return = $item->getBackToStock();
|
100 |
+
$incrementId = $creditmemo->getIncrementId();
|
101 |
+
|
102 |
+
if ($return == 1) {
|
103 |
+
Mage::log(" Stock Change - Credit Memo - Quantity:{$qty} Product ID:{$product} Return: {$return}", null, 'product-updates.txt');
|
104 |
+
$product["children"] = "";
|
105 |
+
$_item = Mage::getModel('catalog/product')->load($product_id);
|
106 |
+
$json = Mage::helper('core')->jsonEncode($_item);
|
107 |
+
$client = new Zend_Http_Client($uri);
|
108 |
+
$client->setHeaders('Content-type', 'application/json');
|
109 |
+
$client->setParameterPost('base_url', $base_url);
|
110 |
+
$client->setParameterPost('product', $json);
|
111 |
+
$client->setParameterPost('reason', 'credit_memo');
|
112 |
+
$response = $client->request('POST');
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
app/code/local/Skuiq/LogProductUpdate/etc/config.xml
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Skuiq_RestConnect>
|
5 |
+
<version>0.0.1</version>
|
6 |
+
</Skuiq_RestConnect>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<models>
|
11 |
+
<skuiq_logproductupdate>
|
12 |
+
<class>Skuiq_LogProductUpdate_Model</class>
|
13 |
+
</skuiq_logproductupdate>
|
14 |
+
</models>
|
15 |
+
|
16 |
+
<events>
|
17 |
+
<catalog_product_save_commit_after>
|
18 |
+
<observers>
|
19 |
+
<skuiq_logproductupdate>
|
20 |
+
<class>skuiq_logproductupdate/observer</class>
|
21 |
+
<method>logUpdate</method>
|
22 |
+
<type>singleton</type>
|
23 |
+
</skuiq_logproductupdate>
|
24 |
+
|
25 |
+
<skuiq_logproductupdate2>
|
26 |
+
<class>skuiq_logproductupdate/observer</class>
|
27 |
+
<method>jsonFile</method>
|
28 |
+
<type>singleton</type>
|
29 |
+
</skuiq_logproductupdate2>
|
30 |
+
</observers>
|
31 |
+
</catalog_product_save_commit_after>
|
32 |
+
|
33 |
+
// Catches if a sale gets cancelled prior to invoice
|
34 |
+
// Send stock adj. to SKU IQ
|
35 |
+
<!--
|
36 |
+
<sales_order_item_cancel_save_commit_after>
|
37 |
+
<observers>
|
38 |
+
<skuiq_log_quantity_changes>
|
39 |
+
<type>model</type>
|
40 |
+
<class>skuiq_logproductupdate/observer</class>
|
41 |
+
<method>stockChange</method>
|
42 |
+
</skuiq_log_quantity_changes>
|
43 |
+
</observers>
|
44 |
+
</sales_order_item_cancel_save_commit_after>
|
45 |
+
-->
|
46 |
+
|
47 |
+
<cataloginventory_stock_item_save_commit_after>
|
48 |
+
<observers>
|
49 |
+
<skuiq_log_quantity_changes>
|
50 |
+
<type>model</type>
|
51 |
+
<class>skuiq_logproductupdate/observer</class>
|
52 |
+
<method>stockChange</method>
|
53 |
+
</skuiq_log_quantity_changes>
|
54 |
+
</observers>
|
55 |
+
</cataloginventory_stock_item_save_commit_after>
|
56 |
+
|
57 |
+
// Catches if a sale gets cancelled post invoice - i.e. via credit memo
|
58 |
+
// Send stock adj. to SKU IQ
|
59 |
+
<sales_order_creditmemo_save_after>
|
60 |
+
<observers>
|
61 |
+
<genmato_stockupdate>
|
62 |
+
<class>skuiq_logproductupdate/observer</class>
|
63 |
+
<method>refundOrderInventory</method>
|
64 |
+
</genmato_stockupdate>
|
65 |
+
</observers>
|
66 |
+
</sales_order_creditmemo_save_after>
|
67 |
+
</events>
|
68 |
+
</global>
|
69 |
+
</config>
|
app/code/local/Skuiq/SendSaleInfo/Model/Observer.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Skuiq_SendSaleInfo_Model_Observer
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Magento passes a Varien_Event_Observer object as
|
6 |
+
* the first parameter of dispatched events.
|
7 |
+
*/
|
8 |
+
public function sendSale(Varien_Event_Observer $observer)
|
9 |
+
{
|
10 |
+
Mage::log("THIS IS A SALE been updated", null, 'product-updates.txt');
|
11 |
+
$uri = "https://api.skuiq.com/magento/webhooks/sales";
|
12 |
+
$client = new Zend_Http_Client($uri);
|
13 |
+
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
14 |
+
|
15 |
+
$order = $observer->getEvent()->getOrder();
|
16 |
+
$incrementId = $order->getIncrementId();
|
17 |
+
$ordered_items = $order->getAllItems();
|
18 |
+
$shippingAddress = $order->getShippingAddress();
|
19 |
+
//$items = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
20 |
+
|
21 |
+
foreach($ordered_items as $i):
|
22 |
+
//$item_sku = $i->getProductId();
|
23 |
+
//$items = $i;
|
24 |
+
//Mage::log("{$item_sku}. INFO", null, 'orders.txt');
|
25 |
+
$ordered_items = Mage::helper('core')->jsonEncode($i);
|
26 |
+
$item[] = $ordered_items;
|
27 |
+
endforeach;
|
28 |
+
|
29 |
+
$json_order = Mage::helper('core')->jsonEncode($order);
|
30 |
+
$json_order_items = $item; //Mage::helper('core')->jsonEncode($item);
|
31 |
+
$json_ship_add = Mage::helper('core')->jsonEncode($shippingAddress);
|
32 |
+
|
33 |
+
$client->setHeaders('Content-type', 'application/json');
|
34 |
+
$client->setParameterPost('base_url', $base_url);
|
35 |
+
$client->setParameterPost('order', $json_order);
|
36 |
+
$client->setParameterPost('items', $json_order_items);
|
37 |
+
$client->setParameterPost('ship_add', $json_ship_add);
|
38 |
+
$response = $client->request('POST');
|
39 |
+
}
|
40 |
+
|
41 |
+
public function updateSale(Varien_Event_Observer $observer)
|
42 |
+
{
|
43 |
+
$order = $observer->getEvent()->getOrder();
|
44 |
+
$uri = "https://api.skuiq.com/magento/webhooks/sales/update";
|
45 |
+
$client = new Zend_Http_Client($uri);
|
46 |
+
$base_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
47 |
+
|
48 |
+
$last_orderid = $order->getId();
|
49 |
+
$order_status = $order->getStatus();
|
50 |
+
$shipmentCollection = $order->getShipmentsCollection();
|
51 |
+
foreach ($shipmentCollection as $shipment) {
|
52 |
+
foreach($shipment->getAllTracks() as $tracknum)
|
53 |
+
{
|
54 |
+
$tracknums[]=$tracknum->getNumber();
|
55 |
+
}
|
56 |
+
};
|
57 |
+
$shipId = serialize($tracknums);
|
58 |
+
|
59 |
+
$client->setHeaders('Content-type', 'application/json');
|
60 |
+
$client->setParameterPost('order_id', $last_orderid);
|
61 |
+
$client->setParameterPost('status', $order_status);
|
62 |
+
$client->setParameterPost('tracking', $shipId);
|
63 |
+
|
64 |
+
$response = $client->request('POST');
|
65 |
+
|
66 |
+
Mage::log(" UPDATE TO ORDER ID {$last_orderid} - STATUS IS NOW : {$order_status} - Tracking Number : {$shipId} ", null, 'product-updates.txt');
|
67 |
+
}
|
68 |
+
}
|
app/code/local/Skuiq/SendSaleInfo/etc/config.xml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Skuiq_RestConnect>
|
5 |
+
<version>0.0.1</version>
|
6 |
+
</Skuiq_RestConnect>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<models>
|
11 |
+
<skuiq_sendsaleinfo>
|
12 |
+
<class>Skuiq_SendSaleInfo_Model</class>
|
13 |
+
</skuiq_sendsaleinfo>
|
14 |
+
</models>
|
15 |
+
|
16 |
+
<events>
|
17 |
+
<sales_order_place_after>
|
18 |
+
<observers>
|
19 |
+
<skuiq_sendsaleinfo>
|
20 |
+
<class>skuiq_sendsaleinfo/observer</class>
|
21 |
+
<method>sendSale</method>
|
22 |
+
</skuiq_sendsaleinfo>
|
23 |
+
</observers>
|
24 |
+
</sales_order_place_after>
|
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>
|
app/code/local/Skuiq/SimpleConfigRelation/.DS_Store
ADDED
Binary file
|
app/code/local/Skuiq/SimpleConfigRelation/Helper/Data.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Skuiq_Simpleconfigrelation_Helper_Data extends Mage_Core_Helper_Data { }
|
app/code/local/Skuiq/SimpleConfigRelation/Model/.DS_Store
ADDED
Binary file
|
app/code/local/Skuiq/SimpleConfigRelation/Model/Api.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Skuiq_SimpleConfigRelation_Model_Api extends Mage_Catalog_Model_Api_Resource
|
3 |
+
{
|
4 |
+
public function getRelationship($productId, $storeId = null)
|
5 |
+
{
|
6 |
+
$result = array();
|
7 |
+
$this->_configProductId = $productId;
|
8 |
+
$product = $this->_getProduct($productId, $storeId);
|
9 |
+
$this->_getProduct = Mage::getModel('catalog/product');
|
10 |
+
|
11 |
+
// $this->_getProduct->setStoreId($storeId);
|
12 |
+
$this->_getProduct->load($productId);
|
13 |
+
|
14 |
+
if ($this->_getProduct->getId()) {
|
15 |
+
$result['optiondata']=$this->alldropdownData();
|
16 |
+
}
|
17 |
+
|
18 |
+
return $result;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function addRelationship($configurableProduct, $childProduct)
|
22 |
+
{
|
23 |
+
try {
|
24 |
+
$_product = Mage::getModel('catalog/product')->load($configurableProduct);
|
25 |
+
$result = Mage::getResourceSingleton('catalog/product_type_configurable')->saveProducts($_product, $childProduct);
|
26 |
+
return true;
|
27 |
+
} catch (Exception $e) {
|
28 |
+
return __error($e);
|
29 |
+
}
|
30 |
+
//return $result;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getChildsByParentId()
|
34 |
+
{
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getVarienPrice()
|
38 |
+
{
|
39 |
+
}
|
40 |
+
|
41 |
+
public function alldropdownData()
|
42 |
+
{
|
43 |
+
$attributes = array();
|
44 |
+
$options = array();
|
45 |
+
|
46 |
+
$currentProduct = $this->_getProduct;
|
47 |
+
|
48 |
+
$products = array();
|
49 |
+
|
50 |
+
$skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();
|
51 |
+
|
52 |
+
/* getting all simple products */
|
53 |
+
$allProducts = $this->_getProduct->getTypeInstance(true)
|
54 |
+
->getUsedProducts(null, $this->_getProduct);
|
55 |
+
|
56 |
+
foreach ($allProducts as $product) {
|
57 |
+
$products[] = $product;
|
58 |
+
}
|
59 |
+
|
60 |
+
/* getting all configurable attributes of that products */
|
61 |
+
$AllowAttributes=$this->_getProduct->getTypeInstance(true)
|
62 |
+
->getConfigurableAttributes($this->_getProduct);
|
63 |
+
|
64 |
+
$producVarien=array();
|
65 |
+
|
66 |
+
foreach ($products as $product) {
|
67 |
+
$productsData[$product->getId()]=$product->getData();
|
68 |
+
|
69 |
+
foreach ($AllowAttributes as $attribute) {
|
70 |
+
$productAttribute = $attribute->getProductAttribute();
|
71 |
+
$productAttributeId = $productAttribute->getId();
|
72 |
+
$attributeValue = $product->getData($productAttribute->getAttributeCode());
|
73 |
+
|
74 |
+
/* Simple Product data */
|
75 |
+
if (!isset($producVarien[$product->getId()])) {
|
76 |
+
$producVarien[$product->getId()] = array();
|
77 |
+
}
|
78 |
+
|
79 |
+
if (!isset($producVarien[$product->getId()][$productAttributeId])) {
|
80 |
+
$producVarien[$product->getId()][$productAttributeId] = array();
|
81 |
+
}
|
82 |
+
|
83 |
+
/* getting option text value */
|
84 |
+
if ($productAttribute->usesSource()) {
|
85 |
+
$MYabel = $productAttribute->getSource()->getOptionText($attributeValue );
|
86 |
+
}else{
|
87 |
+
$MYabel='';
|
88 |
+
}
|
89 |
+
$info = array(
|
90 |
+
'id' => $productAttribute->getId(),
|
91 |
+
'code' => $productAttribute->getAttributeCode(),
|
92 |
+
'label' => $attribute->getLabel(),
|
93 |
+
'optionslabel' => $MYabel
|
94 |
+
);
|
95 |
+
|
96 |
+
$producVarien[$product->getId()][$productAttributeId] = array('value'=>$attributeValue, 'all'=>$info);
|
97 |
+
|
98 |
+
/* end of simple product data */
|
99 |
+
if (!isset($options[$productAttributeId])) {
|
100 |
+
$options[$productAttributeId] = array();
|
101 |
+
}
|
102 |
+
|
103 |
+
if (!isset($options[$productAttributeId][$attributeValue])) {
|
104 |
+
$options[$productAttributeId][$attributeValue] = array();
|
105 |
+
}
|
106 |
+
|
107 |
+
$options[$productAttributeId][$attributeValue][] = $productId;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
return $producVarien;
|
112 |
+
}
|
113 |
+
}
|
app/code/local/Skuiq/SimpleConfigRelation/etc/api.xml
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api>
|
4 |
+
<resources>
|
5 |
+
<simpleconfigrelation_api translate="title" module="simpleconfigrelation">
|
6 |
+
<title>Myapi</title>
|
7 |
+
<acl>simpleconfigrelation/api</acl>
|
8 |
+
<model>simpleconfigrelation/api</model>
|
9 |
+
<methods>
|
10 |
+
<getrelationship translate="title" module="simpleconfigrelation">
|
11 |
+
<title>Relation Between</title>
|
12 |
+
<acl>simpleconfigrelation/getrelationship</acl>
|
13 |
+
</getrelationship>
|
14 |
+
<addrelationship translate="title" module="simpleconfigrelation">
|
15 |
+
<title>Relation Between</title>
|
16 |
+
<acl>simpleconfigrelation/addrelationship</acl>
|
17 |
+
</addrelationship>
|
18 |
+
<getchildsbyparentid translate="title" module="simpleconfigrelation">
|
19 |
+
<title>Child Product iDs</title>
|
20 |
+
<acl>simpleconfigrelation/getchildsbyparentid</acl>
|
21 |
+
</getchildsbyparentid>
|
22 |
+
<getvarienprice translate="title" module="simpleconfigrelation">
|
23 |
+
<title>Get Extra price on Varien</title>
|
24 |
+
<acl>simpleconfigrelation/getvarienprice</acl>
|
25 |
+
</getvarienprice>
|
26 |
+
</methods>
|
27 |
+
</simpleconfigrelation_api>
|
28 |
+
</resources>
|
29 |
+
<acl>
|
30 |
+
<resources>
|
31 |
+
<simpleconfigrelation translate="title" module="simpleconfigrelation">
|
32 |
+
<title>SimpleConfigRelation</title>
|
33 |
+
<sort_order>2000</sort_order>
|
34 |
+
<getrelationship translate="title" module="simpleconfigrelation">
|
35 |
+
<title>Get Relation Between</title>
|
36 |
+
</getrelationship>
|
37 |
+
<addrelationship translate="title" module="simpleconfigrelation">
|
38 |
+
<title>Create Relation Between</title>
|
39 |
+
</addrelationship>
|
40 |
+
<getchildsbyparentid translate="title" module="simpleconfigrelation">
|
41 |
+
<title>Child Product iDs</title>
|
42 |
+
</getchildsbyparentid>
|
43 |
+
<getvarienprice translate="title" module="simpleconfigrelation">
|
44 |
+
<title>Get Extra price on Varien</title>
|
45 |
+
</getvarienprice>
|
46 |
+
</simpleconfigrelation>
|
47 |
+
</resources>
|
48 |
+
</acl>
|
49 |
+
</api>
|
50 |
+
</config>
|
app/code/local/Skuiq/SimpleConfigRelation/etc/config.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Skuiq_SimpleConfigRelation>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Skuiq_SimpleConfigRelation>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<helpers>
|
10 |
+
<simpleconfigrelation>
|
11 |
+
<class>Skuiq_SimpleConfigRelation_Helper</class>
|
12 |
+
</simpleconfigrelation>
|
13 |
+
</helpers>
|
14 |
+
<models>
|
15 |
+
<simpleconfigrelation>
|
16 |
+
<class>Skuiq_SimpleConfigRelation_Model</class>
|
17 |
+
<resourceModel>simpleconfigrelation_mysql4</resourceModel>
|
18 |
+
</simpleconfigrelation>
|
19 |
+
</models>
|
20 |
+
</global>
|
21 |
+
</config>
|
app/etc/modules/Skuiq_LogProductUpdate.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Skuiq_LogProductUpdate>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Skuiq_LogProductUpdate>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/Skuiq_SendSaleInfo.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Skuiq_SendSaleInfo>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Skuiq_SendSaleInfo>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/Skuiq_SimpleConfigRelation.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Skuiq_SimpleConfigRelation>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Api />
|
9 |
+
</depends>
|
10 |
+
<version>0.1.0</version>
|
11 |
+
</Skuiq_SimpleConfigRelation>
|
12 |
+
</modules>
|
13 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>SKUIQ</name>
|
4 |
+
<version>1.2.2</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>Open</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Allows sync of products and sales from Magento to SKU IQ</summary>
|
10 |
+
<description>Allows sync of products and sales from Magento to SKU IQ</description>
|
11 |
+
<notes>Now includes inventory tracking for cancelled and fully or partially credited sales.</notes>
|
12 |
+
<authors><author><name>Boutiika Labs</name><user>SKUIQ</user><email>dev@skuiq.com</email></author></authors>
|
13 |
+
<date>2015-02-26</date>
|
14 |
+
<time>17:54:57</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Skuiq"><dir name="LogProductUpdate"><dir name="Model"><file name="Observer.php" hash="b21325c560e161e8522c7cdcdd3fb289"/></dir><dir name="etc"><file name="config.xml" hash="362ccb945d56d0e09bc64bdec4d7b2e8"/></dir><file name=".DS_Store" hash="5c077e7e7765c52ee6bd8ea1883d84d5"/></dir><dir name="SendSaleInfo"><dir name="Model"><file name="Observer.php" hash="dbc07f52c96bd3831e875df0135ea60a"/></dir><dir name="etc"><file name="config.xml" hash="9499133489324d19dc03c2a8f7a95e3e"/></dir></dir><dir name="SimpleConfigRelation"><dir name="Helper"><file name="Data.php" hash="3ef946f780001355f51a05c238c14886"/></dir><dir name="Model"><file name="Api.php" hash="e21de6bd6c6198bbe925c76e85e28f8e"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="etc"><file name="api.xml" hash="4cc6bbf973cd7d7af47c6ea14af1e927"/><file name="config.xml" hash="1e37ab2f32d83b47ada846be90083f2a"/></dir><file name=".DS_Store" hash="fdeb1f9e27b18614e82b63502614920a"/></dir><file name=".DS_Store" hash="6bdfc4748c1cd4b9b59adf711021a276"/></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>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.0.0</min><max>5.6.2</max></php></required></dependencies>
|
18 |
+
</package>
|