shoppingfeeder - Version 1.5.2

Version Notes

Bug fix for sale price effective date

Download this release

Release Info

Developer ShoppingFeeder
Extension shoppingfeeder
Version 1.5.2
Comparing to
See all releases


Code changes from version 1.5.1 to 1.5.2

app/code/community/ShoppingFeeder/Fbtrack/Model/Observer.php CHANGED
@@ -1,183 +1,183 @@
1
- <?php
2
- class ShoppingFeeder_Fbtrack_Model_Observer extends Varien_Object
3
- {
4
- public function salesOrderPlaceAfter($observer)
5
- {
6
- try{
7
- $fbTracking = Mage::getStoreConfig('shoppingfeeder_fbtrack/fb_track_config/fb_track');
8
- if (!is_null($fbTracking) && $fbTracking)
9
- {
10
- /* @var Mage_Sales_Model_Order $order */
11
- $order = $observer->getEvent()->getOrder();
12
-
13
- //set the order for JS tracking code
14
- $orderItems = array();
15
- foreach ($order->getAllItems() as $item)
16
- {
17
- $orderItems[] = '\''.$item->getProductId().'\'';
18
- }
19
- $orderInfo = array(
20
- 'items' => $orderItems,
21
- 'value' => $order->getGrandTotal()
22
- );
23
- Mage::getModel('core/session')->setOrderForJsTrackingShoppingFeederFbtrack($orderInfo);
24
- }
25
- }
26
- catch (Exception $e)
27
- {
28
- Mage::log('_notifyShoppingFeeder Order ID: '.$order->getRealOrderId().' FAILED! Message: '.$e->getMessage());
29
- }
30
- }
31
-
32
- /**
33
- * @param Varien_Event_Observer $observer
34
- */
35
- public function generateBlocksAfter($observer)
36
- {
37
- try{
38
- $fbTracking = Mage::getStoreConfig('shoppingfeeder_fbtrack/fb_track_config/fb_track');
39
- if (!is_null($fbTracking) && $fbTracking)
40
- {
41
- $actionName = $observer->getEvent()->getAction()->getFullActionName();
42
- // var_dump($actionName);
43
- // exit();
44
- $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('shoppingfeeder_fbtrack_tracking_fb');
45
-
46
- if ($actionName == 'catalog_product_view' || $actionName == 'checkout_cart_index')
47
- {
48
- $product = Mage::registry('current_product');
49
- if (is_null($product))
50
- {
51
- $productId = Mage::getSingleton('core/session')->getProductToShoppingCartShoppingFeederFbtrack();
52
- $product = Mage::getModel('catalog/product')->load($productId);
53
- }
54
-
55
- //if we still don't have a product, don't do anything
56
- if (is_null($product))
57
- {
58
- return;
59
- }
60
-
61
- $pathToUse = '';
62
-
63
- $category = Mage::registry('current_category');
64
- $currentCategoryPath = null;
65
- if (!is_null($category))
66
- {
67
- $currentCategoryPath = $category->getPath();
68
- }
69
-
70
- $startTime = microtime(true);
71
-
72
- $storeRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
73
- $storeRootCategoryName = Mage::getModel('catalog/category')->load($storeRootCategoryId)->getName();
74
- if (is_null($currentCategoryPath))
75
- {
76
- if (!is_null($product) && is_object($product))
77
- {
78
- /** @var Mage_Catalog_Model_Resource_Category_Collection $categoryCollection */
79
- $categoryCollection = $product->getCategoryCollection()->addAttributeToSelect('name');
80
-
81
- $depth = 0;
82
- foreach($categoryCollection as $cat1){
83
- $pathIds = explode('/', $cat1->getPath());
84
- unset($pathIds[0]);
85
-
86
- $collection = Mage::getModel('catalog/category')->getCollection()
87
- ->setStoreId(Mage::app()->getStore()->getId())
88
- ->addAttributeToSelect('name')
89
- ->addAttributeToSelect('is_active')
90
- ->addFieldToFilter('entity_id', array('in' => $pathIds));
91
-
92
- $pathByName = array();
93
- /** @var Mage_Catalog_Model_Category $cat */
94
- foreach($collection as $cat){
95
- if ($cat->getName() != $storeRootCategoryName)
96
- {
97
- $pathByName[] = $cat->getName();
98
- }
99
- }
100
-
101
- //take the longest (generally more detailed) path
102
- $thisDepth = count($pathByName);
103
- if ($thisDepth > $depth)
104
- {
105
- $depth = $thisDepth;
106
- $pathToUse = implode(' > ', $pathByName);
107
- }
108
- }
109
- }
110
- }
111
- else
112
- {
113
- $pathIds = explode('/', $currentCategoryPath);
114
- unset($pathIds[0]);
115
-
116
- $collection = Mage::getModel('catalog/category')->getCollection()
117
- ->setStoreId(Mage::app()->getStore()->getId())
118
- ->addAttributeToSelect('name')
119
- ->addAttributeToSelect('is_active')
120
- ->addFieldToFilter('entity_id', array('in' => $pathIds));
121
-
122
- $pathByName = array();
123
- /** @var Mage_Catalog_Model_Category $cat */
124
- foreach($collection as $cat){
125
- if ($cat->getName() != $storeRootCategoryName)
126
- {
127
- $pathByName[] = $cat->getName();
128
- }
129
- }
130
- $pathToUse = implode(' > ', $pathByName);
131
- }
132
-
133
- if ($product)
134
- {
135
- $block->setData('product', $product);
136
- $block->setData('category', $pathToUse);
137
-
138
- if ($actionName == 'catalog_product_view')
139
- {
140
- $block->setData('action_type', 'ViewContent');
141
- }
142
- elseif ($actionName == 'checkout_cart_index')
143
- {
144
- $block->setData('action_type', 'AddToCart');
145
- //reset the cart product
146
- Mage::getModel('core/session')->unsProductToShoppingCartShoppingFeederFbtrack();
147
- }
148
- }
149
- }
150
-
151
-
152
- elseif ($actionName == 'checkout_onepage_success' || $actionName == 'checkout_multishipping_success')
153
- {
154
- Mage::log('After template action: '.$actionName);
155
- $orderInfo = Mage::getModel('core/session')->getOrderForJsTrackingShoppingFeederFbtrack();
156
- if (!is_null($orderInfo) && $block)
157
- {
158
- $block->setData('order', $orderInfo);
159
- $block->setData('action_type', 'Purchase');
160
- Mage::getModel('core/session')->unsOrderForJsTrackingShoppingFeederFbtrack();
161
- }
162
- }
163
- }
164
- }
165
- catch (Exception $e)
166
- {
167
-
168
- }
169
- }
170
-
171
- /**
172
- * @param Varien_Event_Observer $observer
173
- */
174
- public function setAddToCartProduct($observer)
175
- {
176
- try{
177
- Mage::getModel('core/session')->setProductToShoppingCartShoppingFeederFbtrack(Mage::app()->getRequest()->getParam('product', 0));
178
- }
179
- catch (Exception $e) {
180
-
181
- }
182
- }
183
  }
1
+ <?php
2
+ class ShoppingFeeder_Fbtrack_Model_Observer extends Varien_Object
3
+ {
4
+ public function salesOrderPlaceAfter($observer)
5
+ {
6
+ try{
7
+ $fbTracking = Mage::getStoreConfig('shoppingfeeder_fbtrack/fb_track_config/fb_track');
8
+ if (!is_null($fbTracking) && $fbTracking)
9
+ {
10
+ /* @var Mage_Sales_Model_Order $order */
11
+ $order = $observer->getEvent()->getOrder();
12
+
13
+ //set the order for JS tracking code
14
+ $orderItems = array();
15
+ foreach ($order->getAllItems() as $item)
16
+ {
17
+ $orderItems[] = '\''.$item->getProductId().'\'';
18
+ }
19
+ $orderInfo = array(
20
+ 'items' => $orderItems,
21
+ 'value' => $order->getGrandTotal()
22
+ );
23
+ Mage::getModel('core/session')->setOrderForJsTrackingShoppingFeederFbtrack($orderInfo);
24
+ }
25
+ }
26
+ catch (Exception $e)
27
+ {
28
+ Mage::log('_notifyShoppingFeeder Order ID: '.$order->getRealOrderId().' FAILED! Message: '.$e->getMessage());
29
+ }
30
+ }
31
+
32
+ /**
33
+ * @param Varien_Event_Observer $observer
34
+ */
35
+ public function generateBlocksAfter($observer)
36
+ {
37
+ try{
38
+ $fbTracking = Mage::getStoreConfig('shoppingfeeder_fbtrack/fb_track_config/fb_track');
39
+ if (!is_null($fbTracking) && $fbTracking)
40
+ {
41
+ $actionName = $observer->getEvent()->getAction()->getFullActionName();
42
+ // var_dump($actionName);
43
+ // exit();
44
+ $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('shoppingfeeder_fbtrack_tracking_fb');
45
+
46
+ if ($actionName == 'catalog_product_view' || $actionName == 'checkout_cart_index')
47
+ {
48
+ $product = Mage::registry('current_product');
49
+ if (is_null($product))
50
+ {
51
+ $productId = Mage::getSingleton('core/session')->getProductToShoppingCartShoppingFeederFbtrack();
52
+ $product = Mage::getModel('catalog/product')->load($productId);
53
+ }
54
+
55
+ //if we still don't have a product, don't do anything
56
+ if (is_null($product))
57
+ {
58
+ return;
59
+ }
60
+
61
+ $pathToUse = '';
62
+
63
+ $category = Mage::registry('current_category');
64
+ $currentCategoryPath = null;
65
+ if (!is_null($category))
66
+ {
67
+ $currentCategoryPath = $category->getPath();
68
+ }
69
+
70
+ $startTime = microtime(true);
71
+
72
+ $storeRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
73
+ $storeRootCategoryName = Mage::getModel('catalog/category')->load($storeRootCategoryId)->getName();
74
+ if (is_null($currentCategoryPath))
75
+ {
76
+ if (!is_null($product) && is_object($product))
77
+ {
78
+ /** @var Mage_Catalog_Model_Resource_Category_Collection $categoryCollection */
79
+ $categoryCollection = $product->getCategoryCollection()->addAttributeToSelect('name');
80
+
81
+ $depth = 0;
82
+ foreach($categoryCollection as $cat1){
83
+ $pathIds = explode('/', $cat1->getPath());
84
+ unset($pathIds[0]);
85
+
86
+ $collection = Mage::getModel('catalog/category')->getCollection()
87
+ ->setStoreId(Mage::app()->getStore()->getId())
88
+ ->addAttributeToSelect('name')
89
+ ->addAttributeToSelect('is_active')
90
+ ->addFieldToFilter('entity_id', array('in' => $pathIds));
91
+
92
+ $pathByName = array();
93
+ /** @var Mage_Catalog_Model_Category $cat */
94
+ foreach($collection as $cat){
95
+ if ($cat->getName() != $storeRootCategoryName)
96
+ {
97
+ $pathByName[] = $cat->getName();
98
+ }
99
+ }
100
+
101
+ //take the longest (generally more detailed) path
102
+ $thisDepth = count($pathByName);
103
+ if ($thisDepth > $depth)
104
+ {
105
+ $depth = $thisDepth;
106
+ $pathToUse = implode(' > ', $pathByName);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ else
112
+ {
113
+ $pathIds = explode('/', $currentCategoryPath);
114
+ unset($pathIds[0]);
115
+
116
+ $collection = Mage::getModel('catalog/category')->getCollection()
117
+ ->setStoreId(Mage::app()->getStore()->getId())
118
+ ->addAttributeToSelect('name')
119
+ ->addAttributeToSelect('is_active')
120
+ ->addFieldToFilter('entity_id', array('in' => $pathIds));
121
+
122
+ $pathByName = array();
123
+ /** @var Mage_Catalog_Model_Category $cat */
124
+ foreach($collection as $cat){
125
+ if ($cat->getName() != $storeRootCategoryName)
126
+ {
127
+ $pathByName[] = $cat->getName();
128
+ }
129
+ }
130
+ $pathToUse = implode(' > ', $pathByName);
131
+ }
132
+
133
+ if ($product)
134
+ {
135
+ $block->setData('product', $product);
136
+ $block->setData('category', $pathToUse);
137
+
138
+ if ($actionName == 'catalog_product_view')
139
+ {
140
+ $block->setData('action_type', 'ViewContent');
141
+ }
142
+ elseif ($actionName == 'checkout_cart_index')
143
+ {
144
+ $block->setData('action_type', 'AddToCart');
145
+ //reset the cart product
146
+ Mage::getModel('core/session')->unsProductToShoppingCartShoppingFeederFbtrack();
147
+ }
148
+ }
149
+ }
150
+
151
+
152
+ elseif ($actionName == 'checkout_onepage_success' || $actionName == 'checkout_multishipping_success')
153
+ {
154
+ Mage::log('After template action: '.$actionName);
155
+ $orderInfo = Mage::getModel('core/session')->getOrderForJsTrackingShoppingFeederFbtrack();
156
+ if (!is_null($orderInfo) && $block)
157
+ {
158
+ $block->setData('order', $orderInfo);
159
+ $block->setData('action_type', 'Purchase');
160
+ Mage::getModel('core/session')->unsOrderForJsTrackingShoppingFeederFbtrack();
161
+ }
162
+ }
163
+ }
164
+ }
165
+ catch (Exception $e)
166
+ {
167
+
168
+ }
169
+ }
170
+
171
+ /**
172
+ * @param Varien_Event_Observer $observer
173
+ */
174
+ public function setAddToCartProduct($observer)
175
+ {
176
+ try{
177
+ Mage::getModel('core/session')->setProductToShoppingCartShoppingFeederFbtrack(Mage::app()->getRequest()->getParam('product', 0));
178
+ }
179
+ catch (Exception $e) {
180
+
181
+ }
182
+ }
183
  }
app/code/community/ShoppingFeeder/Service/Controller/FrontAuth.php CHANGED
@@ -1,75 +1,75 @@
1
- <?php
2
-
3
- class ShoppingFeeder_Service_Controller_FrontAuth extends Mage_Core_Controller_Front_Action
4
- {
5
- public function preDispatch()
6
- {
7
- parent::preDispatch();
8
-
9
- //DEBUG
10
- // return $this;
11
-
12
- /**
13
- * For per-store system
14
- */
15
- $store = $this->getRequest()->getParam('store', null);
16
- if (!is_null($store))
17
- {
18
- Mage::app()->setCurrentStore($store);
19
- }
20
- else
21
- {
22
- $defaultStoreCode = Mage::app()
23
- ->getWebsite(true)
24
- ->getDefaultGroup()
25
- ->getDefaultStore()
26
- ->getCode();
27
-
28
- Mage::app()->setCurrentStore($defaultStoreCode);
29
- }
30
-
31
- //check Auth
32
- if (!function_exists('getallheaders'))
33
- {
34
- function getallheaders()
35
- {
36
- $headers = '';
37
- foreach ($_SERVER as $name => $value)
38
- {
39
- if (substr($name, 0, 5) == 'HTTP_')
40
- {
41
- $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
42
- }
43
- }
44
- return $headers;
45
- }
46
- }
47
-
48
- $headers = getallheaders();
49
-
50
- /** @var ShoppingFeeder_Service_Model_Auth $authModel */
51
- $authModel = Mage::getModel('shoppingfeeder_service/auth');
52
-
53
- $authResult = $authModel->auth(
54
- $headers,
55
- $this->getRequest()->getScheme(),
56
- $this->getRequest()->getMethod()
57
- );
58
-
59
- if ($authResult !== true)
60
- {
61
- $responseData = array(
62
- 'status' => 'fail',
63
- 'data' => array (
64
- 'message' => $authResult
65
- )
66
- );
67
-
68
- header('Content-type: application/json; charset=UTF-8');
69
- echo json_encode($responseData);
70
- exit();
71
- }
72
-
73
- return $this;
74
- }
75
  }
1
+ <?php
2
+
3
+ class ShoppingFeeder_Service_Controller_FrontAuth extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function preDispatch()
6
+ {
7
+ parent::preDispatch();
8
+
9
+ //DEBUG
10
+ // return $this;
11
+
12
+ /**
13
+ * For per-store system
14
+ */
15
+ $store = $this->getRequest()->getParam('store', null);
16
+ if (!is_null($store))
17
+ {
18
+ Mage::app()->setCurrentStore($store);
19
+ }
20
+ else
21
+ {
22
+ $defaultStoreCode = Mage::app()
23
+ ->getWebsite(true)
24
+ ->getDefaultGroup()
25
+ ->getDefaultStore()
26
+ ->getCode();
27
+
28
+ Mage::app()->setCurrentStore($defaultStoreCode);
29
+ }
30
+
31
+ //check Auth
32
+ if (!function_exists('getallheaders'))
33
+ {
34
+ function getallheaders()
35
+ {
36
+ $headers = '';
37
+ foreach ($_SERVER as $name => $value)
38
+ {
39
+ if (substr($name, 0, 5) == 'HTTP_')
40
+ {
41
+ $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
42
+ }
43
+ }
44
+ return $headers;
45
+ }
46
+ }
47
+
48
+ $headers = getallheaders();
49
+
50
+ /** @var ShoppingFeeder_Service_Model_Auth $authModel */
51
+ $authModel = Mage::getModel('shoppingfeeder_service/auth');
52
+
53
+ $authResult = $authModel->auth(
54
+ $headers,
55
+ $this->getRequest()->getScheme(),
56
+ $this->getRequest()->getMethod()
57
+ );
58
+
59
+ if ($authResult !== true)
60
+ {
61
+ $responseData = array(
62
+ 'status' => 'fail',
63
+ 'data' => array (
64
+ 'message' => $authResult
65
+ )
66
+ );
67
+
68
+ header('Content-type: application/json; charset=UTF-8');
69
+ echo json_encode($responseData);
70
+ exit();
71
+ }
72
+
73
+ return $this;
74
+ }
75
  }
app/code/community/ShoppingFeeder/Service/Model/Auth.php CHANGED
@@ -1,103 +1,103 @@
1
- <?php
2
-
3
- class ShoppingFeeder_Service_Model_Auth extends Mage_Core_Model_Abstract
4
- {
5
- const RANDOM_STRING = 'The mice all ate cheese together.';
6
- const MAX_TIMEOUT = 300; //5 minutes
7
-
8
- public function __construct()
9
- {
10
- $this->_init('shoppingfeeder_service/auth');
11
- }
12
-
13
- public static function auth(array $headers, $incomingScheme, $incomingMethod)
14
- {
15
- //check the API key
16
- $incomingApiKey = '';
17
- $incomingAuthTimestamp = strtotime('1970-00-00');
18
- $incomingSignature = '';
19
- foreach ($headers as $key => $value)
20
- {
21
- if (strtolower('X-SFApiKey') == strtolower($key))
22
- {
23
- $incomingApiKey = $value;
24
- }
25
- if (strtolower('X-SFTimestamp') == strtolower($key))
26
- {
27
- $incomingAuthTimestamp = $value;
28
- }
29
- if (strtolower('X-SFSignature') == strtolower($key))
30
- {
31
- $incomingSignature = $value;
32
- }
33
- }
34
-
35
- //$sslInFront = Mage::getStoreConfig('web/secure/use_in_frontend');
36
- //$useSsl = ($sslInFront == null) ? false : boolval($sslInFront);
37
- $useSsl = false;
38
-
39
- $apiKeys = self::getApiKeys();
40
-
41
- if (!$useSsl || ($useSsl && $incomingScheme == 'https'))
42
- {
43
- //check the timestamp
44
- if (time() - $incomingAuthTimestamp <= self::MAX_TIMEOUT)
45
- {
46
- $localApiKey = $apiKeys['api_key'];
47
- if ($localApiKey == $incomingApiKey)
48
- {
49
- $localApiSecret = $apiKeys['api_secret'];
50
-
51
- $stringToSign = $incomingMethod . "\n" .
52
- $incomingAuthTimestamp . "\n" .
53
- self::RANDOM_STRING;
54
-
55
- if (function_exists('hash_hmac'))
56
- {
57
- $signature = hash_hmac('sha256', $stringToSign, $localApiSecret);
58
- }
59
- elseif (function_exists('mhash'))
60
- {
61
- $signature = bin2hex(mhash(MHASH_SHA256, $stringToSign, $localApiSecret));
62
- }
63
- else
64
- {
65
- return 'Authentication failed: Appropriate hashing function does not exist.';
66
- }
67
-
68
- if ($incomingSignature == $signature)
69
- {
70
- return true;
71
- }
72
- else
73
- {
74
- return 'Authentication failed: invalid credentials.';
75
- }
76
- }
77
- else
78
- {
79
- return 'Authentication failed: invalid API key.';
80
- }
81
- }
82
- else
83
- {
84
- return 'Authentication failed: timeout exceeded.';
85
- }
86
- }
87
- else
88
- {
89
- return 'Authentication failed: non-secure connection';
90
- }
91
- }
92
-
93
- public static function getApiKeys()
94
- {
95
- $localApiKey = Mage::getStoreConfig('shoppingfeeder/service/apikey');
96
- $localApiSecret = Mage::getStoreConfig('shoppingfeeder/service/apisecret');
97
-
98
- return array(
99
- 'api_key' => $localApiKey,
100
- 'api_secret' => $localApiSecret
101
- );
102
- }
103
  }
1
+ <?php
2
+
3
+ class ShoppingFeeder_Service_Model_Auth extends Mage_Core_Model_Abstract
4
+ {
5
+ const RANDOM_STRING = 'The mice all ate cheese together.';
6
+ const MAX_TIMEOUT = 300; //5 minutes
7
+
8
+ public function __construct()
9
+ {
10
+ $this->_init('shoppingfeeder_service/auth');
11
+ }
12
+
13
+ public static function auth(array $headers, $incomingScheme, $incomingMethod)
14
+ {
15
+ //check the API key
16
+ $incomingApiKey = '';
17
+ $incomingAuthTimestamp = strtotime('1970-00-00');
18
+ $incomingSignature = '';
19
+ foreach ($headers as $key => $value)
20
+ {
21
+ if (strtolower('X-SFApiKey') == strtolower($key))
22
+ {
23
+ $incomingApiKey = $value;
24
+ }
25
+ if (strtolower('X-SFTimestamp') == strtolower($key))
26
+ {
27
+ $incomingAuthTimestamp = $value;
28
+ }
29
+ if (strtolower('X-SFSignature') == strtolower($key))
30
+ {
31
+ $incomingSignature = $value;
32
+ }
33
+ }
34
+
35
+ //$sslInFront = Mage::getStoreConfig('web/secure/use_in_frontend');
36
+ //$useSsl = ($sslInFront == null) ? false : boolval($sslInFront);
37
+ $useSsl = false;
38
+
39
+ $apiKeys = self::getApiKeys();
40
+
41
+ if (!$useSsl || ($useSsl && $incomingScheme == 'https'))
42
+ {
43
+ //check the timestamp
44
+ if (time() - $incomingAuthTimestamp <= self::MAX_TIMEOUT)
45
+ {
46
+ $localApiKey = $apiKeys['api_key'];
47
+ if ($localApiKey == $incomingApiKey)
48
+ {
49
+ $localApiSecret = $apiKeys['api_secret'];
50
+
51
+ $stringToSign = $incomingMethod . "\n" .
52
+ $incomingAuthTimestamp . "\n" .
53
+ self::RANDOM_STRING;
54
+
55
+ if (function_exists('hash_hmac'))
56
+ {
57
+ $signature = hash_hmac('sha256', $stringToSign, $localApiSecret);
58
+ }
59
+ elseif (function_exists('mhash'))
60
+ {
61
+ $signature = bin2hex(mhash(MHASH_SHA256, $stringToSign, $localApiSecret));
62
+ }
63
+ else
64
+ {
65
+ return 'Authentication failed: Appropriate hashing function does not exist.';
66
+ }
67
+
68
+ if ($incomingSignature == $signature)
69
+ {
70
+ return true;
71
+ }
72
+ else
73
+ {
74
+ return 'Authentication failed: invalid credentials.';
75
+ }
76
+ }
77
+ else
78
+ {
79
+ return 'Authentication failed: invalid API key.';
80
+ }
81
+ }
82
+ else
83
+ {
84
+ return 'Authentication failed: timeout exceeded.';
85
+ }
86
+ }
87
+ else
88
+ {
89
+ return 'Authentication failed: non-secure connection';
90
+ }
91
+ }
92
+
93
+ public static function getApiKeys()
94
+ {
95
+ $localApiKey = Mage::getStoreConfig('shoppingfeeder/service/apikey');
96
+ $localApiSecret = Mage::getStoreConfig('shoppingfeeder/service/apisecret');
97
+
98
+ return array(
99
+ 'api_key' => $localApiKey,
100
+ 'api_secret' => $localApiSecret
101
+ );
102
+ }
103
  }
app/code/community/ShoppingFeeder/Service/Model/Observer.php CHANGED
@@ -1,241 +1,241 @@
1
- <?php
2
- class ShoppingFeeder_Service_Model_Observer extends Varien_Object
3
- {
4
- const SF_URL = 'https://www.shoppingfeeder.com/webhook/magento-orders/';
5
- //const SF_URL = 'http://dev.shoppingfeeder.com/webhook/magento-orders/';
6
-
7
- public function salesOrderPlaceAfter($observer)
8
- {
9
- try{
10
- //if order tracking is set
11
- //$sfEnabled = Mage::getStoreConfig('shoppingfeeder/service/enable');
12
- $sfEnabled = true;
13
- $sfTracking = Mage::getStoreConfig('shoppingfeeder/service/tracking');
14
- $fbTracking = Mage::getStoreConfig('shoppingfeeder/fb_track_config/fb_track');
15
- if (($sfEnabled && $sfTracking) || (!is_null($fbTracking) && $fbTracking))
16
- {
17
- /* @var Mage_Sales_Model_Order $order */
18
- $order = $observer->getEvent()->getOrder();
19
-
20
- //Mage::log('salesOrderPlaceAfter Order ID: '.$order->getRealOrderId());
21
-
22
- //set the order for JS tracking code
23
- $orderItems = array();
24
- foreach ($order->getAllItems() as $item)
25
- {
26
- $orderItems[] = '\''.$item->getProductId().'\'';
27
- }
28
- $orderInfo = array(
29
- 'items' => $orderItems,
30
- 'value' => $order->getGrandTotal()
31
- );
32
- Mage::getSingleton('core/session')->setSfdrOrderForJsTracking($orderInfo);
33
-
34
- //only notify ShoppingFeeder if required
35
- if ($sfEnabled && $sfTracking)
36
- {
37
- $this->_notifyShoppingFeeder($order);
38
- }
39
- }
40
- }
41
- catch (Exception $e)
42
- {
43
- Mage::log('_notifyShoppingFeeder Order ID: '.$order->getRealOrderId().' FAILED! Message: '.$e->getMessage());
44
- }
45
- }
46
-
47
- public function productView($observer)
48
- {
49
- try{
50
- //here we're going to create the referral cookie for the visitor if they came from ShoppingFeeder
51
- if (isset($_GET['SFDRREF']))
52
- {
53
- setcookie('SFDRREF', $_GET['SFDRREF'], time() + (60*60*24*30), '/');
54
- $_COOKIE['SFDRREF']= $_GET['SFDRREF'];
55
- }
56
- }
57
- catch (Exception $e)
58
- {
59
-
60
- }
61
- }
62
-
63
- /**
64
- * @param Varien_Event_Observer $observer
65
- */
66
- public function generateBlocksAfter($observer)
67
- {
68
- try{
69
- $fbTracking = Mage::getStoreConfig('shoppingfeeder/fb_track_config/fb_track');
70
- if (!is_null($fbTracking) && $fbTracking)
71
- {
72
- $actionName = $observer->getEvent()->getAction()->getFullActionName();
73
- // var_dump($actionName);
74
- // exit();
75
- $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('shoppingfeeder_service_tracking_fb');
76
-
77
- if ($actionName == 'catalog_product_view' || $actionName == 'checkout_cart_index')
78
- {
79
- $product = Mage::registry('current_product');
80
- if (is_null($product))
81
- {
82
- $productId = Mage::getSingleton('core/session')->getSfdrProductToShoppingCart();
83
- $product = Mage::getModel('catalog/product')->load($productId);
84
- }
85
-
86
- //if we still don't have a product, don't do anything
87
- if (is_null($product))
88
- {
89
- return;
90
- }
91
-
92
- $pathToUse = '';
93
-
94
- $category = Mage::registry('current_category');
95
- $currentCategoryPath = null;
96
- if (!is_null($category))
97
- {
98
- $currentCategoryPath = $category->getPath();
99
- }
100
-
101
- $startTime = microtime(true);
102
-
103
- $storeRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
104
- $storeRootCategoryName = Mage::getModel('catalog/category')->load($storeRootCategoryId)->getName();
105
- if (is_null($currentCategoryPath))
106
- {
107
- if (!is_null($product) && is_object($product))
108
- {
109
- /** @var Mage_Catalog_Model_Resource_Category_Collection $categoryCollection */
110
- $categoryCollection = $product->getCategoryCollection()->addAttributeToSelect('name');
111
-
112
- $depth = 0;
113
- foreach($categoryCollection as $cat1){
114
- $pathIds = explode('/', $cat1->getPath());
115
- unset($pathIds[0]);
116
-
117
- $collection = Mage::getModel('catalog/category')->getCollection()
118
- ->setStoreId(Mage::app()->getStore()->getId())
119
- ->addAttributeToSelect('name')
120
- ->addAttributeToSelect('is_active')
121
- ->addFieldToFilter('entity_id', array('in' => $pathIds));
122
-
123
- $pathByName = array();
124
- /** @var Mage_Catalog_Model_Category $cat */
125
- foreach($collection as $cat){
126
- if ($cat->getName() != $storeRootCategoryName)
127
- {
128
- $pathByName[] = $cat->getName();
129
- }
130
- }
131
-
132
- //take the longest (generally more detailed) path
133
- $thisDepth = count($pathByName);
134
- if ($thisDepth > $depth)
135
- {
136
- $depth = $thisDepth;
137
- $pathToUse = implode(' > ', $pathByName);
138
- }
139
- }
140
- }
141
- }
142
- else
143
- {
144
- $pathIds = explode('/', $currentCategoryPath);
145
- unset($pathIds[0]);
146
-
147
- $collection = Mage::getModel('catalog/category')->getCollection()
148
- ->setStoreId(Mage::app()->getStore()->getId())
149
- ->addAttributeToSelect('name')
150
- ->addAttributeToSelect('is_active')
151
- ->addFieldToFilter('entity_id', array('in' => $pathIds));
152
-
153
- $pathByName = array();
154
- /** @var Mage_Catalog_Model_Category $cat */
155
- foreach($collection as $cat){
156
- if ($cat->getName() != $storeRootCategoryName)
157
- {
158
- $pathByName[] = $cat->getName();
159
- }
160
- }
161
- $pathToUse = implode(' > ', $pathByName);
162
- }
163
-
164
- if ($product)
165
- {
166
- $block->setData('product', $product);
167
- $block->setData('category', $pathToUse);
168
-
169
- if ($actionName == 'catalog_product_view')
170
- {
171
- $block->setData('action_type', 'ViewContent');
172
- }
173
- elseif ($actionName == 'checkout_cart_index')
174
- {
175
- $block->setData('action_type', 'AddToCart');
176
- //reset the cart product
177
- Mage::getSingleton('core/session')->unsSfdrProductToShoppingCart();
178
- }
179
- }
180
- }
181
-
182
-
183
- elseif ($actionName == 'checkout_onepage_success' || $actionName == 'checkout_multishipping_success')
184
- {
185
- $orderInfo = Mage::getSingleton('core/session')->getSfdrOrderForJsTracking();
186
- if (!is_null($orderInfo) && $block)
187
- {
188
- $block->setData('order', $orderInfo);
189
- $block->setData('action_type', 'Purchase');
190
- Mage::getSingleton('core/session')->unsSfdrOrderForJsTracking();
191
- }
192
- }
193
- }
194
- }
195
- catch (Exception $e)
196
- {
197
-
198
- }
199
- }
200
-
201
- /**
202
- * @param Varien_Event_Observer $observer
203
- */
204
- public function setAddToCartProduct($observer)
205
- {
206
- try{
207
-
208
- //add the cart product to the session
209
- // $product = Mage::getModel('catalog/product')
210
- // ->load(Mage::app()->getRequest()->getParam('product', 0));
211
-
212
- Mage::getSingleton('core/session')->setSfdrProductToShoppingCart(Mage::app()->getRequest()->getParam('product', 0));
213
- }
214
- catch (Exception $e)
215
- {
216
-
217
- }
218
- }
219
-
220
- protected function _notifyShoppingFeeder(Mage_Sales_Model_Order $order)
221
- {
222
- Mage::log('_notifyShoppingFeeder Order ID: '.$order->getRealOrderId());
223
-
224
- //get API key value from admin settings
225
- $apiKey = $sfTracking = Mage::getStoreConfig('shoppingfeeder/service/apikey');
226
-
227
- $http = new Zend_Http_Client(self::SF_URL);
228
-
229
- $http->setHeaders('X-SFApiKey', $apiKey);
230
-
231
- $data = $order->toArray();
232
- foreach ($order->getAllItems() as $lineItem)
233
- {
234
- $data['line_items'][] = $lineItem->toArray();
235
- }
236
- $data['landing_site_ref'] = isset($_COOKIE['SFDRREF']) ? $_COOKIE['SFDRREF'] : '';
237
-
238
- $http->setRawData(Mage::helper('core')->jsonEncode($data));
239
- $http->request(Zend_Http_Client::POST);
240
- }
241
  }
1
+ <?php
2
+ class ShoppingFeeder_Service_Model_Observer extends Varien_Object
3
+ {
4
+ const SF_URL = 'https://www.shoppingfeeder.com/webhook/magento-orders/';
5
+ //const SF_URL = 'http://dev.shoppingfeeder.com/webhook/magento-orders/';
6
+
7
+ public function salesOrderPlaceAfter($observer)
8
+ {
9
+ try{
10
+ //if order tracking is set
11
+ //$sfEnabled = Mage::getStoreConfig('shoppingfeeder/service/enable');
12
+ $sfEnabled = true;
13
+ $sfTracking = Mage::getStoreConfig('shoppingfeeder/service/tracking');
14
+ $fbTracking = Mage::getStoreConfig('shoppingfeeder/fb_track_config/fb_track');
15
+ if (($sfEnabled && $sfTracking) || (!is_null($fbTracking) && $fbTracking))
16
+ {
17
+ /* @var Mage_Sales_Model_Order $order */
18
+ $order = $observer->getEvent()->getOrder();
19
+
20
+ //Mage::log('salesOrderPlaceAfter Order ID: '.$order->getRealOrderId());
21
+
22
+ //set the order for JS tracking code
23
+ $orderItems = array();
24
+ foreach ($order->getAllItems() as $item)
25
+ {
26
+ $orderItems[] = '\''.$item->getProductId().'\'';
27
+ }
28
+ $orderInfo = array(
29
+ 'items' => $orderItems,
30
+ 'value' => $order->getGrandTotal()
31
+ );
32
+ Mage::getSingleton('core/session')->setSfdrOrderForJsTracking($orderInfo);
33
+
34
+ //only notify ShoppingFeeder if required
35
+ if ($sfEnabled && $sfTracking)
36
+ {
37
+ $this->_notifyShoppingFeeder($order);
38
+ }
39
+ }
40
+ }
41
+ catch (Exception $e)
42
+ {
43
+ Mage::log('_notifyShoppingFeeder Order ID: '.$order->getRealOrderId().' FAILED! Message: '.$e->getMessage());
44
+ }
45
+ }
46
+
47
+ public function productView($observer)
48
+ {
49
+ try{
50
+ //here we're going to create the referral cookie for the visitor if they came from ShoppingFeeder
51
+ if (isset($_GET['SFDRREF']))
52
+ {
53
+ setcookie('SFDRREF', $_GET['SFDRREF'], time() + (60*60*24*30), '/');
54
+ $_COOKIE['SFDRREF']= $_GET['SFDRREF'];
55
+ }
56
+ }
57
+ catch (Exception $e)
58
+ {
59
+
60
+ }
61
+ }
62
+
63
+ /**
64
+ * @param Varien_Event_Observer $observer
65
+ */
66
+ public function generateBlocksAfter($observer)
67
+ {
68
+ try{
69
+ $fbTracking = Mage::getStoreConfig('shoppingfeeder/fb_track_config/fb_track');
70
+ if (!is_null($fbTracking) && $fbTracking)
71
+ {
72
+ $actionName = $observer->getEvent()->getAction()->getFullActionName();
73
+ // var_dump($actionName);
74
+ // exit();
75
+ $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('shoppingfeeder_service_tracking_fb');
76
+
77
+ if ($actionName == 'catalog_product_view' || $actionName == 'checkout_cart_index')
78
+ {
79
+ $product = Mage::registry('current_product');
80
+ if (is_null($product))
81
+ {
82
+ $productId = Mage::getSingleton('core/session')->getSfdrProductToShoppingCart();
83
+ $product = Mage::getModel('catalog/product')->load($productId);
84
+ }
85
+
86
+ //if we still don't have a product, don't do anything
87
+ if (is_null($product))
88
+ {
89
+ return;
90
+ }
91
+
92
+ $pathToUse = '';
93
+
94
+ $category = Mage::registry('current_category');
95
+ $currentCategoryPath = null;
96
+ if (!is_null($category))
97
+ {
98
+ $currentCategoryPath = $category->getPath();
99
+ }
100
+
101
+ $startTime = microtime(true);
102
+
103
+ $storeRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
104
+ $storeRootCategoryName = Mage::getModel('catalog/category')->load($storeRootCategoryId)->getName();
105
+ if (is_null($currentCategoryPath))
106
+ {
107
+ if (!is_null($product) && is_object($product))
108
+ {
109
+ /** @var Mage_Catalog_Model_Resource_Category_Collection $categoryCollection */
110
+ $categoryCollection = $product->getCategoryCollection()->addAttributeToSelect('name');
111
+
112
+ $depth = 0;
113
+ foreach($categoryCollection as $cat1){
114
+ $pathIds = explode('/', $cat1->getPath());
115
+ unset($pathIds[0]);
116
+
117
+ $collection = Mage::getModel('catalog/category')->getCollection()
118
+ ->setStoreId(Mage::app()->getStore()->getId())
119
+ ->addAttributeToSelect('name')
120
+ ->addAttributeToSelect('is_active')
121
+ ->addFieldToFilter('entity_id', array('in' => $pathIds));
122
+
123
+ $pathByName = array();
124
+ /** @var Mage_Catalog_Model_Category $cat */
125
+ foreach($collection as $cat){
126
+ if ($cat->getName() != $storeRootCategoryName)
127
+ {
128
+ $pathByName[] = $cat->getName();
129
+ }
130
+ }
131
+
132
+ //take the longest (generally more detailed) path
133
+ $thisDepth = count($pathByName);
134
+ if ($thisDepth > $depth)
135
+ {
136
+ $depth = $thisDepth;
137
+ $pathToUse = implode(' > ', $pathByName);
138
+ }
139
+ }
140
+ }
141
+ }
142
+ else
143
+ {
144
+ $pathIds = explode('/', $currentCategoryPath);
145
+ unset($pathIds[0]);
146
+
147
+ $collection = Mage::getModel('catalog/category')->getCollection()
148
+ ->setStoreId(Mage::app()->getStore()->getId())
149
+ ->addAttributeToSelect('name')
150
+ ->addAttributeToSelect('is_active')
151
+ ->addFieldToFilter('entity_id', array('in' => $pathIds));
152
+
153
+ $pathByName = array();
154
+ /** @var Mage_Catalog_Model_Category $cat */
155
+ foreach($collection as $cat){
156
+ if ($cat->getName() != $storeRootCategoryName)
157
+ {
158
+ $pathByName[] = $cat->getName();
159
+ }
160
+ }
161
+ $pathToUse = implode(' > ', $pathByName);
162
+ }
163
+
164
+ if ($product)
165
+ {
166
+ $block->setData('product', $product);
167
+ $block->setData('category', $pathToUse);
168
+
169
+ if ($actionName == 'catalog_product_view')
170
+ {
171
+ $block->setData('action_type', 'ViewContent');
172
+ }
173
+ elseif ($actionName == 'checkout_cart_index')
174
+ {
175
+ $block->setData('action_type', 'AddToCart');
176
+ //reset the cart product
177
+ Mage::getSingleton('core/session')->unsSfdrProductToShoppingCart();
178
+ }
179
+ }
180
+ }
181
+
182
+
183
+ elseif ($actionName == 'checkout_onepage_success' || $actionName == 'checkout_multishipping_success')
184
+ {
185
+ $orderInfo = Mage::getSingleton('core/session')->getSfdrOrderForJsTracking();
186
+ if (!is_null($orderInfo) && $block)
187
+ {
188
+ $block->setData('order', $orderInfo);
189
+ $block->setData('action_type', 'Purchase');
190
+ Mage::getSingleton('core/session')->unsSfdrOrderForJsTracking();
191
+ }
192
+ }
193
+ }
194
+ }
195
+ catch (Exception $e)
196
+ {
197
+
198
+ }
199
+ }
200
+
201
+ /**
202
+ * @param Varien_Event_Observer $observer
203
+ */
204
+ public function setAddToCartProduct($observer)
205
+ {
206
+ try{
207
+
208
+ //add the cart product to the session
209
+ // $product = Mage::getModel('catalog/product')
210
+ // ->load(Mage::app()->getRequest()->getParam('product', 0));
211
+
212
+ Mage::getSingleton('core/session')->setSfdrProductToShoppingCart(Mage::app()->getRequest()->getParam('product', 0));
213
+ }
214
+ catch (Exception $e)
215
+ {
216
+
217
+ }
218
+ }
219
+
220
+ protected function _notifyShoppingFeeder(Mage_Sales_Model_Order $order)
221
+ {
222
+ Mage::log('_notifyShoppingFeeder Order ID: '.$order->getRealOrderId());
223
+
224
+ //get API key value from admin settings
225
+ $apiKey = $sfTracking = Mage::getStoreConfig('shoppingfeeder/service/apikey');
226
+
227
+ $http = new Zend_Http_Client(self::SF_URL);
228
+
229
+ $http->setHeaders('X-SFApiKey', $apiKey);
230
+
231
+ $data = $order->toArray();
232
+ foreach ($order->getAllItems() as $lineItem)
233
+ {
234
+ $data['line_items'][] = $lineItem->toArray();
235
+ }
236
+ $data['landing_site_ref'] = isset($_COOKIE['SFDRREF']) ? $_COOKIE['SFDRREF'] : '';
237
+
238
+ $http->setRawData(Mage::helper('core')->jsonEncode($data));
239
+ $http->request(Zend_Http_Client::POST);
240
+ }
241
  }
app/code/community/ShoppingFeeder/Service/Model/Offers.php CHANGED
@@ -1,520 +1,520 @@
1
- <?php
2
-
3
- class ShoppingFeeder_Service_Model_Offers extends Mage_Core_Model_Abstract
4
- {
5
- public function __construct()
6
- {
7
- $this->_init('shoppingfeeder_service/offers');
8
- }
9
-
10
- private function hasParent($product)
11
- {
12
- $parents = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
13
- return !empty($parents);
14
- }
15
-
16
- private function getProductInfo(Mage_Catalog_Model_Product $product, Mage_Catalog_Model_Product $parent = null, $variantOptions = null, $lastUpdate = null, $priceCurrency, $priceCurrencyRate)
17
- {
18
- /** @var Mage_Catalog_Model_Product_Type_Configurable $configModel */
19
- $configModel = Mage::getModel('catalog/product_type_configurable');
20
-
21
- $p = array();
22
-
23
- $isVariant = !is_null($parent);
24
-
25
- /**
26
- * We only want to pull variants (children of configurable products) that are children, not as standalone products
27
- */
28
- //if this product's parent is visible in catalog and search, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
29
- //we will find this product when we fetch all the children of this parent through a normal iteration, so return nothing
30
- if (!$isVariant && $this->hasParent($product))
31
- {
32
- return array();
33
- }
34
-
35
- if ($isVariant)
36
- {
37
- $variant = $product;
38
- $product = $parent;
39
- }
40
-
41
- $data = $product->getData();
42
-
43
- /* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
44
- $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
45
-
46
- $attributes = $product->getAttributes();
47
-
48
- $manufacturer = '';
49
- $brand = '';
50
-
51
- $usefulAttributes = array();
52
-
53
- /**
54
- * @var Mage_Eav_Model_Entity_Attribute_Abstract $attribute
55
- */
56
- // var_dump("");
57
- // var_dump("");
58
- // var_dump("");
59
- foreach ($attributes as $attribute)
60
- {
61
- $attributeCode = $attribute->getAttributeCode();
62
- $attributeLabel = $attribute->getData('frontend_label');
63
-
64
- if ($isVariant)
65
- {
66
- $value = $attribute->getFrontend()->getValue($variant);
67
- }
68
- else
69
- {
70
- $value = $attribute->getFrontend()->getValue($product);
71
- }
72
-
73
- // var_dump($attributeCode. ' : '.print_r($value, true));
74
- // var_dump($attributeLabel. ' : '.print_r($value, true));
75
-
76
- if (preg_match('/^manufacturer$/i', $attributeCode) || preg_match('/^manufacturer$/i', $attributeLabel))
77
- {
78
- $manufacturer = $value;
79
- }
80
-
81
- if (preg_match('/^brand$/i', $attributeCode) || preg_match('/^brand$/i', $attributeLabel))
82
- {
83
- $brand = $value;
84
- }
85
-
86
- /*
87
- if (preg_match('/age/i', $attributeCode) || preg_match('/age/i', $attributeLabel))
88
- {
89
- $usefulAttributes['age'] = $value;
90
- }
91
- if (preg_match('/color|colour/i', $attributeCode) || preg_match('/color|colour/i', $attributeLabel))
92
- {
93
- $usefulAttributes['colour'] = $value;
94
- }
95
- if (preg_match('/size/i', $attributeCode) || preg_match('/size/i', $attributeLabel))
96
- {
97
- $usefulAttributes['size'] = $value;
98
- }
99
- if (preg_match('/gender|sex/i', $attributeCode) || preg_match('/gender|sex/i', $attributeLabel))
100
- {
101
- $usefulAttributes['gender'] = $value;
102
- }
103
- if (preg_match('/material/i', $attributeCode) || preg_match('/material/i', $attributeLabel))
104
- {
105
- $usefulAttributes['material'] = $value;
106
- }
107
- if (preg_match('/pattern/i', $attributeCode) || preg_match('/pattern/i', $attributeLabel))
108
- {
109
- $usefulAttributes['pattern'] = $value;
110
- }
111
- */
112
-
113
- $attributeValue = $attribute->getFrontend()->getValue($product);
114
- //don't deal with arrays
115
- if (!is_array($attributeValue))
116
- {
117
- if (!is_null($product->getData($attributeCode)) && ((string)$attributeValue != ''))
118
- {
119
- $usefulAttributes[$attributeCode] = $value;
120
- }
121
- }
122
- }
123
- // exit();
124
-
125
- //category path
126
- $categories = $product->getCategoryIds();
127
-
128
- $categoryPathsToEvaluate = array();
129
- $maxDepth = 0;
130
- $categoryPathToUse = '';
131
-
132
- $storeRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
133
- $storeRootCategoryName = Mage::getModel('catalog/category')->load($storeRootCategoryId)->getName();
134
-
135
- $lastCatUrl = null;
136
- if (!empty($categories))
137
- {
138
- /** @var Mage_Catalog_Model_Resource_Category_Collection $categoryCollection */
139
- $categoryCollection = $product->getCategoryCollection()->addAttributeToSelect('name');
140
-
141
- $depth = 0;
142
- foreach($categoryCollection as $cat1){
143
- $pathIds = explode('/', $cat1->getPath());
144
- unset($pathIds[0]);
145
-
146
- $collection = Mage::getModel('catalog/category')->getCollection()
147
- ->setStoreId(Mage::app()->getStore()->getId())
148
- ->addAttributeToSelect('name')
149
- ->addAttributeToSelect('is_active')
150
- ->addFieldToFilter('entity_id', array('in' => $pathIds))
151
- ->addUrlRewriteToResult();
152
-
153
- $pathByName = array();
154
- /** @var Mage_Catalog_Model_Category $cat */
155
- foreach($collection as $cat){
156
- if ($cat->getName() != $storeRootCategoryName)
157
- {
158
- $pathByName[] = $cat->getName();
159
-
160
- //try get the category URL
161
- try {
162
- $lastCatUrl = $cat->getUrl();
163
- }
164
- catch (Exception $e) {
165
-
166
- }
167
- }
168
- }
169
-
170
- //take the longest (generally more detailed) path
171
- $thisDepth = count($pathByName);
172
- if ($thisDepth > $depth)
173
- {
174
- $depth = $thisDepth;
175
- $categoryPathToUse = implode(' > ', $pathByName);
176
- }
177
- }
178
-
179
- // //we will get all the category paths and then use the most refined, deepest one
180
- // foreach ($categories as $rootCategoryId)
181
- // {
182
- // $depth = 0;
183
- // $category_path = '';
184
- //
185
- // $mageCategoryPath = Mage::getModel('catalog/category')->load($rootCategoryId)->getPath();
186
- // $allCategoryIds = explode('/', $mageCategoryPath);
187
- // unset($allCategoryIds[0]);
188
- //
189
- // $categoryPath = '';
190
- // /**
191
- // * @var Mage_Catalog_Model_Category $category
192
- // */
193
- // foreach ($allCategoryIds as $categoryId)
194
- // {
195
- // $depth++;
196
- // $category = Mage::getModel('catalog/category')->load($categoryId);
197
- // $category_name = $category->getName();
198
- // if ($category_name != $storeRootCategoryName)
199
- // {
200
- // if (!empty($categoryPath))
201
- // {
202
- // $categoryPath.= ' > ';
203
- // }
204
- // $categoryPath.= $category_name;
205
- // }
206
- // }
207
- //
208
- // $categoryPathsToEvaluate[$rootCategoryId]['path'] = $categoryPath;
209
- // $categoryPathsToEvaluate[$rootCategoryId]['depth'] = $depth;
210
- //
211
- // if ($maxDepth < $depth)
212
- // {
213
- // $maxDepth = $depth;
214
- // $categoryPathToUse = $categoryPath;
215
- // }
216
- // }
217
- }
218
-
219
- if ($isVariant && isset($variant))
220
- {
221
- // var_dump($usefulAttributes);
222
- $p['internal_variant_id'] = $variant->getId();
223
-
224
- $variantOptionsTitle = array();
225
- $variantPrice = $variantOptions['basePrice'];
226
-
227
- $urlHashParts = array();
228
-
229
- // Collect options applicable to the configurable product
230
- if (isset($variantOptions['refactoredOptions'][$variant->getId()]))
231
- {
232
- foreach ($variantOptions['refactoredOptions'][$variant->getId()] as $attributeCode => $option) {
233
- $variantOptionsTitle[] = $option['value'];
234
-
235
- //add these configured attributes to the set of parent's attributes
236
- $usefulAttributes[$attributeCode] = $option['value'];
237
-
238
- if (is_null($option['price']))
239
- {
240
- $variantPrice = $variant->getPrice();
241
- }
242
- else
243
- {
244
- $variantPrice += $option['price'];
245
- }
246
-
247
- $urlHashParts[] = $option['attributeId'].'='.$option['valueId'];
248
- }
249
- }
250
-
251
- $variantOptionsTitle = implode(' / ', $variantOptionsTitle);
252
- $title = $data['name'] . ' - ' . $variantOptionsTitle;
253
- $sku = $variant->getData('sku');
254
- $price = $variantPrice;
255
- $salePrice = $variant->getSpecialPrice();
256
- $variantImage = $variant->getImage();
257
-
258
- if (!is_null($variantImage) && !empty($variantImage) && $variantImage!='no_selection')
259
- {
260
- $imageFile = $variant->getImage();
261
- // $imageUrl = $p['image_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
262
- // 'catalog/product/'.preg_replace('/^\//', '', $imageFile);
263
- $imageUrl = $p['image_url'] = $variant->getMediaConfig()->getMediaUrl($imageFile);
264
- $imageLocalPath = $variant->getMediaConfig()->getMediaPath($imageFile);
265
- }
266
- else
267
- {
268
- $imageFile = $product->getImage();
269
- // $imageUrl = $p['image_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
270
- // 'catalog/product/'.preg_replace('/^\//', '', $imageFile);
271
- $imageUrl = $p['image_url'] = $product->getMediaConfig()->getMediaUrl($imageFile);
272
- $imageLocalPath = $product->getMediaConfig()->getMediaPath($imageFile);
273
- }
274
- $productUrl = $product->getProductUrl().'#'.implode('&', $urlHashParts);
275
- }
276
- else
277
- {
278
- $p['internal_variant_id'] = '';
279
- $title = $data['name'];
280
- $sku = $data['sku'];
281
-
282
-
283
- if ($product->getTypeId() == 'bundle')
284
- {
285
- /**
286
- * @var $priceModel Mage_Bundle_Model_Product_Price
287
- */
288
- $priceModel = $product->getPriceModel();
289
-
290
- list($price, $_maximalPriceTax) = $priceModel->getTotalPrices($product, null, null, false);
291
- list($priceInclTax, $_maximalPriceInclTax) = $priceModel->getTotalPrices($product, null, true, false);
292
- }
293
- else
294
- {
295
- $price = $product->getPrice();
296
- }
297
-
298
- $salePrice = $product->getSpecialPrice();
299
-
300
- $imageFile = $product->getImage();
301
- // $imageUrl = $p['image_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
302
- // 'catalog/product/'.preg_replace('/^\//', '', $imageFile);
303
- $imageUrl = $p['image_url'] = $product->getMediaConfig()->getMediaUrl($imageFile);
304
- $imageLocalPath = $product->getMediaConfig()->getMediaPath($imageFile);
305
- $productUrl = $product->getProductUrl();
306
- }
307
-
308
- //if we have previously captured this product and it hasn't changed, don't send through full payload
309
- $wasPreviouslyCaptured = !is_null($lastUpdate) && isset($usefulAttributes['updated_at']) && strtotime($usefulAttributes['updated_at']) < $lastUpdate;
310
- if ($wasPreviouslyCaptured)
311
- {
312
- $p['internal_id'] = $product->getId();
313
- $p['internal_update_time'] = date("c", strtotime($usefulAttributes['updated_at']));
314
- }
315
- else
316
- {
317
- $p['category'] = $categoryPathToUse;
318
- $p['category_url'] = $lastCatUrl;
319
- $p['title'] = $title;
320
- $p['brand'] = ($brand=='No') ? (($manufacturer == 'No') ? '' : $manufacturer) : $brand;
321
- $p['manufacturer'] = ($manufacturer=='No') ? $brand : $manufacturer;
322
- $p['mpn'] = isset($data['model']) ? $data['model'] : $data['sku'];
323
- $p['internal_id'] = $product->getId();
324
- $p['description'] = $data['description'];
325
- $p['short_description'] = $data['short_description'];
326
- $p['weight'] = isset($data['weight']) ? $data['weight'] : 0.00;
327
- $p['sku'] = $sku;
328
- $p['gtin'] = '';
329
-
330
- //$priceModel = $product->getPriceModel();
331
-
332
- //do a currency conversion. if the currency is in base currency, it will be 1.0
333
- $price = $price * $priceCurrencyRate;
334
- $salePrice = $salePrice * $priceCurrencyRate;
335
-
336
- $p['currency'] = $priceCurrency;
337
- $p['price'] = $price;// Mage::helper('checkout')->convertPrice($priceModel->getPrice($product), false);
338
- $p['sale_price'] = '';
339
- $p['sale_price_effective_date'] = '';
340
- if ($salePrice != $p['price'])
341
- {
342
- $p['sale_price'] = $salePrice;
343
- if ($product->getSpecialFromDate()!=null && $product->getSpecialToDate()!=null)
344
- {
345
- $p['sale_price_effective_date'] = date("c", strtotime(date("Y-m-d 23:59:59", strtotime($product->getSpecialFromDate())))).'/'.date("c", strtotime(date("Y-m-d 23:59:59", strtotime($product->getSpecialToDate()))));
346
- }
347
- }
348
-
349
- $p['delivery_cost'] = 0.00;
350
- $p['tax'] = 0.00;
351
- $p['url'] = $productUrl;
352
- $p['internal_update_time'] = isset($usefulAttributes['updated_at']) ? date("c", strtotime($usefulAttributes['updated_at'])) : '';
353
-
354
- $p['image_url'] = $imageUrl;
355
- if (file_exists($imageLocalPath))
356
- {
357
- $p['image_modified_time'] = date("c", filemtime($imageLocalPath));
358
- }
359
- $p['availability'] = ($stockItem->getIsInStock())?'in stock':'out of stock';
360
- $p['quantity'] = $stockItem->getQty();
361
- $p['condition'] = '';
362
- $p['availability_date'] = '';
363
- $p['attributes'] = $usefulAttributes;
364
- $imageGallery = array();
365
- foreach ($product->getMediaGalleryImages() as $image)
366
- {
367
- $galleryImage = array();
368
- $galleryImage['url'] = $image['url'];
369
- if (file_exists($image['path']))
370
- {
371
- $galleryImage['image_modified_time'] = date("c", filemtime($image['path']));
372
- }
373
- $imageGallery[] = $galleryImage;
374
- }
375
- $p['extra_images'] = $imageGallery;
376
- }
377
-
378
- return $p;
379
- }
380
-
381
- public function getItems($page = null, $numPerPage = 1000, $lastUpdate = null, $store = null, $priceCurrency = null, $priceCurrencyRate = null, $allowVariants = true)
382
- {
383
- /* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection */
384
- $collection = Mage::getModel('catalog/product')->getCollection()
385
- ->addAttributeToSelect('*')
386
- ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
387
- ->addAttributeToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
388
-
389
- /**
390
- * For per-store system
391
- */
392
- if (!is_null($store))
393
- {
394
- $collection->addStoreFilter(Mage::app()->getStore($store)->getId());
395
- }
396
-
397
- if (!is_null($page))
398
- {
399
- $offset = ($page * $numPerPage) - $numPerPage;
400
- $productIds = $collection->getAllIds($numPerPage, $offset);
401
- }
402
- else
403
- {
404
- $productIds = $collection->getAllIds();
405
- }
406
-
407
- $products = array();
408
- foreach ($productIds as $productId)
409
- {
410
- Mage::getModel('catalog/product')->reset();
411
- /** @var Mage_Catalog_Model_Product $product */
412
- $product = Mage::getModel('catalog/product')->load($productId);
413
-
414
- /**
415
- * Get variants, if there are any
416
- * If there are variants that are visible in the catalog, we will skip them when we iterate normally
417
- */
418
-
419
- //if we have a configurable product, capture the variants
420
- if ($product->getTypeId() == 'configurable' && $allowVariants)
421
- {
422
- /** @var Mage_Catalog_Model_Product_Type_Configurable $configModel */
423
- $configModel = Mage::getModel('catalog/product_type_configurable');
424
-
425
- // $timeStart = microtime(true);
426
- // $children = $configModel->getChildrenIds($product->getId());
427
- // $children = array_pop($children);
428
- // var_dump("Time for GetIDs: ".(microtime(true) - $timeStart));
429
-
430
- $timeStart = microtime(true);
431
- $children = Mage::getResourceSingleton('catalog/product_type_configurable')
432
- ->getChildrenIds($product->getId());
433
- // var_dump("Time for GetIDs 2: ".(microtime(true) - $timeStart));
434
- $children = array_pop($children);
435
- // var_dump($children);
436
-
437
- // $timeStart = microtime(true);
438
- // $children = $configModel->getUsedProducts(null,$product);
439
- // var_dump("Time for GetUsed: ".(microtime(true) - $timeStart));
440
- // exit();
441
-
442
- if (count($children) > 0)
443
- {
444
- $parent = $product;
445
-
446
- //get variant options
447
- $layout = Mage::getSingleton('core/layout');
448
- $block = $layout->createBlock('catalog/product_view_type_configurable');
449
- $block->setProduct($parent);
450
- $variantOptions = Mage::helper('core')->jsonDecode($block->getJsonConfig());
451
-
452
- $variantAttributes = array();
453
- foreach ($variantOptions['attributes'] as $attributeId => $options)
454
- {
455
- $code = $options['code'];
456
- foreach ($options['options'] as $option)
457
- {
458
- $value = $option['label'];
459
- $price = @$option['price'];
460
- $valueId = $option['id'];
461
- foreach ($option['products'] as $productId)
462
- {
463
- //$children[] = $productId;
464
- $variantAttributes[$productId][$code]['value'] = $value;
465
- $variantAttributes[$productId][$code]['price'] = $price;
466
- $variantAttributes[$productId][$code]['valueId'] = $valueId;
467
- $variantAttributes[$productId][$code]['attributeId'] = $attributeId;
468
- }
469
- }
470
- }
471
- $variantOptions['refactoredOptions'] = $variantAttributes;
472
-
473
-
474
- foreach ($children as $variantId)
475
- {
476
- /** @var Mage_Catalog_Model_Product $variant */
477
- $variant = Mage::getModel('catalog/product')->load($variantId);
478
-
479
- $productData = $this->getProductInfo($variant, $parent, $variantOptions, $lastUpdate, $priceCurrency, $priceCurrencyRate);
480
- if (!empty($productData))
481
- {
482
- $products[] = $productData;
483
- }
484
- }
485
- }
486
- }
487
- else
488
- {
489
- $productData = $this->getProductInfo($product, null, null, $lastUpdate, $priceCurrency, $priceCurrencyRate);
490
- if (!empty($productData))
491
- {
492
- $products[] = $productData;
493
- }
494
- }
495
- }
496
-
497
- return $products;
498
- }
499
-
500
- public function getItem($itemId, $store = null, $priceCurrency = null, $priceCurrencyRate = null)
501
- {
502
- $products = array();
503
-
504
- $product = Mage::getModel('catalog/product')->load($itemId);
505
-
506
- $products[] = $this->getProductInfo($product, null, null, null, $priceCurrency, $priceCurrencyRate);
507
-
508
- return $products;
509
- }
510
-
511
- public function getStockQuantity($itemId, $store = null)
512
- {
513
- $product = Mage::getModel('catalog/product')->load($itemId);
514
-
515
- /* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
516
- $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
517
-
518
- return $stockItem->getQty();
519
- }
520
  }
1
+ <?php
2
+
3
+ class ShoppingFeeder_Service_Model_Offers extends Mage_Core_Model_Abstract
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_init('shoppingfeeder_service/offers');
8
+ }
9
+
10
+ private function hasParent($product)
11
+ {
12
+ $parents = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
13
+ return !empty($parents);
14
+ }
15
+
16
+ private function getProductInfo(Mage_Catalog_Model_Product $product, Mage_Catalog_Model_Product $parent = null, $variantOptions = null, $lastUpdate = null, $priceCurrency, $priceCurrencyRate)
17
+ {
18
+ /** @var Mage_Catalog_Model_Product_Type_Configurable $configModel */
19
+ $configModel = Mage::getModel('catalog/product_type_configurable');
20
+
21
+ $p = array();
22
+
23
+ $isVariant = !is_null($parent);
24
+
25
+ /**
26
+ * We only want to pull variants (children of configurable products) that are children, not as standalone products
27
+ */
28
+ //if this product's parent is visible in catalog and search, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
29
+ //we will find this product when we fetch all the children of this parent through a normal iteration, so return nothing
30
+ if (!$isVariant && $this->hasParent($product))
31
+ {
32
+ return array();
33
+ }
34
+
35
+ if ($isVariant)
36
+ {
37
+ $variant = $product;
38
+ $product = $parent;
39
+ }
40
+
41
+ $data = $product->getData();
42
+
43
+ /* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
44
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
45
+
46
+ $attributes = $product->getAttributes();
47
+
48
+ $manufacturer = '';
49
+ $brand = '';
50
+
51
+ $usefulAttributes = array();
52
+
53
+ /**
54
+ * @var Mage_Eav_Model_Entity_Attribute_Abstract $attribute
55
+ */
56
+ // var_dump("");
57
+ // var_dump("");
58
+ // var_dump("");
59
+ foreach ($attributes as $attribute)
60
+ {
61
+ $attributeCode = $attribute->getAttributeCode();
62
+ $attributeLabel = $attribute->getData('frontend_label');
63
+
64
+ if ($isVariant)
65
+ {
66
+ $value = $attribute->getFrontend()->getValue($variant);
67
+ }
68
+ else
69
+ {
70
+ $value = $attribute->getFrontend()->getValue($product);
71
+ }
72
+
73
+ // var_dump($attributeCode. ' : '.print_r($value, true));
74
+ // var_dump($attributeLabel. ' : '.print_r($value, true));
75
+
76
+ if (preg_match('/^manufacturer$/i', $attributeCode) || preg_match('/^manufacturer$/i', $attributeLabel))
77
+ {
78
+ $manufacturer = $value;
79
+ }
80
+
81
+ if (preg_match('/^brand$/i', $attributeCode) || preg_match('/^brand$/i', $attributeLabel))
82
+ {
83
+ $brand = $value;
84
+ }
85
+
86
+ /*
87
+ if (preg_match('/age/i', $attributeCode) || preg_match('/age/i', $attributeLabel))
88
+ {
89
+ $usefulAttributes['age'] = $value;
90
+ }
91
+ if (preg_match('/color|colour/i', $attributeCode) || preg_match('/color|colour/i', $attributeLabel))
92
+ {
93
+ $usefulAttributes['colour'] = $value;
94
+ }
95
+ if (preg_match('/size/i', $attributeCode) || preg_match('/size/i', $attributeLabel))
96
+ {
97
+ $usefulAttributes['size'] = $value;
98
+ }
99
+ if (preg_match('/gender|sex/i', $attributeCode) || preg_match('/gender|sex/i', $attributeLabel))
100
+ {
101
+ $usefulAttributes['gender'] = $value;
102
+ }
103
+ if (preg_match('/material/i', $attributeCode) || preg_match('/material/i', $attributeLabel))
104
+ {
105
+ $usefulAttributes['material'] = $value;
106
+ }
107
+ if (preg_match('/pattern/i', $attributeCode) || preg_match('/pattern/i', $attributeLabel))
108
+ {
109
+ $usefulAttributes['pattern'] = $value;
110
+ }
111
+ */
112
+
113
+ $attributeValue = $attribute->getFrontend()->getValue($product);
114
+ //don't deal with arrays
115
+ if (!is_array($attributeValue))
116
+ {
117
+ if (!is_null($product->getData($attributeCode)) && ((string)$attributeValue != ''))
118
+ {
119
+ $usefulAttributes[$attributeCode] = $value;
120
+ }
121
+ }
122
+ }
123
+ // exit();
124
+
125
+ //category path
126
+ $categories = $product->getCategoryIds();
127
+
128
+ $categoryPathsToEvaluate = array();
129
+ $maxDepth = 0;
130
+ $categoryPathToUse = '';
131
+
132
+ $storeRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
133
+ $storeRootCategoryName = Mage::getModel('catalog/category')->load($storeRootCategoryId)->getName();
134
+
135
+ $lastCatUrl = null;
136
+ if (!empty($categories))
137
+ {
138
+ /** @var Mage_Catalog_Model_Resource_Category_Collection $categoryCollection */
139
+ $categoryCollection = $product->getCategoryCollection()->addAttributeToSelect('name');
140
+
141
+ $depth = 0;
142
+ foreach($categoryCollection as $cat1){
143
+ $pathIds = explode('/', $cat1->getPath());
144
+ unset($pathIds[0]);
145
+
146
+ $collection = Mage::getModel('catalog/category')->getCollection()
147
+ ->setStoreId(Mage::app()->getStore()->getId())
148
+ ->addAttributeToSelect('name')
149
+ ->addAttributeToSelect('is_active')
150
+ ->addFieldToFilter('entity_id', array('in' => $pathIds))
151
+ ->addUrlRewriteToResult();
152
+
153
+ $pathByName = array();
154
+ /** @var Mage_Catalog_Model_Category $cat */
155
+ foreach($collection as $cat){
156
+ if ($cat->getName() != $storeRootCategoryName)
157
+ {
158
+ $pathByName[] = $cat->getName();
159
+
160
+ //try get the category URL
161
+ try {
162
+ $lastCatUrl = $cat->getUrl();
163
+ }
164
+ catch (Exception $e) {
165
+
166
+ }
167
+ }
168
+ }
169
+
170
+ //take the longest (generally more detailed) path
171
+ $thisDepth = count($pathByName);
172
+ if ($thisDepth > $depth)
173
+ {
174
+ $depth = $thisDepth;
175
+ $categoryPathToUse = implode(' > ', $pathByName);
176
+ }
177
+ }
178
+
179
+ // //we will get all the category paths and then use the most refined, deepest one
180
+ // foreach ($categories as $rootCategoryId)
181
+ // {
182
+ // $depth = 0;
183
+ // $category_path = '';
184
+ //
185
+ // $mageCategoryPath = Mage::getModel('catalog/category')->load($rootCategoryId)->getPath();
186
+ // $allCategoryIds = explode('/', $mageCategoryPath);
187
+ // unset($allCategoryIds[0]);
188
+ //
189
+ // $categoryPath = '';
190
+ // /**
191
+ // * @var Mage_Catalog_Model_Category $category
192
+ // */
193
+ // foreach ($allCategoryIds as $categoryId)
194
+ // {
195
+ // $depth++;
196
+ // $category = Mage::getModel('catalog/category')->load($categoryId);
197
+ // $category_name = $category->getName();
198
+ // if ($category_name != $storeRootCategoryName)
199
+ // {
200
+ // if (!empty($categoryPath))
201
+ // {
202
+ // $categoryPath.= ' > ';
203
+ // }
204
+ // $categoryPath.= $category_name;
205
+ // }
206
+ // }
207
+ //
208
+ // $categoryPathsToEvaluate[$rootCategoryId]['path'] = $categoryPath;
209
+ // $categoryPathsToEvaluate[$rootCategoryId]['depth'] = $depth;
210
+ //
211
+ // if ($maxDepth < $depth)
212
+ // {
213
+ // $maxDepth = $depth;
214
+ // $categoryPathToUse = $categoryPath;
215
+ // }
216
+ // }
217
+ }
218
+
219
+ if ($isVariant && isset($variant))
220
+ {
221
+ // var_dump($usefulAttributes);
222
+ $p['internal_variant_id'] = $variant->getId();
223
+
224
+ $variantOptionsTitle = array();
225
+ $variantPrice = $variantOptions['basePrice'];
226
+
227
+ $urlHashParts = array();
228
+
229
+ // Collect options applicable to the configurable product
230
+ if (isset($variantOptions['refactoredOptions'][$variant->getId()]))
231
+ {
232
+ foreach ($variantOptions['refactoredOptions'][$variant->getId()] as $attributeCode => $option) {
233
+ $variantOptionsTitle[] = $option['value'];
234
+
235
+ //add these configured attributes to the set of parent's attributes
236
+ $usefulAttributes[$attributeCode] = $option['value'];
237
+
238
+ if (is_null($option['price']))
239
+ {
240
+ $variantPrice = $variant->getPrice();
241
+ }
242
+ else
243
+ {
244
+ $variantPrice += $option['price'];
245
+ }
246
+
247
+ $urlHashParts[] = $option['attributeId'].'='.$option['valueId'];
248
+ }
249
+ }
250
+
251
+ $variantOptionsTitle = implode(' / ', $variantOptionsTitle);
252
+ $title = $data['name'] . ' - ' . $variantOptionsTitle;
253
+ $sku = $variant->getData('sku');
254
+ $price = $variantPrice;
255
+ $salePrice = $variant->getSpecialPrice();
256
+ $variantImage = $variant->getImage();
257
+
258
+ if (!is_null($variantImage) && !empty($variantImage) && $variantImage!='no_selection')
259
+ {
260
+ $imageFile = $variant->getImage();
261
+ // $imageUrl = $p['image_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
262
+ // 'catalog/product/'.preg_replace('/^\//', '', $imageFile);
263
+ $imageUrl = $p['image_url'] = $variant->getMediaConfig()->getMediaUrl($imageFile);
264
+ $imageLocalPath = $variant->getMediaConfig()->getMediaPath($imageFile);
265
+ }
266
+ else
267
+ {
268
+ $imageFile = $product->getImage();
269
+ // $imageUrl = $p['image_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
270
+ // 'catalog/product/'.preg_replace('/^\//', '', $imageFile);
271
+ $imageUrl = $p['image_url'] = $product->getMediaConfig()->getMediaUrl($imageFile);
272
+ $imageLocalPath = $product->getMediaConfig()->getMediaPath($imageFile);
273
+ }
274
+ $productUrl = $product->getProductUrl().'#'.implode('&', $urlHashParts);
275
+ }
276
+ else
277
+ {
278
+ $p['internal_variant_id'] = '';
279
+ $title = $data['name'];
280
+ $sku = $data['sku'];
281
+
282
+
283
+ if ($product->getTypeId() == 'bundle')
284
+ {
285
+ /**
286
+ * @var $priceModel Mage_Bundle_Model_Product_Price
287
+ */
288
+ $priceModel = $product->getPriceModel();
289
+
290
+ list($price, $_maximalPriceTax) = $priceModel->getTotalPrices($product, null, null, false);
291
+ list($priceInclTax, $_maximalPriceInclTax) = $priceModel->getTotalPrices($product, null, true, false);
292
+ }
293
+ else
294
+ {
295
+ $price = $product->getPrice();
296
+ }
297
+
298
+ $salePrice = $product->getSpecialPrice();
299
+
300
+ $imageFile = $product->getImage();
301
+ // $imageUrl = $p['image_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
302
+ // 'catalog/product/'.preg_replace('/^\//', '', $imageFile);
303
+ $imageUrl = $p['image_url'] = $product->getMediaConfig()->getMediaUrl($imageFile);
304
+ $imageLocalPath = $product->getMediaConfig()->getMediaPath($imageFile);
305
+ $productUrl = $product->getProductUrl();
306
+ }
307
+
308
+ //if we have previously captured this product and it hasn't changed, don't send through full payload
309
+ $wasPreviouslyCaptured = !is_null($lastUpdate) && isset($usefulAttributes['updated_at']) && strtotime($usefulAttributes['updated_at']) < $lastUpdate;
310
+ if ($wasPreviouslyCaptured)
311
+ {
312
+ $p['internal_id'] = $product->getId();
313
+ $p['internal_update_time'] = date("c", strtotime($usefulAttributes['updated_at']));
314
+ }
315
+ else
316
+ {
317
+ $p['category'] = $categoryPathToUse;
318
+ $p['category_url'] = $lastCatUrl;
319
+ $p['title'] = $title;
320
+ $p['brand'] = ($brand=='No') ? (($manufacturer == 'No') ? '' : $manufacturer) : $brand;
321
+ $p['manufacturer'] = ($manufacturer=='No') ? $brand : $manufacturer;
322
+ $p['mpn'] = isset($data['model']) ? $data['model'] : $data['sku'];
323
+ $p['internal_id'] = $product->getId();
324
+ $p['description'] = $data['description'];
325
+ $p['short_description'] = $data['short_description'];
326
+ $p['weight'] = isset($data['weight']) ? $data['weight'] : 0.00;
327
+ $p['sku'] = $sku;
328
+ $p['gtin'] = '';
329
+
330
+ //$priceModel = $product->getPriceModel();
331
+
332
+ //do a currency conversion. if the currency is in base currency, it will be 1.0
333
+ $price = $price * $priceCurrencyRate;
334
+ $salePrice = $salePrice * $priceCurrencyRate;
335
+
336
+ $p['currency'] = $priceCurrency;
337
+ $p['price'] = $price;// Mage::helper('checkout')->convertPrice($priceModel->getPrice($product), false);
338
+ $p['sale_price'] = '';
339
+ $p['sale_price_effective_date'] = '';
340
+ if ($salePrice != $p['price'])
341
+ {
342
+ $p['sale_price'] = $salePrice;
343
+ if ($product->getSpecialFromDate()!=null && $product->getSpecialToDate()!=null)
344
+ {
345
+ $p['sale_price_effective_date'] = date("c", strtotime(date("Y-m-d 00:00:00", strtotime($product->getSpecialFromDate())))).'/'.date("c", strtotime(date("Y-m-d 23:59:59", strtotime($product->getSpecialToDate()))));
346
+ }
347
+ }
348
+
349
+ $p['delivery_cost'] = 0.00;
350
+ $p['tax'] = 0.00;
351
+ $p['url'] = $productUrl;
352
+ $p['internal_update_time'] = isset($usefulAttributes['updated_at']) ? date("c", strtotime($usefulAttributes['updated_at'])) : '';
353
+
354
+ $p['image_url'] = $imageUrl;
355
+ if (file_exists($imageLocalPath))
356
+ {
357
+ $p['image_modified_time'] = date("c", filemtime($imageLocalPath));
358
+ }
359
+ $p['availability'] = ($stockItem->getIsInStock())?'in stock':'out of stock';
360
+ $p['quantity'] = $stockItem->getQty();
361
+ $p['condition'] = '';
362
+ $p['availability_date'] = '';
363
+ $p['attributes'] = $usefulAttributes;
364
+ $imageGallery = array();
365
+ foreach ($product->getMediaGalleryImages() as $image)
366
+ {
367
+ $galleryImage = array();
368
+ $galleryImage['url'] = $image['url'];
369
+ if (file_exists($image['path']))
370
+ {
371
+ $galleryImage['image_modified_time'] = date("c", filemtime($image['path']));
372
+ }
373
+ $imageGallery[] = $galleryImage;
374
+ }
375
+ $p['extra_images'] = $imageGallery;
376
+ }
377
+
378
+ return $p;
379
+ }
380
+
381
+ public function getItems($page = null, $numPerPage = 1000, $lastUpdate = null, $store = null, $priceCurrency = null, $priceCurrencyRate = null, $allowVariants = true)
382
+ {
383
+ /* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection */
384
+ $collection = Mage::getModel('catalog/product')->getCollection()
385
+ ->addAttributeToSelect('*')
386
+ ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
387
+ ->addAttributeToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
388
+
389
+ /**
390
+ * For per-store system
391
+ */
392
+ if (!is_null($store))
393
+ {
394
+ $collection->addStoreFilter(Mage::app()->getStore($store)->getId());
395
+ }
396
+
397
+ if (!is_null($page))
398
+ {
399
+ $offset = ($page * $numPerPage) - $numPerPage;
400
+ $productIds = $collection->getAllIds($numPerPage, $offset);
401
+ }
402
+ else
403
+ {
404
+ $productIds = $collection->getAllIds();
405
+ }
406
+
407
+ $products = array();
408
+ foreach ($productIds as $productId)
409
+ {
410
+ Mage::getModel('catalog/product')->reset();
411
+ /** @var Mage_Catalog_Model_Product $product */
412
+ $product = Mage::getModel('catalog/product')->load($productId);
413
+
414
+ /**
415
+ * Get variants, if there are any
416
+ * If there are variants that are visible in the catalog, we will skip them when we iterate normally
417
+ */
418
+
419
+ //if we have a configurable product, capture the variants
420
+ if ($product->getTypeId() == 'configurable' && $allowVariants)
421
+ {
422
+ /** @var Mage_Catalog_Model_Product_Type_Configurable $configModel */
423
+ $configModel = Mage::getModel('catalog/product_type_configurable');
424
+
425
+ // $timeStart = microtime(true);
426
+ // $children = $configModel->getChildrenIds($product->getId());
427
+ // $children = array_pop($children);
428
+ // var_dump("Time for GetIDs: ".(microtime(true) - $timeStart));
429
+
430
+ $timeStart = microtime(true);
431
+ $children = Mage::getResourceSingleton('catalog/product_type_configurable')
432
+ ->getChildrenIds($product->getId());
433
+ // var_dump("Time for GetIDs 2: ".(microtime(true) - $timeStart));
434
+ $children = array_pop($children);
435
+ // var_dump($children);
436
+
437
+ // $timeStart = microtime(true);
438
+ // $children = $configModel->getUsedProducts(null,$product);
439
+ // var_dump("Time for GetUsed: ".(microtime(true) - $timeStart));
440
+ // exit();
441
+
442
+ if (count($children) > 0)
443
+ {
444
+ $parent = $product;
445
+
446
+ //get variant options
447
+ $layout = Mage::getSingleton('core/layout');
448
+ $block = $layout->createBlock('catalog/product_view_type_configurable');
449
+ $block->setProduct($parent);
450
+ $variantOptions = Mage::helper('core')->jsonDecode($block->getJsonConfig());
451
+
452
+ $variantAttributes = array();
453
+ foreach ($variantOptions['attributes'] as $attributeId => $options)
454
+ {
455
+ $code = $options['code'];
456
+ foreach ($options['options'] as $option)
457
+ {
458
+ $value = $option['label'];
459
+ $price = @$option['price'];
460
+ $valueId = $option['id'];
461
+ foreach ($option['products'] as $productId)
462
+ {
463
+ //$children[] = $productId;
464
+ $variantAttributes[$productId][$code]['value'] = $value;
465
+ $variantAttributes[$productId][$code]['price'] = $price;
466
+ $variantAttributes[$productId][$code]['valueId'] = $valueId;
467
+ $variantAttributes[$productId][$code]['attributeId'] = $attributeId;
468
+ }
469
+ }
470
+ }
471
+ $variantOptions['refactoredOptions'] = $variantAttributes;
472
+
473
+
474
+ foreach ($children as $variantId)
475
+ {
476
+ /** @var Mage_Catalog_Model_Product $variant */
477
+ $variant = Mage::getModel('catalog/product')->load($variantId);
478
+
479
+ $productData = $this->getProductInfo($variant, $parent, $variantOptions, $lastUpdate, $priceCurrency, $priceCurrencyRate);
480
+ if (!empty($productData))
481
+ {
482
+ $products[] = $productData;
483
+ }
484
+ }
485
+ }
486
+ }
487
+ else
488
+ {
489
+ $productData = $this->getProductInfo($product, null, null, $lastUpdate, $priceCurrency, $priceCurrencyRate);
490
+ if (!empty($productData))
491
+ {
492
+ $products[] = $productData;
493
+ }
494
+ }
495
+ }
496
+
497
+ return $products;
498
+ }
499
+
500
+ public function getItem($itemId, $store = null, $priceCurrency = null, $priceCurrencyRate = null)
501
+ {
502
+ $products = array();
503
+
504
+ $product = Mage::getModel('catalog/product')->load($itemId);
505
+
506
+ $products[] = $this->getProductInfo($product, null, null, null, $priceCurrency, $priceCurrencyRate);
507
+
508
+ return $products;
509
+ }
510
+
511
+ public function getStockQuantity($itemId, $store = null)
512
+ {
513
+ $product = Mage::getModel('catalog/product')->load($itemId);
514
+
515
+ /* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
516
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
517
+
518
+ return $stockItem->getQty();
519
+ }
520
  }
app/code/community/ShoppingFeeder/Service/Model/Orders.php CHANGED
@@ -1,83 +1,83 @@
1
- <?php
2
-
3
- class ShoppingFeeder_Service_Model_Orders extends Mage_Core_Model_Abstract
4
- {
5
- public function __construct()
6
- {
7
- $this->_init('shoppingfeeder_service/orders');
8
- }
9
-
10
- private function getOrderInfo(Mage_Sales_Model_Order $order)
11
- {
12
- $data = array();
13
-
14
- $orderData = $order->getData();
15
-
16
- //normalise order data for ShoppingFeeder
17
- $data['order_id'] = $orderData['entity_id'];
18
- $data['order_date'] = $orderData['created_at'];
19
- $data['store_order_number'] = $orderData['increment_id'];
20
- $data['store_order_user_id'] = $orderData['customer_id'];
21
- $data['store_order_currency'] = $orderData['order_currency_code'];
22
- $data['store_total_price'] = $orderData['grand_total'];
23
- $data['store_total_line_items_price'] = $orderData['subtotal_incl_tax'];
24
- $data['store_total_tax'] = $orderData['tax_amount'];
25
- $data['store_order_total_discount'] = $orderData['discount_amount'];
26
- $data['store_shipping_price'] = $orderData['shipping_incl_tax'];
27
-
28
- $lineItems = array();
29
- foreach($order->getAllItems() as $item)
30
- {
31
- $lineItems[] = $item->toArray();
32
- }
33
- $data['line_items'] = $lineItems;
34
-
35
- return $data;
36
- }
37
-
38
- public function getItems($page = null, $numPerPage = 1000, $store = null)
39
- {
40
- /* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection */
41
- $collection = Mage::getModel('sales/order')->getCollection()
42
- ->addAttributeToSelect('*')
43
- ->addAttributeToFilter('status', Mage_Sales_Model_Order::STATE_COMPLETE);
44
-
45
- /**
46
- * For per-store system
47
- */
48
- if (!is_null($store))
49
- {
50
- $collection->addAttributeToFilter('store_id', Mage::app()->getStore($store)->getId());
51
- }
52
-
53
- if (!is_null($page))
54
- {
55
- $offset = ($page * $numPerPage) - $numPerPage;
56
- $orderIds = $collection->getAllIds($numPerPage, $offset);
57
- }
58
- else
59
- {
60
- $orderIds = $collection->getAllIds();
61
- }
62
-
63
- $orders = array();
64
- /* @var Mage_Sales_Model_Order $order */
65
- foreach ($orderIds as $orderId)
66
- {
67
- $order = Mage::getModel('sales/order')->load($orderId);
68
-
69
- $orders[$order->getId()] = $this->getOrderInfo($order);
70
- }
71
- return $orders;
72
- }
73
-
74
- public function getItem($itemId, $store = null)
75
- {
76
- $orders = array();
77
-
78
- $order = Mage::getModel('sales/order')->load($itemId);
79
- $orders[$order->getId()] = $this->getOrderInfo($order);
80
-
81
- return $orders;
82
- }
83
  }
1
+ <?php
2
+
3
+ class ShoppingFeeder_Service_Model_Orders extends Mage_Core_Model_Abstract
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_init('shoppingfeeder_service/orders');
8
+ }
9
+
10
+ private function getOrderInfo(Mage_Sales_Model_Order $order)
11
+ {
12
+ $data = array();
13
+
14
+ $orderData = $order->getData();
15
+
16
+ //normalise order data for ShoppingFeeder
17
+ $data['order_id'] = $orderData['entity_id'];
18
+ $data['order_date'] = $orderData['created_at'];
19
+ $data['store_order_number'] = $orderData['increment_id'];
20
+ $data['store_order_user_id'] = $orderData['customer_id'];
21
+ $data['store_order_currency'] = $orderData['order_currency_code'];
22
+ $data['store_total_price'] = $orderData['grand_total'];
23
+ $data['store_total_line_items_price'] = $orderData['subtotal_incl_tax'];
24
+ $data['store_total_tax'] = $orderData['tax_amount'];
25
+ $data['store_order_total_discount'] = $orderData['discount_amount'];
26
+ $data['store_shipping_price'] = $orderData['shipping_incl_tax'];
27
+
28
+ $lineItems = array();
29
+ foreach($order->getAllItems() as $item)
30
+ {
31
+ $lineItems[] = $item->toArray();
32
+ }
33
+ $data['line_items'] = $lineItems;
34
+
35
+ return $data;
36
+ }
37
+
38
+ public function getItems($page = null, $numPerPage = 1000, $store = null)
39
+ {
40
+ /* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection */
41
+ $collection = Mage::getModel('sales/order')->getCollection()
42
+ ->addAttributeToSelect('*')
43
+ ->addAttributeToFilter('status', Mage_Sales_Model_Order::STATE_COMPLETE);
44
+
45
+ /**
46
+ * For per-store system
47
+ */
48
+ if (!is_null($store))
49
+ {
50
+ $collection->addAttributeToFilter('store_id', Mage::app()->getStore($store)->getId());
51
+ }
52
+
53
+ if (!is_null($page))
54
+ {
55
+ $offset = ($page * $numPerPage) - $numPerPage;
56
+ $orderIds = $collection->getAllIds($numPerPage, $offset);
57
+ }
58
+ else
59
+ {
60
+ $orderIds = $collection->getAllIds();
61
+ }
62
+
63
+ $orders = array();
64
+ /* @var Mage_Sales_Model_Order $order */
65
+ foreach ($orderIds as $orderId)
66
+ {
67
+ $order = Mage::getModel('sales/order')->load($orderId);
68
+
69
+ $orders[$order->getId()] = $this->getOrderInfo($order);
70
+ }
71
+ return $orders;
72
+ }
73
+
74
+ public function getItem($itemId, $store = null)
75
+ {
76
+ $orders = array();
77
+
78
+ $order = Mage::getModel('sales/order')->load($itemId);
79
+ $orders[$order->getId()] = $this->getOrderInfo($order);
80
+
81
+ return $orders;
82
+ }
83
  }
app/code/community/ShoppingFeeder/Service/controllers/AttributesController.php CHANGED
@@ -1,52 +1,52 @@
1
- <?php
2
-
3
- //IMPORTANT - "Controller" directory is not autoloaded
4
- require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
-
6
- class ShoppingFeeder_Service_AttributesController extends ShoppingFeeder_Service_Controller_FrontAuth
7
- {
8
- public function indexAction()
9
- {
10
- set_time_limit(0);
11
-
12
- $store = $this->getRequest()->getParam('store', null);
13
-
14
- /**
15
- * For per-store system
16
- */
17
- if (!is_null($store))
18
- {
19
- Mage::app()->setCurrentStore($store);
20
- }
21
- else
22
- {
23
- $defaultStoreCode = Mage::app()
24
- ->getWebsite(true)
25
- ->getDefaultGroup()
26
- ->getDefaultStore()
27
- ->getCode();
28
-
29
- Mage::app()->setCurrentStore($defaultStoreCode);
30
- }
31
-
32
- $internalAttributes = Mage::getResourceModel('catalog/product_attribute_collection')
33
- ->getItems();
34
-
35
- $attributes = array();
36
- foreach ($internalAttributes as $attribute){
37
- $attributes[$attribute->getAttributecode()] = $attribute->getFrontendLabel();
38
- }
39
-
40
- $responseData = array(
41
- 'status' => 'success',
42
- 'data' => array(
43
- 'attributes' => $attributes,
44
- 'store' => $store
45
- )
46
- );
47
-
48
- header('Content-type: application/json; charset=UTF-8');
49
- echo json_encode($responseData);
50
- exit();
51
- }
52
  }
1
+ <?php
2
+
3
+ //IMPORTANT - "Controller" directory is not autoloaded
4
+ require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
+
6
+ class ShoppingFeeder_Service_AttributesController extends ShoppingFeeder_Service_Controller_FrontAuth
7
+ {
8
+ public function indexAction()
9
+ {
10
+ set_time_limit(0);
11
+
12
+ $store = $this->getRequest()->getParam('store', null);
13
+
14
+ /**
15
+ * For per-store system
16
+ */
17
+ if (!is_null($store))
18
+ {
19
+ Mage::app()->setCurrentStore($store);
20
+ }
21
+ else
22
+ {
23
+ $defaultStoreCode = Mage::app()
24
+ ->getWebsite(true)
25
+ ->getDefaultGroup()
26
+ ->getDefaultStore()
27
+ ->getCode();
28
+
29
+ Mage::app()->setCurrentStore($defaultStoreCode);
30
+ }
31
+
32
+ $internalAttributes = Mage::getResourceModel('catalog/product_attribute_collection')
33
+ ->getItems();
34
+
35
+ $attributes = array();
36
+ foreach ($internalAttributes as $attribute){
37
+ $attributes[$attribute->getAttributecode()] = $attribute->getFrontendLabel();
38
+ }
39
+
40
+ $responseData = array(
41
+ 'status' => 'success',
42
+ 'data' => array(
43
+ 'attributes' => $attributes,
44
+ 'store' => $store
45
+ )
46
+ );
47
+
48
+ header('Content-type: application/json; charset=UTF-8');
49
+ echo json_encode($responseData);
50
+ exit();
51
+ }
52
  }
app/code/community/ShoppingFeeder/Service/controllers/FeedController.php CHANGED
@@ -1,127 +1,127 @@
1
- <?php
2
-
3
- //IMPORTANT - "Controller" directory is not autoloaded
4
- require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
-
6
- class ShoppingFeeder_Service_FeedController extends ShoppingFeeder_Service_Controller_FrontAuth
7
- {
8
- public function indexAction()
9
- {
10
- set_time_limit(0);
11
-
12
- /** @var ShoppingFeeder_Service_Model_Offers $offersModel */
13
- $offersModel = Mage::getSingleton('shoppingfeeder_service/offers');
14
-
15
- $page = $this->getRequest()->getParam('page', null);
16
- $numPerPage = $this->getRequest()->getParam('num_per_page', 1000);
17
- $offerId = $this->getRequest()->getParam('offer_id', null);
18
- $lastUpdate = $this->getRequest()->getParam('last_update', null);
19
- $store = $this->getRequest()->getParam('store', null);
20
- $currency = $this->getRequest()->getParam('currency', null);
21
- $allowVariants = (intval($this->getRequest()->getParam('allow_variants', 1)) == 1) ? true : false;
22
-
23
- /**
24
- * For per-store system
25
- */
26
- if (!is_null($store))
27
- {
28
- Mage::app()->setCurrentStore($store);
29
- }
30
- else
31
- {
32
- $defaultStoreCode = Mage::app()
33
- ->getWebsite(true)
34
- ->getDefaultGroup()
35
- ->getDefaultStore()
36
- ->getCode();
37
-
38
- Mage::app()->setCurrentStore($defaultStoreCode);
39
- }
40
-
41
- $baseCurrency = Mage::app()->getStore()->getBaseCurrencyCode();
42
- $priceCurrency = (is_null($currency)) ? Mage::app()->getStore()->getDefaultCurrencyCode() : $currency;
43
- $priceCurrencyRate = Mage::helper('directory')->currencyConvert(1, $baseCurrency, $priceCurrency);
44
-
45
- if (is_null($offerId))
46
- {
47
- $offers = $offersModel->getItems($page, $numPerPage, $lastUpdate, $store, $priceCurrency, $priceCurrencyRate, $allowVariants);
48
- }
49
- else
50
- {
51
- $offers = $offersModel->getItem($offerId, $store, $priceCurrency, $priceCurrencyRate);
52
- }
53
-
54
- $responseData = array(
55
- 'status' => 'success',
56
- 'data' => array(
57
- 'page' => $page,
58
- 'num_per_page' => $numPerPage,
59
- 'offers' => $offers,
60
- 'store' => $store,
61
- 'base_currency' => $baseCurrency,
62
- 'price_currency' => $priceCurrency,
63
- 'exchange_Rate' => $priceCurrencyRate
64
- )
65
- );
66
-
67
- header('Content-type: application/json; charset=UTF-8');
68
- echo json_encode($responseData);
69
- exit();
70
- }
71
-
72
- /** Old XML version */
73
- /*
74
- public function indexAction()
75
- {
76
- set_time_limit(0);
77
-
78
- $offersModel = Mage::getSingleton('shoppingfeeder_service/offers');
79
-
80
- $page = $this->getRequest()->getParam('page', null);
81
- $numPerPage = $this->getRequest()->getParam('num_per_page', 1000);
82
-
83
- $offers = $offersModel->getItems($page, $numPerPage);
84
- header('Content-type: text/xml; charset=UTF-8');
85
- echo '<?xml version="1.0" encoding="UTF-8"?>';
86
- echo "\n".'<offers>';
87
- foreach ($offers as $offer) {
88
- echo "\n".'<offer>';
89
- echo "\n".'<category><![CDATA['.$offer['category'].']]></category>';
90
- echo "\n".'<title><![CDATA['.$offer['title'].']]></title>';
91
- echo "\n".'<brand><![CDATA['.$offer['manufacturer'].']]></brand>';
92
- echo "\n".'<manufacturer><![CDATA['.$offer['manufacturer'].']]></manufacturer>';
93
- echo "\n".'<mpn><![CDATA['.$offer['mpn'].']]></mpn>';
94
- echo "\n".'<sku><![CDATA['.$offer['sku'].']]></sku>';
95
- echo "\n".'<gtin>'.$offer['gtin'].'</gtin>';
96
- echo "\n".'<weight>'.$offer['weight'].'</weight>';
97
- echo "\n".'<internal_id><![CDATA['.$offer['internal_id'].']]></internal_id>';
98
- echo "\n".'<internal_variant_id><![CDATA['.$offer['internal_variant_id'].']]></internal_variant_id>';
99
- echo "\n".'<description><![CDATA['.$offer['description'].']]></description>';
100
- echo "\n".'<price>'.$offer['price'].'</price>';
101
- echo "\n".'<sale_price>'.$offer['sale_price'].'</sale_price>';
102
- echo "\n".'<sale_price_effective_date>'.$offer['sale_price_effective_date'].'</sale_price_effective_date>';
103
- echo "\n".'<delivery_cost>'.$offer['delivery_cost'].'</delivery_cost>';
104
- echo "\n".'<tax>'.$offer['tax'].'</tax>';
105
- echo "\n".'<url><![CDATA['.$offer['url'].']]></url>';
106
- echo "\n".'<image_url><![CDATA['.$offer['image_url'].']]></image_url>';
107
- echo "\n".'<quantity>'.$offer['quantity'].'</quantity>';
108
- echo "\n".'<condition>'.$offer['condition'].'</condition>';
109
- echo "\n".'<availability>'.$offer['availability'].'</availability>';
110
- echo "\n".'<availability_date>'.$offer['availability_date'].'</availability_date>';
111
- foreach ($offer['attributes'] as $attributeName => $attributeValue) {
112
- echo "\n".' <attribute name="'.htmlspecialchars($attributeName).'"><![CDATA['.$attributeValue.']]></attribute>';
113
- }
114
- foreach ($offer['extra_images'] as $imageUrl){
115
- echo "\n".' <additional_image_link><![CDATA['.$imageUrl.']]></additional_image_link>';
116
- }
117
- echo "\n".'</offer>';
118
-
119
- flush();
120
- ob_flush();
121
- }
122
- echo "\n".'</offers>';
123
-
124
- exit();
125
- }
126
- */
127
  }
1
+ <?php
2
+
3
+ //IMPORTANT - "Controller" directory is not autoloaded
4
+ require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
+
6
+ class ShoppingFeeder_Service_FeedController extends ShoppingFeeder_Service_Controller_FrontAuth
7
+ {
8
+ public function indexAction()
9
+ {
10
+ set_time_limit(0);
11
+
12
+ /** @var ShoppingFeeder_Service_Model_Offers $offersModel */
13
+ $offersModel = Mage::getSingleton('shoppingfeeder_service/offers');
14
+
15
+ $page = $this->getRequest()->getParam('page', null);
16
+ $numPerPage = $this->getRequest()->getParam('num_per_page', 1000);
17
+ $offerId = $this->getRequest()->getParam('offer_id', null);
18
+ $lastUpdate = $this->getRequest()->getParam('last_update', null);
19
+ $store = $this->getRequest()->getParam('store', null);
20
+ $currency = $this->getRequest()->getParam('currency', null);
21
+ $allowVariants = (intval($this->getRequest()->getParam('allow_variants', 1)) == 1) ? true : false;
22
+
23
+ /**
24
+ * For per-store system
25
+ */
26
+ if (!is_null($store))
27
+ {
28
+ Mage::app()->setCurrentStore($store);
29
+ }
30
+ else
31
+ {
32
+ $defaultStoreCode = Mage::app()
33
+ ->getWebsite(true)
34
+ ->getDefaultGroup()
35
+ ->getDefaultStore()
36
+ ->getCode();
37
+
38
+ Mage::app()->setCurrentStore($defaultStoreCode);
39
+ }
40
+
41
+ $baseCurrency = Mage::app()->getStore()->getBaseCurrencyCode();
42
+ $priceCurrency = (is_null($currency)) ? Mage::app()->getStore()->getDefaultCurrencyCode() : $currency;
43
+ $priceCurrencyRate = Mage::helper('directory')->currencyConvert(1, $baseCurrency, $priceCurrency);
44
+
45
+ if (is_null($offerId))
46
+ {
47
+ $offers = $offersModel->getItems($page, $numPerPage, $lastUpdate, $store, $priceCurrency, $priceCurrencyRate, $allowVariants);
48
+ }
49
+ else
50
+ {
51
+ $offers = $offersModel->getItem($offerId, $store, $priceCurrency, $priceCurrencyRate);
52
+ }
53
+
54
+ $responseData = array(
55
+ 'status' => 'success',
56
+ 'data' => array(
57
+ 'page' => $page,
58
+ 'num_per_page' => $numPerPage,
59
+ 'offers' => $offers,
60
+ 'store' => $store,
61
+ 'base_currency' => $baseCurrency,
62
+ 'price_currency' => $priceCurrency,
63
+ 'exchange_Rate' => $priceCurrencyRate
64
+ )
65
+ );
66
+
67
+ header('Content-type: application/json; charset=UTF-8');
68
+ echo json_encode($responseData);
69
+ exit();
70
+ }
71
+
72
+ /** Old XML version */
73
+ /*
74
+ public function indexAction()
75
+ {
76
+ set_time_limit(0);
77
+
78
+ $offersModel = Mage::getSingleton('shoppingfeeder_service/offers');
79
+
80
+ $page = $this->getRequest()->getParam('page', null);
81
+ $numPerPage = $this->getRequest()->getParam('num_per_page', 1000);
82
+
83
+ $offers = $offersModel->getItems($page, $numPerPage);
84
+ header('Content-type: text/xml; charset=UTF-8');
85
+ echo '<?xml version="1.0" encoding="UTF-8"?>';
86
+ echo "\n".'<offers>';
87
+ foreach ($offers as $offer) {
88
+ echo "\n".'<offer>';
89
+ echo "\n".'<category><![CDATA['.$offer['category'].']]></category>';
90
+ echo "\n".'<title><![CDATA['.$offer['title'].']]></title>';
91
+ echo "\n".'<brand><![CDATA['.$offer['manufacturer'].']]></brand>';
92
+ echo "\n".'<manufacturer><![CDATA['.$offer['manufacturer'].']]></manufacturer>';
93
+ echo "\n".'<mpn><![CDATA['.$offer['mpn'].']]></mpn>';
94
+ echo "\n".'<sku><![CDATA['.$offer['sku'].']]></sku>';
95
+ echo "\n".'<gtin>'.$offer['gtin'].'</gtin>';
96
+ echo "\n".'<weight>'.$offer['weight'].'</weight>';
97
+ echo "\n".'<internal_id><![CDATA['.$offer['internal_id'].']]></internal_id>';
98
+ echo "\n".'<internal_variant_id><![CDATA['.$offer['internal_variant_id'].']]></internal_variant_id>';
99
+ echo "\n".'<description><![CDATA['.$offer['description'].']]></description>';
100
+ echo "\n".'<price>'.$offer['price'].'</price>';
101
+ echo "\n".'<sale_price>'.$offer['sale_price'].'</sale_price>';
102
+ echo "\n".'<sale_price_effective_date>'.$offer['sale_price_effective_date'].'</sale_price_effective_date>';
103
+ echo "\n".'<delivery_cost>'.$offer['delivery_cost'].'</delivery_cost>';
104
+ echo "\n".'<tax>'.$offer['tax'].'</tax>';
105
+ echo "\n".'<url><![CDATA['.$offer['url'].']]></url>';
106
+ echo "\n".'<image_url><![CDATA['.$offer['image_url'].']]></image_url>';
107
+ echo "\n".'<quantity>'.$offer['quantity'].'</quantity>';
108
+ echo "\n".'<condition>'.$offer['condition'].'</condition>';
109
+ echo "\n".'<availability>'.$offer['availability'].'</availability>';
110
+ echo "\n".'<availability_date>'.$offer['availability_date'].'</availability_date>';
111
+ foreach ($offer['attributes'] as $attributeName => $attributeValue) {
112
+ echo "\n".' <attribute name="'.htmlspecialchars($attributeName).'"><![CDATA['.$attributeValue.']]></attribute>';
113
+ }
114
+ foreach ($offer['extra_images'] as $imageUrl){
115
+ echo "\n".' <additional_image_link><![CDATA['.$imageUrl.']]></additional_image_link>';
116
+ }
117
+ echo "\n".'</offer>';
118
+
119
+ flush();
120
+ ob_flush();
121
+ }
122
+ echo "\n".'</offers>';
123
+
124
+ exit();
125
+ }
126
+ */
127
  }
app/code/community/ShoppingFeeder/Service/controllers/OrdersController.php CHANGED
@@ -1,94 +1,94 @@
1
- <?php
2
-
3
- //IMPORTANT - "Controller" directory is not autoloaded
4
- require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
-
6
- class ShoppingFeeder_Service_OrdersController extends ShoppingFeeder_Service_Controller_FrontAuth
7
- {
8
- public function indexAction()
9
- {
10
- set_time_limit(0);
11
-
12
- /** @var ShoppingFeeder_Service_Model_Orders $ordersModel */
13
- $ordersModel = Mage::getSingleton('shoppingfeeder_service/orders');
14
-
15
- $page = $this->getRequest()->getParam('page', null);
16
- $numPerPage = $this->getRequest()->getParam('num_per_page', 1000);
17
- $orderId = $this->getRequest()->getParam('order_id', null);
18
- $store = $this->getRequest()->getParam('store', null);
19
-
20
- /**
21
- * For per-store system
22
- */
23
- if (!is_null($store))
24
- {
25
- Mage::app()->setCurrentStore($store);
26
- }
27
- else
28
- {
29
- $defaultStoreCode = Mage::app()
30
- ->getWebsite(true)
31
- ->getDefaultGroup()
32
- ->getDefaultStore()
33
- ->getCode();
34
-
35
- Mage::app()->setCurrentStore($defaultStoreCode);
36
- }
37
-
38
- if (is_null($orderId))
39
- {
40
- $orders = $ordersModel->getItems($page, $numPerPage, $store);
41
- }
42
- else
43
- {
44
- $orders = $ordersModel->getItem($orderId, $store);
45
- }
46
-
47
- $responseData = array(
48
- 'status' => 'success',
49
- 'data' => array(
50
- 'page' => $page,
51
- 'num_per_page' => $numPerPage,
52
- 'orders' => $orders,
53
- 'store' => $store
54
- )
55
- );
56
-
57
- header('Content-type: application/json; charset=UTF-8');
58
- echo json_encode($responseData);
59
- exit();
60
- }
61
-
62
- // public function createAction()
63
- // {
64
- // /** @var ShoppingFeeder_Service_Model_Orders $ordersModel */
65
- // $ordersModel = Mage::getSingleton('shoppingfeeder_service/orders');
66
- //
67
- // if ($this->getRequest()->getMethod() == Zend_Http_Client::POST)
68
- // {
69
- // //create the order
70
- // $order = $ordersModel->create();
71
- //
72
- //
73
- // $responseData = array(
74
- // 'status' => 'success',
75
- // 'data' => array(
76
- // 'order' => $order
77
- // )
78
- // );
79
- // }
80
- // else
81
- // {
82
- // $responseData = array(
83
- // 'status' => 'fail',
84
- // 'data' => array(
85
- // 'message' => 'HTTP method incorrect, must be POST'
86
- // )
87
- // );
88
- // }
89
- //
90
- // header('Content-type: application/json; charset=UTF-8');
91
- // echo json_encode($responseData);
92
- // exit();
93
- // }
94
  }
1
+ <?php
2
+
3
+ //IMPORTANT - "Controller" directory is not autoloaded
4
+ require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
+
6
+ class ShoppingFeeder_Service_OrdersController extends ShoppingFeeder_Service_Controller_FrontAuth
7
+ {
8
+ public function indexAction()
9
+ {
10
+ set_time_limit(0);
11
+
12
+ /** @var ShoppingFeeder_Service_Model_Orders $ordersModel */
13
+ $ordersModel = Mage::getSingleton('shoppingfeeder_service/orders');
14
+
15
+ $page = $this->getRequest()->getParam('page', null);
16
+ $numPerPage = $this->getRequest()->getParam('num_per_page', 1000);
17
+ $orderId = $this->getRequest()->getParam('order_id', null);
18
+ $store = $this->getRequest()->getParam('store', null);
19
+
20
+ /**
21
+ * For per-store system
22
+ */
23
+ if (!is_null($store))
24
+ {
25
+ Mage::app()->setCurrentStore($store);
26
+ }
27
+ else
28
+ {
29
+ $defaultStoreCode = Mage::app()
30
+ ->getWebsite(true)
31
+ ->getDefaultGroup()
32
+ ->getDefaultStore()
33
+ ->getCode();
34
+
35
+ Mage::app()->setCurrentStore($defaultStoreCode);
36
+ }
37
+
38
+ if (is_null($orderId))
39
+ {
40
+ $orders = $ordersModel->getItems($page, $numPerPage, $store);
41
+ }
42
+ else
43
+ {
44
+ $orders = $ordersModel->getItem($orderId, $store);
45
+ }
46
+
47
+ $responseData = array(
48
+ 'status' => 'success',
49
+ 'data' => array(
50
+ 'page' => $page,
51
+ 'num_per_page' => $numPerPage,
52
+ 'orders' => $orders,
53
+ 'store' => $store
54
+ )
55
+ );
56
+
57
+ header('Content-type: application/json; charset=UTF-8');
58
+ echo json_encode($responseData);
59
+ exit();
60
+ }
61
+
62
+ // public function createAction()
63
+ // {
64
+ // /** @var ShoppingFeeder_Service_Model_Orders $ordersModel */
65
+ // $ordersModel = Mage::getSingleton('shoppingfeeder_service/orders');
66
+ //
67
+ // if ($this->getRequest()->getMethod() == Zend_Http_Client::POST)
68
+ // {
69
+ // //create the order
70
+ // $order = $ordersModel->create();
71
+ //
72
+ //
73
+ // $responseData = array(
74
+ // 'status' => 'success',
75
+ // 'data' => array(
76
+ // 'order' => $order
77
+ // )
78
+ // );
79
+ // }
80
+ // else
81
+ // {
82
+ // $responseData = array(
83
+ // 'status' => 'fail',
84
+ // 'data' => array(
85
+ // 'message' => 'HTTP method incorrect, must be POST'
86
+ // )
87
+ // );
88
+ // }
89
+ //
90
+ // header('Content-type: application/json; charset=UTF-8');
91
+ // echo json_encode($responseData);
92
+ // exit();
93
+ // }
94
  }
app/code/community/ShoppingFeeder/Service/controllers/StockController.php CHANGED
@@ -1,31 +1,31 @@
1
- <?php
2
-
3
- //IMPORTANT - "Controller" directory is not autoloaded
4
- require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
-
6
- class ShoppingFeeder_Service_StockController extends ShoppingFeeder_Service_Controller_FrontAuth
7
- {
8
- public function indexAction()
9
- {
10
- set_time_limit(0);
11
-
12
- $offerId = $this->getRequest()->getParam('offer_id', null);
13
- $store = $this->getRequest()->getParam('store', null);
14
-
15
- /** @var ShoppingFeeder_Service_Model_Offers $offersModel */
16
- $offersModel = Mage::getSingleton('shoppingfeeder_service/offers');
17
-
18
- $stockQuantity = $offersModel->getStockQuantity($offerId, $store);
19
-
20
- $responseData = array(
21
- 'status' => 'success',
22
- 'data' => array(
23
- 'stock_quantity' => (int)$stockQuantity
24
- )
25
- );
26
-
27
- header('Content-type: application/json; charset=UTF-8');
28
- echo json_encode($responseData);
29
- exit();
30
- }
31
  }
1
+ <?php
2
+
3
+ //IMPORTANT - "Controller" directory is not autoloaded
4
+ require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
+
6
+ class ShoppingFeeder_Service_StockController extends ShoppingFeeder_Service_Controller_FrontAuth
7
+ {
8
+ public function indexAction()
9
+ {
10
+ set_time_limit(0);
11
+
12
+ $offerId = $this->getRequest()->getParam('offer_id', null);
13
+ $store = $this->getRequest()->getParam('store', null);
14
+
15
+ /** @var ShoppingFeeder_Service_Model_Offers $offersModel */
16
+ $offersModel = Mage::getSingleton('shoppingfeeder_service/offers');
17
+
18
+ $stockQuantity = $offersModel->getStockQuantity($offerId, $store);
19
+
20
+ $responseData = array(
21
+ 'status' => 'success',
22
+ 'data' => array(
23
+ 'stock_quantity' => (int)$stockQuantity
24
+ )
25
+ );
26
+
27
+ header('Content-type: application/json; charset=UTF-8');
28
+ echo json_encode($responseData);
29
+ exit();
30
+ }
31
  }
app/code/community/ShoppingFeeder/Service/controllers/StoresController.php CHANGED
@@ -1,32 +1,32 @@
1
- <?php
2
-
3
- //IMPORTANT - "Controller" directory is not autoloaded
4
- require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
-
6
- class ShoppingFeeder_Service_StoresController extends ShoppingFeeder_Service_Controller_FrontAuth
7
- {
8
- public function indexAction()
9
- {
10
- /** @var $websiteCollection Mage_Core_Model_Store */
11
- $storeCollection = Mage::getModel('core/store')->getCollection();
12
-
13
- $stores = array();
14
- foreach ($storeCollection as $store) {
15
- /** @var $store Mage_Core_Model_Store */
16
- $store->initConfigCache();
17
-
18
- $stores[$store->getCode()] = $store->getName();
19
- }
20
-
21
- $responseData = array(
22
- 'status' => 'success',
23
- 'data' => array(
24
- 'stores' => $stores
25
- )
26
- );
27
-
28
- header('Content-type: application/json; charset=UTF-8');
29
- echo json_encode($responseData);
30
- exit();
31
- }
32
  }
1
+ <?php
2
+
3
+ //IMPORTANT - "Controller" directory is not autoloaded
4
+ require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
+
6
+ class ShoppingFeeder_Service_StoresController extends ShoppingFeeder_Service_Controller_FrontAuth
7
+ {
8
+ public function indexAction()
9
+ {
10
+ /** @var $websiteCollection Mage_Core_Model_Store */
11
+ $storeCollection = Mage::getModel('core/store')->getCollection();
12
+
13
+ $stores = array();
14
+ foreach ($storeCollection as $store) {
15
+ /** @var $store Mage_Core_Model_Store */
16
+ $store->initConfigCache();
17
+
18
+ $stores[$store->getCode()] = $store->getName();
19
+ }
20
+
21
+ $responseData = array(
22
+ 'status' => 'success',
23
+ 'data' => array(
24
+ 'stores' => $stores
25
+ )
26
+ );
27
+
28
+ header('Content-type: application/json; charset=UTF-8');
29
+ echo json_encode($responseData);
30
+ exit();
31
+ }
32
  }
app/code/community/ShoppingFeeder/Service/controllers/TestController.php CHANGED
@@ -1,351 +1,351 @@
1
- <?php
2
-
3
- //IMPORTANT - "Controller" directory is not autoloaded
4
- require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
-
6
- class ShoppingFeeder_Service_TestController extends Mage_Core_Controller_Front_Action
7
- {
8
- public function indexAction()
9
- {
10
- $store = $this->getRequest()->getParam('store', null);
11
-
12
- /**
13
- * For per-store system
14
- */
15
- if (!is_null($store))
16
- {
17
- Mage::app()->setCurrentStore($store);
18
- }
19
- else
20
- {
21
- $defaultStoreCode = Mage::app()
22
- ->getWebsite(true)
23
- ->getDefaultGroup()
24
- ->getDefaultStore()
25
- ->getCode();
26
-
27
- Mage::app()->setCurrentStore($defaultStoreCode);
28
- }
29
-
30
- if (!function_exists('getallheaders'))
31
- {
32
- function getallheaders()
33
- {
34
- $headers = '';
35
- foreach ($_SERVER as $name => $value)
36
- {
37
- if (substr($name, 0, 5) == 'HTTP_')
38
- {
39
- $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
40
- }
41
- }
42
- return $headers;
43
- }
44
- }
45
-
46
- $requiresSsl = false;
47
-
48
- try
49
- {
50
-
51
- //try fetch the store
52
- if (!is_null($store))
53
- {
54
- /** @var $websiteCollection Mage_Core_Model_Store */
55
- $storeCollection = Mage::getModel('core/store')->getCollection();
56
-
57
- $stores = array();
58
- foreach ($storeCollection as $internalStore) {
59
- /** @var $internalStore Mage_Core_Model_Store */
60
- $internalStore->initConfigCache();
61
-
62
- $stores[$internalStore->getCode()] = $internalStore->getName();
63
- }
64
-
65
- if (!isset($stores[$store]))
66
- {
67
- throw new Exception('Multi-store store code is not valid');
68
- }
69
- }
70
-
71
- /** @var ShoppingFeeder_Service_Model_Auth $authModel */
72
- $authModel = Mage::getModel('shoppingfeeder_service/auth');
73
- //check if this setup requires SSL
74
- $sslInFront = Mage::getStoreConfig('web/secure/use_in_frontend');
75
- $requiresSsl = ($sslInFront == null) ? false : $sslInFront;
76
-
77
- $apiKeys = $authModel->getApiKeys();
78
-
79
- if (!isset($apiKeys['api_key']) || empty($apiKeys['api_key']))
80
- {
81
- throw new Exception('API key not setup.');
82
- }
83
-
84
- if (!isset($apiKeys['api_secret']) || empty($apiKeys['api_secret']))
85
- {
86
- throw new Exception('API secret not setup.');
87
- }
88
-
89
- $headers = getallheaders();
90
-
91
- $authResult = $authModel->auth(
92
- $headers,
93
- $this->getRequest()->getScheme(),
94
- $this->getRequest()->getMethod()
95
- );
96
-
97
- if ($authResult === true)
98
- {
99
- set_time_limit(0);
100
-
101
- $responseData = array(
102
- 'status' => 'success',
103
- 'data' => array(
104
- 'message' => 'Authorization OK',
105
- 'requires_ssl' => $requiresSsl
106
- )
107
- );
108
- }
109
- else
110
- {
111
- $responseData = array(
112
- 'status' => 'fail',
113
- 'data' => array (
114
- 'message' => 'Authorization failed: ['.$authResult.']',
115
- 'requires_ssl' => $requiresSsl
116
- )
117
- );
118
- }
119
- }
120
- catch (Exception $e)
121
- {
122
- $responseData = array(
123
- 'status' => 'fail',
124
- 'data' => array (
125
- 'message' => $e->getMessage(),
126
- 'requires_ssl' => $requiresSsl
127
- )
128
- );
129
- }
130
-
131
- header('Content-type: application/json; charset=UTF-8');
132
- echo json_encode($responseData);
133
- exit();
134
- }
135
-
136
- public function debugAction()
137
- {
138
- $store = $this->getRequest()->getParam('store', null);
139
-
140
- /**
141
- * For per-store system
142
- */
143
- if (!is_null($store))
144
- {
145
- Mage::app()->setCurrentStore($store);
146
- }
147
- else
148
- {
149
- $defaultStoreCode = Mage::app()
150
- ->getWebsite(true)
151
- ->getDefaultGroup()
152
- ->getDefaultStore()
153
- ->getCode();
154
-
155
- Mage::app()->setCurrentStore($defaultStoreCode);
156
- }
157
-
158
- if (function_exists('getallheaders'))
159
- {
160
- echo 'Function <b>getallheaders</b> <span style="color:green;">exists</span>'."<br>\n";
161
- try
162
- {
163
- $headers = getallheaders();
164
- echo 'Get headers succeeded: '.print_r($headers,true)."<br>\n";
165
- }
166
- catch (Exception $e)
167
- {
168
- echo 'Get headers failed: ['.$e->getMessage().']'."<br>\n";
169
- }
170
- }
171
- else
172
- {
173
- try
174
- {
175
- function getallheaders()
176
- {
177
- $headers = '';
178
- foreach ($_SERVER as $name => $value)
179
- {
180
- if (substr($name, 0, 5) == 'HTTP_')
181
- {
182
- $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
183
- }
184
- }
185
- return $headers;
186
- }
187
- echo 'Function <b>getallheaders</b> created'."<br>\n";
188
-
189
- try
190
- {
191
- $headers = getallheaders();
192
- echo 'Get headers succeeded: '.print_r($headers,true)."<br>\n";
193
- }
194
- catch (Exception $e)
195
- {
196
- echo 'Get headers failed: ['.$e->getMessage().']'."<br>\n";
197
- }
198
- }
199
- catch (Exception $e)
200
- {
201
- echo 'Function <b>getallheaders</b> could not be created'."<br>\n";
202
- }
203
- }
204
-
205
- if (function_exists('hash_hmac'))
206
- {
207
- echo 'Function <b>hash_hmac</b> <span style="color:green;">exists</span>'."<br>\n";
208
- }
209
- else
210
- {
211
- echo 'Function <b>hash_hmac</b> <span style="color:red;">does not exist</span>'."<br>\n";
212
- }
213
-
214
- if (function_exists('mhash'))
215
- {
216
- echo 'Function <b>mhash</b> <span style="color:green;">exists</span>'."<br>\n";
217
- }
218
- else
219
- {
220
- echo 'Function <b>mhash</b> <span style="color:red;">does not exist</span>'."<br>\n";
221
- }
222
-
223
- try
224
- {
225
- /** @var ShoppingFeeder_Service_Model_Auth $authModel */
226
- $authModel = Mage::getModel('shoppingfeeder_service/auth');
227
- echo '$authModel successfully instantiated'."<br>\n";
228
- }
229
- catch (Exception $e)
230
- {
231
- echo '$authModel could not be instantiated: ['.$e->getMessage().']'."<br>\n";
232
- }
233
-
234
-
235
- if (isset($authModel))
236
- {
237
- try
238
- {
239
- $apiKeys = $authModel->getApiKeys();
240
- //hide from view
241
- unset($apiKeys['api_secret']);
242
- echo 'API Keys successfully fetched: '.print_r($apiKeys, true)."<br>\n";
243
-
244
- try
245
- {
246
- $headers = getallheaders();
247
- $authResult = $authModel->auth(
248
- $headers,
249
- $this->getRequest()->getScheme(),
250
- $this->getRequest()->getMethod()
251
- );
252
- echo '$authresult successfully called: '.print_r($authResult,true)."<br>\n";
253
- }
254
- catch (Exception $e)
255
- {
256
- echo '$authresult could not be called: ['.$e->getMessage().']'."<br>\n";
257
- }
258
- }
259
- catch (Exception $e)
260
- {
261
- echo 'API Keys could not be fetched: ['.$e->getMessage().']'."<br>\n";
262
- }
263
- }
264
-
265
- try {
266
- $currency = $this->getRequest()->getParam('currency', null);
267
-
268
- $baseCurrency = Mage::app()->getStore()->getBaseCurrencyCode();
269
- $priceCurrency = (is_null($currency)) ? Mage::app()->getStore()->getDefaultCurrencyCode() : $currency;
270
- $priceCurrencyRate = Mage::helper('directory')->currencyConvert(1, $baseCurrency, $priceCurrency);
271
-
272
- echo 'Base currency <span style="color:green;">'.$baseCurrency.'</span>'."<br>\n";
273
- echo 'Price currency <span style="color:green;">'.$priceCurrency.'</span>'."<br>\n";
274
- echo 'Exchange rate '.$baseCurrency.'/'.$priceCurrency.' <span style="color:green;">'.$priceCurrencyRate.'</span>'."<br>\n";
275
- }
276
- catch (Exception $e)
277
- {
278
- echo '<span style="color:red;">could not</span> fetch currencies: ['.$e->getMessage().']'."<br>\n";
279
- }
280
-
281
- $offersModel = false;
282
- try {
283
- $offersModel = Mage::getSingleton('shoppingfeeder_service/offers');
284
- echo '$offersModel <span style="color:green;">successfully instantiated</span>'."<br>\n";
285
- }
286
- catch (Exception $e)
287
- {
288
- echo '$offersModel <span style="color:red;">could not</span> be instantiated: ['.$e->getMessage().']'."<br>\n";
289
-
290
- }
291
-
292
- $page = 1;
293
- $numPerPage = 1;
294
- $offers = false;
295
- if ($offersModel)
296
- {
297
- try {
298
- $page = 1;
299
- $numPerPage = 1;
300
-
301
- $offers = $offersModel->getItems($page, $numPerPage);
302
- echo 'Fetch 1 product successful'."<br>\n";
303
- }
304
- catch (Exception $e)
305
- {
306
- echo 'Fetch 1 product <span style="color:red;">NOT</span> successful: ['.$e->getMessage().']'."<br>\n";
307
-
308
- try {
309
- echo 'Trying to get $collection'."<br>\n";
310
- $collection = Mage::getModel('catalog/product')->getCollection()
311
- ->addAttributeToSelect('*')
312
- ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
313
- ->addAttributeToFilter('visibility', 4);
314
- echo '$collection <span style="color:green;">successfully instantiated</span>'."<br>\n";
315
- }
316
- catch (Exception $e)
317
- {
318
- echo '$collection <span style="color:red;">NOT</span> successful: ['.$e->getMessage().']'."<br>\n";
319
- }
320
- }
321
- }
322
-
323
- if ($offers)
324
- {
325
- try {
326
- $responseData = array(
327
- 'status' => 'success',
328
- 'data' => array(
329
- 'page' => $page,
330
- 'num_per_page' => $numPerPage,
331
- 'offers' => $offers
332
- )
333
- );
334
-
335
- echo json_encode($responseData);
336
- }
337
- catch (Exception $e)
338
- {
339
- echo 'Could not output JSON: ['.$e->getMessage().']'."<br>\n";
340
- }
341
- }
342
-
343
- exit();
344
- }
345
-
346
- public function debug2Action()
347
- {
348
- echo("DEBUG-DEBUG");
349
- exit();
350
- }
351
  }
1
+ <?php
2
+
3
+ //IMPORTANT - "Controller" directory is not autoloaded
4
+ require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
+
6
+ class ShoppingFeeder_Service_TestController extends Mage_Core_Controller_Front_Action
7
+ {
8
+ public function indexAction()
9
+ {
10
+ $store = $this->getRequest()->getParam('store', null);
11
+
12
+ /**
13
+ * For per-store system
14
+ */
15
+ if (!is_null($store))
16
+ {
17
+ Mage::app()->setCurrentStore($store);
18
+ }
19
+ else
20
+ {
21
+ $defaultStoreCode = Mage::app()
22
+ ->getWebsite(true)
23
+ ->getDefaultGroup()
24
+ ->getDefaultStore()
25
+ ->getCode();
26
+
27
+ Mage::app()->setCurrentStore($defaultStoreCode);
28
+ }
29
+
30
+ if (!function_exists('getallheaders'))
31
+ {
32
+ function getallheaders()
33
+ {
34
+ $headers = '';
35
+ foreach ($_SERVER as $name => $value)
36
+ {
37
+ if (substr($name, 0, 5) == 'HTTP_')
38
+ {
39
+ $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
40
+ }
41
+ }
42
+ return $headers;
43
+ }
44
+ }
45
+
46
+ $requiresSsl = false;
47
+
48
+ try
49
+ {
50
+
51
+ //try fetch the store
52
+ if (!is_null($store))
53
+ {
54
+ /** @var $websiteCollection Mage_Core_Model_Store */
55
+ $storeCollection = Mage::getModel('core/store')->getCollection();
56
+
57
+ $stores = array();
58
+ foreach ($storeCollection as $internalStore) {
59
+ /** @var $internalStore Mage_Core_Model_Store */
60
+ $internalStore->initConfigCache();
61
+
62
+ $stores[$internalStore->getCode()] = $internalStore->getName();
63
+ }
64
+
65
+ if (!isset($stores[$store]))
66
+ {
67
+ throw new Exception('Multi-store store code is not valid');
68
+ }
69
+ }
70
+
71
+ /** @var ShoppingFeeder_Service_Model_Auth $authModel */
72
+ $authModel = Mage::getModel('shoppingfeeder_service/auth');
73
+ //check if this setup requires SSL
74
+ $sslInFront = Mage::getStoreConfig('web/secure/use_in_frontend');
75
+ $requiresSsl = ($sslInFront == null) ? false : $sslInFront;
76
+
77
+ $apiKeys = $authModel->getApiKeys();
78
+
79
+ if (!isset($apiKeys['api_key']) || empty($apiKeys['api_key']))
80
+ {
81
+ throw new Exception('API key not setup.');
82
+ }
83
+
84
+ if (!isset($apiKeys['api_secret']) || empty($apiKeys['api_secret']))
85
+ {
86
+ throw new Exception('API secret not setup.');
87
+ }
88
+
89
+ $headers = getallheaders();
90
+
91
+ $authResult = $authModel->auth(
92
+ $headers,
93
+ $this->getRequest()->getScheme(),
94
+ $this->getRequest()->getMethod()
95
+ );
96
+
97
+ if ($authResult === true)
98
+ {
99
+ set_time_limit(0);
100
+
101
+ $responseData = array(
102
+ 'status' => 'success',
103
+ 'data' => array(
104
+ 'message' => 'Authorization OK',
105
+ 'requires_ssl' => $requiresSsl
106
+ )
107
+ );
108
+ }
109
+ else
110
+ {
111
+ $responseData = array(
112
+ 'status' => 'fail',
113
+ 'data' => array (
114
+ 'message' => 'Authorization failed: ['.$authResult.']',
115
+ 'requires_ssl' => $requiresSsl
116
+ )
117
+ );
118
+ }
119
+ }
120
+ catch (Exception $e)
121
+ {
122
+ $responseData = array(
123
+ 'status' => 'fail',
124
+ 'data' => array (
125
+ 'message' => $e->getMessage(),
126
+ 'requires_ssl' => $requiresSsl
127
+ )
128
+ );
129
+ }
130
+
131
+ header('Content-type: application/json; charset=UTF-8');
132
+ echo json_encode($responseData);
133
+ exit();
134
+ }
135
+
136
+ public function debugAction()
137
+ {
138
+ $store = $this->getRequest()->getParam('store', null);
139
+
140
+ /**
141
+ * For per-store system
142
+ */
143
+ if (!is_null($store))
144
+ {
145
+ Mage::app()->setCurrentStore($store);
146
+ }
147
+ else
148
+ {
149
+ $defaultStoreCode = Mage::app()
150
+ ->getWebsite(true)
151
+ ->getDefaultGroup()
152
+ ->getDefaultStore()
153
+ ->getCode();
154
+
155
+ Mage::app()->setCurrentStore($defaultStoreCode);
156
+ }
157
+
158
+ if (function_exists('getallheaders'))
159
+ {
160
+ echo 'Function <b>getallheaders</b> <span style="color:green;">exists</span>'."<br>\n";
161
+ try
162
+ {
163
+ $headers = getallheaders();
164
+ echo 'Get headers succeeded: '.print_r($headers,true)."<br>\n";
165
+ }
166
+ catch (Exception $e)
167
+ {
168
+ echo 'Get headers failed: ['.$e->getMessage().']'."<br>\n";
169
+ }
170
+ }
171
+ else
172
+ {
173
+ try
174
+ {
175
+ function getallheaders()
176
+ {
177
+ $headers = '';
178
+ foreach ($_SERVER as $name => $value)
179
+ {
180
+ if (substr($name, 0, 5) == 'HTTP_')
181
+ {
182
+ $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
183
+ }
184
+ }
185
+ return $headers;
186
+ }
187
+ echo 'Function <b>getallheaders</b> created'."<br>\n";
188
+
189
+ try
190
+ {
191
+ $headers = getallheaders();
192
+ echo 'Get headers succeeded: '.print_r($headers,true)."<br>\n";
193
+ }
194
+ catch (Exception $e)
195
+ {
196
+ echo 'Get headers failed: ['.$e->getMessage().']'."<br>\n";
197
+ }
198
+ }
199
+ catch (Exception $e)
200
+ {
201
+ echo 'Function <b>getallheaders</b> could not be created'."<br>\n";
202
+ }
203
+ }
204
+
205
+ if (function_exists('hash_hmac'))
206
+ {
207
+ echo 'Function <b>hash_hmac</b> <span style="color:green;">exists</span>'."<br>\n";
208
+ }
209
+ else
210
+ {
211
+ echo 'Function <b>hash_hmac</b> <span style="color:red;">does not exist</span>'."<br>\n";
212
+ }
213
+
214
+ if (function_exists('mhash'))
215
+ {
216
+ echo 'Function <b>mhash</b> <span style="color:green;">exists</span>'."<br>\n";
217
+ }
218
+ else
219
+ {
220
+ echo 'Function <b>mhash</b> <span style="color:red;">does not exist</span>'."<br>\n";
221
+ }
222
+
223
+ try
224
+ {
225
+ /** @var ShoppingFeeder_Service_Model_Auth $authModel */
226
+ $authModel = Mage::getModel('shoppingfeeder_service/auth');
227
+ echo '$authModel successfully instantiated'."<br>\n";
228
+ }
229
+ catch (Exception $e)
230
+ {
231
+ echo '$authModel could not be instantiated: ['.$e->getMessage().']'."<br>\n";
232
+ }
233
+
234
+
235
+ if (isset($authModel))
236
+ {
237
+ try
238
+ {
239
+ $apiKeys = $authModel->getApiKeys();
240
+ //hide from view
241
+ unset($apiKeys['api_secret']);
242
+ echo 'API Keys successfully fetched: '.print_r($apiKeys, true)."<br>\n";
243
+
244
+ try
245
+ {
246
+ $headers = getallheaders();
247
+ $authResult = $authModel->auth(
248
+ $headers,
249
+ $this->getRequest()->getScheme(),
250
+ $this->getRequest()->getMethod()
251
+ );
252
+ echo '$authresult successfully called: '.print_r($authResult,true)."<br>\n";
253
+ }
254
+ catch (Exception $e)
255
+ {
256
+ echo '$authresult could not be called: ['.$e->getMessage().']'."<br>\n";
257
+ }
258
+ }
259
+ catch (Exception $e)
260
+ {
261
+ echo 'API Keys could not be fetched: ['.$e->getMessage().']'."<br>\n";
262
+ }
263
+ }
264
+
265
+ try {
266
+ $currency = $this->getRequest()->getParam('currency', null);
267
+
268
+ $baseCurrency = Mage::app()->getStore()->getBaseCurrencyCode();
269
+ $priceCurrency = (is_null($currency)) ? Mage::app()->getStore()->getDefaultCurrencyCode() : $currency;
270
+ $priceCurrencyRate = Mage::helper('directory')->currencyConvert(1, $baseCurrency, $priceCurrency);
271
+
272
+ echo 'Base currency <span style="color:green;">'.$baseCurrency.'</span>'."<br>\n";
273
+ echo 'Price currency <span style="color:green;">'.$priceCurrency.'</span>'."<br>\n";
274
+ echo 'Exchange rate '.$baseCurrency.'/'.$priceCurrency.' <span style="color:green;">'.$priceCurrencyRate.'</span>'."<br>\n";
275
+ }
276
+ catch (Exception $e)
277
+ {
278
+ echo '<span style="color:red;">could not</span> fetch currencies: ['.$e->getMessage().']'."<br>\n";
279
+ }
280
+
281
+ $offersModel = false;
282
+ try {
283
+ $offersModel = Mage::getSingleton('shoppingfeeder_service/offers');
284
+ echo '$offersModel <span style="color:green;">successfully instantiated</span>'."<br>\n";
285
+ }
286
+ catch (Exception $e)
287
+ {
288
+ echo '$offersModel <span style="color:red;">could not</span> be instantiated: ['.$e->getMessage().']'."<br>\n";
289
+
290
+ }
291
+
292
+ $page = 1;
293
+ $numPerPage = 1;
294
+ $offers = false;
295
+ if ($offersModel)
296
+ {
297
+ try {
298
+ $page = 1;
299
+ $numPerPage = 1;
300
+
301
+ $offers = $offersModel->getItems($page, $numPerPage);
302
+ echo 'Fetch 1 product successful'."<br>\n";
303
+ }
304
+ catch (Exception $e)
305
+ {
306
+ echo 'Fetch 1 product <span style="color:red;">NOT</span> successful: ['.$e->getMessage().']'."<br>\n";
307
+
308
+ try {
309
+ echo 'Trying to get $collection'."<br>\n";
310
+ $collection = Mage::getModel('catalog/product')->getCollection()
311
+ ->addAttributeToSelect('*')
312
+ ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
313
+ ->addAttributeToFilter('visibility', 4);
314
+ echo '$collection <span style="color:green;">successfully instantiated</span>'."<br>\n";
315
+ }
316
+ catch (Exception $e)
317
+ {
318
+ echo '$collection <span style="color:red;">NOT</span> successful: ['.$e->getMessage().']'."<br>\n";
319
+ }
320
+ }
321
+ }
322
+
323
+ if ($offers)
324
+ {
325
+ try {
326
+ $responseData = array(
327
+ 'status' => 'success',
328
+ 'data' => array(
329
+ 'page' => $page,
330
+ 'num_per_page' => $numPerPage,
331
+ 'offers' => $offers
332
+ )
333
+ );
334
+
335
+ echo json_encode($responseData);
336
+ }
337
+ catch (Exception $e)
338
+ {
339
+ echo 'Could not output JSON: ['.$e->getMessage().']'."<br>\n";
340
+ }
341
+ }
342
+
343
+ exit();
344
+ }
345
+
346
+ public function debug2Action()
347
+ {
348
+ echo("DEBUG-DEBUG");
349
+ exit();
350
+ }
351
  }
app/code/community/ShoppingFeeder/Service/controllers/VersionController.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
-
3
- //IMPORTANT - "Controller" directory is not autoloaded
4
- require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
-
6
- class ShoppingFeeder_Service_VersionController extends Mage_Core_Controller_Front_Action
7
- {
8
- protected static $_version = '1.5.1';
9
-
10
- public function indexAction()
11
- {
12
- $responseData = array(
13
- 'status' => 'success',
14
- 'data' => array(
15
- 'version' => self::$_version
16
- )
17
- );
18
-
19
- header('Content-type: application/json; charset=UTF-8');
20
- echo json_encode($responseData);
21
- exit();
22
- }
23
  }
1
+ <?php
2
+
3
+ //IMPORTANT - "Controller" directory is not autoloaded
4
+ require_once(Mage::getModuleDir('Controller','ShoppingFeeder_Service').DS.'Controller'.DS.'FrontAuth.php');
5
+
6
+ class ShoppingFeeder_Service_VersionController extends Mage_Core_Controller_Front_Action
7
+ {
8
+ protected static $_version = '1.5.2';
9
+
10
+ public function indexAction()
11
+ {
12
+ $responseData = array(
13
+ 'status' => 'success',
14
+ 'data' => array(
15
+ 'version' => self::$_version
16
+ )
17
+ );
18
+
19
+ header('Content-type: application/json; charset=UTF-8');
20
+ echo json_encode($responseData);
21
+ exit();
22
+ }
23
  }
app/code/community/ShoppingFeeder/Service/etc/config.xml CHANGED
@@ -9,7 +9,7 @@
9
  <config>
10
  <modules>
11
  <ShoppingFeeder_Service>
12
- <version>1.5.1</version>
13
  </ShoppingFeeder_Service>
14
  </modules>
15
  <global>
9
  <config>
10
  <modules>
11
  <ShoppingFeeder_Service>
12
+ <version>1.5.2</version>
13
  </ShoppingFeeder_Service>
14
  </modules>
15
  <global>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>shoppingfeeder</name>
4
- <version>1.5.1</version>
5
  <stability>stable</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
@@ -16,11 +16,11 @@ Use ShoppingFeeder to import your Shopify product catalogue, export it to numero
16
  Export to Google, Shopping.com, Nextag, kelkoo, PriceCheck, Shopmania, Fruugo and more!&#xD;
17
  &#xD;
18
  To set up your ShoppingFeeder account and install this extension seamlessly, create an account at: &lt;a href="http://www.shoppingfeeder.com/register"&gt;http://www.shoppingfeeder.com/register&lt;/a&gt;</description>
19
- <notes>Bug fix for configurable product special price</notes>
20
  <authors><author><name>ShoppingFeeder</name><user>shoppingfeeder</user><email>support@shoppingfeeder.com</email></author></authors>
21
- <date>2016-11-03</date>
22
- <time>13:03:58</time>
23
- <contents><target name="mageetc"><dir name="modules"><file name="ShoppingFeeder_Service.xml" hash="90b374109c2d1281ddf527f24fa7d914"/></dir></target><target name="magecommunity"><dir name="ShoppingFeeder"><dir name="Fbtrack"><dir name="Block"><dir name="Adminhtml"><file name="Service.php" hash="2c0bb6d0c7f965c9583cfaae4890d053"/></dir><file name="Service.php" hash="56cd6921b7bda27e2ed66b80af1d927f"/><dir name="Tracking"><file name="Fb.php" hash="1926b36b1d6092b7566e2688559fa895"/></dir></dir><dir name="Helper"><file name="Data.php" hash="87df6b00fcfb2008697cf46d6d18cf75"/></dir><dir name="Model"><file name="Observer.php" hash="dc3282bb0795790a95abd781e9394ece"/></dir><dir name="etc"><file name="config.xml" hash="2cbb1a1b1f6f9ecc77bf0eb406941a17"/><file name="system.xml" hash="227c0ffc63ff10b814d42cd9a8f8bad4"/></dir></dir><dir name="Service"><dir name="Block"><dir name="Adminhtml"><file name="Service.php" hash="8feb1712d6aa6a6897be8f80ba5d3f0b"/></dir><file name="Service.php" hash="48874f0e80ce70686b81eb5380e9f498"/><dir name="Tracking"><file name="Fb.php" hash="060687f842c896df73feb233b68b069b"/></dir></dir><dir name="Controller"><file name="FrontAuth.php" hash="28ed32e1bf3250362911a26869f0e6d7"/></dir><dir name="Helper"><file name="Data.php" hash="17589bd08352e497806bef9884972300"/></dir><dir name="Model"><file name="Auth.php" hash="2cff17b0750ff70695b32524627b2aaf"/><file name="Observer.php" hash="eb7443554b58eeeb4687ebc2ee6db5ff"/><file name="Offers.php" hash="ff47a521cea4b6bdd38c4aec233a5867"/><file name="Orders.php" hash="cc3c9f38ae41c11ab7dda0bcb8dd001f"/></dir><dir name="controllers"><file name="AttributesController.php" hash="e937c492f770bc8381a003a080cf878b"/><file name="FeedController.php" hash="92b70af3a048ece99d262480c51aa862"/><file name="OrdersController.php" hash="e0dcf407e15ca212b43ee0015c918675"/><file name="StockController.php" hash="1bd761514eb385776dc41476300f88c4"/><file name="StoresController.php" hash="a29fa0e97299ce764fd66360cbf6632a"/><file name="TestController.php" hash="5138a844cb7cbc8e792df664057bdf9b"/><file name="VersionController.php" hash="104b8f411cbd9a3f2c3fed2cf8dc821c"/></dir><dir name="data"><file name="cacert.pem" hash="380df856e8f789c1af97d0da9a243769"/></dir><dir name="etc"><file name="config.xml" hash="4fda9559a4577bde982a58becabde5b9"/><file name="system.xml" hash="e358d831424ccacdd393dfac49b8a994"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="shoppingfeeder_service.xml" hash="4f3a5b5018c0328da4f9490d4c6042fd"/></dir><dir name="template"><dir name="shoppingfeeder"><file name="fbtrack.phtml" hash="d7b78bc15e750d570f06e06facd721bb"/><file name="fbtrack_standalone.phtml" hash="d7b78bc15e750d570f06e06facd721bb"/></dir></dir></dir></dir></dir></target></contents>
24
  <compatible/>
25
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
26
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>shoppingfeeder</name>
4
+ <version>1.5.2</version>
5
  <stability>stable</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
16
  Export to Google, Shopping.com, Nextag, kelkoo, PriceCheck, Shopmania, Fruugo and more!&#xD;
17
  &#xD;
18
  To set up your ShoppingFeeder account and install this extension seamlessly, create an account at: &lt;a href="http://www.shoppingfeeder.com/register"&gt;http://www.shoppingfeeder.com/register&lt;/a&gt;</description>
19
+ <notes>Bug fix for sale price effective date</notes>
20
  <authors><author><name>ShoppingFeeder</name><user>shoppingfeeder</user><email>support@shoppingfeeder.com</email></author></authors>
21
+ <date>2016-11-23</date>
22
+ <time>12:28:41</time>
23
+ <contents><target name="mageetc"><dir name="modules"><file name="ShoppingFeeder_Service.xml" hash="90b374109c2d1281ddf527f24fa7d914"/></dir></target><target name="magecommunity"><dir name="ShoppingFeeder"><dir name="Fbtrack"><dir name="Block"><dir name="Adminhtml"><file name="Service.php" hash="2c0bb6d0c7f965c9583cfaae4890d053"/></dir><file name="Service.php" hash="56cd6921b7bda27e2ed66b80af1d927f"/><dir name="Tracking"><file name="Fb.php" hash="1926b36b1d6092b7566e2688559fa895"/></dir></dir><dir name="Helper"><file name="Data.php" hash="87df6b00fcfb2008697cf46d6d18cf75"/></dir><dir name="Model"><file name="Observer.php" hash="e74b770258e02099d187913d00724bc8"/></dir><dir name="etc"><file name="config.xml" hash="2cbb1a1b1f6f9ecc77bf0eb406941a17"/><file name="system.xml" hash="227c0ffc63ff10b814d42cd9a8f8bad4"/></dir></dir><dir name="Service"><dir name="Block"><dir name="Adminhtml"><file name="Service.php" hash="8feb1712d6aa6a6897be8f80ba5d3f0b"/></dir><file name="Service.php" hash="48874f0e80ce70686b81eb5380e9f498"/><dir name="Tracking"><file name="Fb.php" hash="060687f842c896df73feb233b68b069b"/></dir></dir><dir name="Controller"><file name="FrontAuth.php" hash="898ec607a5e957145a4650459a14bab0"/></dir><dir name="Helper"><file name="Data.php" hash="17589bd08352e497806bef9884972300"/></dir><dir name="Model"><file name="Auth.php" hash="fca7b73dfce4b2c99269f3deba9904b7"/><file name="Observer.php" hash="639b365ee394cb9945ea01fac7d1a30d"/><file name="Offers.php" hash="ec7609f712a66e1508e8ea989c4837e3"/><file name="Orders.php" hash="34821ae78c33da770b5bbced80a957c9"/></dir><dir name="controllers"><file name="AttributesController.php" hash="ff8b6b375f4e2003b611c339c4d22f55"/><file name="FeedController.php" hash="84b2525cce66eb3abe2ef481635295ff"/><file name="OrdersController.php" hash="50e1701b194f5122c55344ed084c7523"/><file name="StockController.php" hash="1f35d35642bf63e5baf4a0cade460ba3"/><file name="StoresController.php" hash="2443dc0538edffc635efcbfec6c48d64"/><file name="TestController.php" hash="cc6a91597d597ee05b208cbf2679c9db"/><file name="VersionController.php" hash="be3e0e7156eac5784a68f6417b68a5a6"/></dir><dir name="data"><file name="cacert.pem" hash="380df856e8f789c1af97d0da9a243769"/></dir><dir name="etc"><file name="config.xml" hash="54987c6a55605b9004dc0a77a2c0dde1"/><file name="system.xml" hash="e358d831424ccacdd393dfac49b8a994"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="shoppingfeeder_service.xml" hash="4f3a5b5018c0328da4f9490d4c6042fd"/></dir><dir name="template"><dir name="shoppingfeeder"><file name="fbtrack.phtml" hash="d7b78bc15e750d570f06e06facd721bb"/><file name="fbtrack_standalone.phtml" hash="d7b78bc15e750d570f06e06facd721bb"/></dir></dir></dir></dir></dir></target></contents>
24
  <compatible/>
25
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
26
  </package>