socialcommerce_suite_by_turnto - Version 2.1.4

Version Notes

TurnTo Admin Extension
2.0 Adds support for Single Sign On
2.1 Re-wrote catalog feed generator

Download this release

Release Info

Developer TurnTo Networks
Extension socialcommerce_suite_by_turnto
Version 2.1.4
Comparing to
See all releases


Code changes from version 2.1.2 to 2.1.4

app/code/community/Turnto/Admin/controllers/.IndexController.php.swo ADDED
Binary file
app/code/community/Turnto/Admin/controllers/.IndexController.php.swp DELETED
Binary file
app/code/community/Turnto/Admin/controllers/AdminControllers/.TurntoController.php.swp ADDED
Binary file
app/code/community/Turnto/Admin/controllers/AdminControllers/TurntoController.php CHANGED
@@ -7,17 +7,8 @@ class Turnto_Admin_AdminControllers_TurntoController extends Mage_Adminhtml_Cont
7
  $this->loadLayout();
8
 
9
  $resource = Mage::getSingleton('core/resource');
10
- $storeList = array();
11
- foreach (Mage::app()->getWebsites() as $website) {
12
- foreach ($website->getGroups() as $group) {
13
- $stores = $group->getStores();
14
- foreach ($stores as $store) {
15
- array_push($storeList, $store);
16
- }
17
- }
18
- }
19
 
20
- Mage::register('sites', $storeList);
21
 
22
  $this->_addLeft($this->getLayout()->createBlock('Turnto_Admin_Block_ShowTabsAdminBlock'));
23
 
@@ -53,55 +44,77 @@ class Turnto_Admin_AdminControllers_TurntoController extends Mage_Adminhtml_Cont
53
  }
54
 
55
  $scope = $post['scope'];
56
- $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
57
- $baseMediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
58
- if(isset($scope)){
59
- $baseUrl = Mage::app()->getStore($scope)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
60
- $baseMediaUrl = Mage::app()->getStore($scope)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
61
- }
62
-
63
- $resource = Mage::getSingleton('core/resource');
64
- $readConnection = $resource->getConnection('core_read');
65
-
66
- $stmt = $readConnection->prepare(
67
- 'select sales_flat_order.entity_id as orderid, '
68
- .'sales_flat_order_item.created_at as orderdate, '
69
- .'customer_email as email, '
70
- .'ifnull(parent.name, sales_flat_order_item.name) as itemtitle, '
71
- .'concat('.$readConnection->quote($baseUrl).', ifnull(parent.url_path, catalog_product_flat_1.url_path)) as itemurl, '
72
- .'item_id as itemlineid, '
73
- .'postcode as zip, '
74
- .'customer_firstname as firstname, '
75
- .'customer_lastname as lastname, '
76
- .'ifnull(parent.sku, sales_flat_order_item.sku) as sku, '
77
- .'grand_total as price, '
78
- .'concat('.$readConnection->quote($baseMediaUrl).', ifnull(parent.small_image, catalog_product_flat_1.small_image)) as itemimageurl '
79
- .'from sales_flat_order,'
80
- .'sales_flat_order_item, '
81
- .'sales_flat_order_address, '
82
- .'catalog_product_flat_1 '
83
- .'left join catalog_product_super_link on catalog_product_flat_1.entity_id = catalog_product_super_link.product_id '
84
- .'left join catalog_product_flat_1 as parent on catalog_product_super_link.parent_id = parent.entity_id '
85
- .'where sales_flat_order.entity_id = sales_flat_order_item.order_id '
86
- .'and sales_flat_order.entity_id = sales_flat_order_address.parent_id '
87
- .'and sales_flat_order_item.product_id = catalog_product_flat_1.entity_id '
88
- .'and sales_flat_order_item.created_at > str_to_date(\''.$startDate.'\', \'%m/%d/%Y\')', array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
89
- $stmt->execute();
90
-
91
  $handle = fopen($path . 'histfeed.csv', 'w');
92
 
93
  fwrite($handle, "ORDERID\tORDERDATE\tEMAIL\tITEMTITLE\tITEMURL\tITEMLINEID\tZIP\tFIRSTNAME\tLASTNAME\tSKU\tPRICE\tITEMIMAGEURL");
94
  fwrite($handle, "\n");
95
-
96
- while ($row = $stmt->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) {
97
- foreach($row as $column){
98
- fwrite($handle, str_replace("\t", "\\t", $column));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  fwrite($handle, "\t");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
-
102
- fwrite($handle, "\n");
103
  }
104
- $stmt = null;
 
 
105
  fclose($handle);
106
 
107
  $message = $this->__('The historical feed was successfully generated. Click the "Download historical feed" link to download.');
@@ -109,24 +122,33 @@ class Turnto_Admin_AdminControllers_TurntoController extends Mage_Adminhtml_Cont
109
  }
110
  else{
111
  /* form processing */
112
- $scope = $post['scope'];
113
-
 
 
 
 
 
 
 
 
114
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
115
  $baseMediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
116
- if(isset($scope)){
117
- $baseUrl = Mage::app()->getStore($scope)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
118
- $baseMediaUrl = Mage::app()->getStore($scope)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
119
- }
 
120
 
121
  $handle = fopen($path . 'catfeed.csv', 'w');
122
 
123
  fwrite($handle, "SKU\tIMAGEURL\tTITLE\tPRICE\tCURRENCY\tACTIVE\tITEMURL\tCATEGORY\tKEYWORDS\tREPLACEMENTSKU\tINSTOCK\tVIRTUALPARENTCODE\tCATEGORYPATHJSON\tISCATEGORY");
124
  fwrite($handle, "\n");
125
 
126
- $products = Mage::getModel('catalog/product')->setStoreId($scope)->getCollection()->addAttributeToSelect('name')->addAttributeToSelect('*')->addAttributeToSelect('price')->addAttributeToSelect('image');
127
  if ($products) {
128
  foreach ($products as $product) {
129
- $product->setStoreId($scope);
130
  fwrite($handle, $product->getSku());
131
  fwrite($handle, "\t");
132
  if($product->getImage() != null && $product->getImage() != "no_selection") {
@@ -167,13 +189,13 @@ class Turnto_Admin_AdminControllers_TurntoController extends Mage_Adminhtml_Cont
167
  }
168
  }
169
 
170
- $categories = Mage::getModel('catalog/category')->setStoreId($scope)->getCollection()->addAttributeToSelect('name');
171
  if ($categories) {
172
  foreach ($categories as $category) {
173
  if ($category->getId() == 1) {
174
  continue;
175
  }
176
- $category->setStoreId($scope);
177
  fwrite($handle, $category->getId());
178
  fwrite($handle, "\t");
179
  //IMAGEURL
7
  $this->loadLayout();
8
 
9
  $resource = Mage::getSingleton('core/resource');
 
 
 
 
 
 
 
 
 
10
 
11
+ Mage::register('websites', Mage::app()->getWebsites());
12
 
13
  $this->_addLeft($this->getLayout()->createBlock('Turnto_Admin_Block_ShowTabsAdminBlock'));
14
 
44
  }
45
 
46
  $scope = $post['scope'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  $handle = fopen($path . 'histfeed.csv', 'w');
48
 
49
  fwrite($handle, "ORDERID\tORDERDATE\tEMAIL\tITEMTITLE\tITEMURL\tITEMLINEID\tZIP\tFIRSTNAME\tLASTNAME\tSKU\tPRICE\tITEMIMAGEURL");
50
  fwrite($handle, "\n");
51
+
52
+ $fromDate = date('Y-m-d H:i:s', strtotime($startDate));
53
+ Mage::app();
54
+ $orders = Mage::getModel('sales/order')
55
+ ->getCollection()
56
+ ->addFieldToFilter('store_id', $scope)
57
+ ->addAttributeToFilter('created_at', array('from'=>$fromDate))
58
+ ->addAttributeToSort('entity_id', 'DESC');
59
+ $orders->setPageSize(100);
60
+ $pages = $orders->getLastPageNumber();
61
+ $currentPage = 1;
62
+ do {
63
+ $orders->setCurPage($currentPage);
64
+ foreach($orders as $order) {
65
+ $itemlineid = 0;
66
+ foreach($order->getAllVisibleItems() as $item) {
67
+ //ORDERID
68
+ fwrite($handle, $order->getRealOrderId());
69
+ fwrite($handle, "\t");
70
+ //ORDERDATE
71
+ fwrite($handle, $order->getCreatedAtDate()->toString('Y-MM-d'));
72
+ fwrite($handle, "\t");
73
+ //EMAIL
74
+ fwrite($handle, $order->getCustomerEmail());
75
+ fwrite($handle, "\t");
76
+ //ITEMTITLE
77
+ fwrite($handle, $item->getName());
78
+ fwrite($handle, "\t");
79
+ //ITEMURL
80
+ $product = $item->getProduct();
81
+ fwrite($handle, $product->getProductUrl());
82
+ fwrite($handle, "\t");
83
+ //ITEMLINEID
84
+ fwrite($handle, $itemlineid++);
85
+ fwrite($handle, "\t");
86
+ //ZIP
87
+ fwrite($handle, $order->getShippingAddress()->getPostcode());
88
  fwrite($handle, "\t");
89
+ //FIRSTNAME
90
+ $name = explode(' ', $order->getCustomerName());
91
+ fwrite($handle, $name[0]);
92
+ fwrite($handle, "\t");
93
+ //LASTNAME
94
+ if (isset($name[1])){
95
+ fwrite($handle, $name[1]);
96
+ }
97
+ fwrite($handle, "\t");
98
+ //SKU
99
+ fwrite($handle, $item->getSku());
100
+ fwrite($handle, "\t");
101
+ //PRICE
102
+ fwrite($handle, $item->getOriginalPrice());
103
+ fwrite($handle, "\t");
104
+ //ITEMIMAGEURL
105
+ if($product->getImage() != null && $product->getImage() != "no_selection") {
106
+ fwrite($handle, Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getImage() ));
107
+ } else if ($product->getSmallImage() != null && $product->getSmallImage() != "no_selection") {
108
+ fwrite($handle, Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getSmallImage() ));
109
+ } else if ($product->getThumbnail() != null && $product->getThumbnail() != "no_selection") {
110
+ fwrite($handle, Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getThumbnail() ));
111
+ }
112
+ fwrite($handle, "\n");
113
  }
 
 
114
  }
115
+ $currentPage++;
116
+ } while($currentPage <= $pages);
117
+
118
  fclose($handle);
119
 
120
  $message = $this->__('The historical feed was successfully generated. Click the &quot;Download historical feed&quot; link to download.');
122
  }
123
  else{
124
  /* form processing */
125
+ $websiteId = $post['websiteId'];
126
+ $storeId = 1;
127
+ if (isset($websiteId)) {
128
+ $split = explode('_', $websiteId);
129
+ $websiteId = $split[0];
130
+ $storeId = $split[1];
131
+ } else {
132
+ $websiteId = 1;
133
+ }
134
+
135
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
136
  $baseMediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
137
+ if(!isset($storeId)){
138
+ $storeId = 1;
139
+ }
140
+ $baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
141
+ $baseMediaUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
142
 
143
  $handle = fopen($path . 'catfeed.csv', 'w');
144
 
145
  fwrite($handle, "SKU\tIMAGEURL\tTITLE\tPRICE\tCURRENCY\tACTIVE\tITEMURL\tCATEGORY\tKEYWORDS\tREPLACEMENTSKU\tINSTOCK\tVIRTUALPARENTCODE\tCATEGORYPATHJSON\tISCATEGORY");
146
  fwrite($handle, "\n");
147
 
148
+ $products = Mage::getModel('catalog/product')->setStoreId($storeId)->getCollection()->addAttributeToSelect('name')->addAttributeToSelect('*')->addAttributeToSelect('price')->addAttributeToSelect('image')->addWebsiteFilter($websiteId);
149
  if ($products) {
150
  foreach ($products as $product) {
151
+ $product->setStoreId($storeId);
152
  fwrite($handle, $product->getSku());
153
  fwrite($handle, "\t");
154
  if($product->getImage() != null && $product->getImage() != "no_selection") {
189
  }
190
  }
191
 
192
+ $categories = Mage::getModel('catalog/category')->setStoreId($storeId)->getCollection()->addAttributeToSelect('name');
193
  if ($categories) {
194
  foreach ($categories as $category) {
195
  if ($category->getId() == 1) {
196
  continue;
197
  }
198
+ $category->setStoreId($storeId);
199
  fwrite($handle, $category->getId());
200
  fwrite($handle, "\t");
201
  //IMAGEURL
app/code/community/Turnto/Admin/controllers/AdminControllers/TurntoController.php.bkup ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Turnto_Admin_AdminControllers_TurntoController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->loadLayout();
8
+
9
+ $resource = Mage::getSingleton('core/resource');
10
+ $storeList = array();
11
+ foreach (Mage::app()->getWebsites() as $website) {
12
+ foreach ($website->getGroups() as $group) {
13
+ $stores = $group->getStores();
14
+ foreach ($stores as $store) {
15
+ array_push($storeList, $store);
16
+ }
17
+ }
18
+ }
19
+
20
+ Mage::register('sites', $storeList);
21
+
22
+ $this->_addLeft($this->getLayout()->createBlock('Turnto_Admin_Block_ShowTabsAdminBlock'));
23
+
24
+ $this->renderLayout();
25
+ }
26
+
27
+ public function redirectAction()
28
+ {
29
+ $this->_redirectUrl('http://www.turnto.com');
30
+ }
31
+
32
+ public function postAction()
33
+ {
34
+ $post = $this->getRequest()->getPost();
35
+ $catalogFeed = true;
36
+
37
+ try {
38
+ if (empty($post)) {
39
+ Mage::throwException($this->__('Invalid form data.'));
40
+ }
41
+
42
+ $path = Mage::getBaseDir('media') . DS . 'turnto/';
43
+ mkdir($path, 0755);
44
+
45
+ if($post['feed_type'] == 'historical'){
46
+ /* form processing */
47
+ $startDate = $post['start_date'];
48
+
49
+ if($startDate == null || $startDate == ""){
50
+ Mage::getSingleton('adminhtml/session')->addError("Start Date is required");
51
+ $this->_redirect('*/*/', array('active_tab' => 'turnto_hist_feed_tab'));
52
+ return;
53
+ }
54
+
55
+ $scope = $post['scope'];
56
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
57
+ $baseMediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
58
+ if(isset($scope)){
59
+ $baseUrl = Mage::app()->getStore($scope)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
60
+ $baseMediaUrl = Mage::app()->getStore($scope)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
61
+ }
62
+
63
+ $resource = Mage::getSingleton('core/resource');
64
+ $readConnection = $resource->getConnection('core_read');
65
+
66
+ $stmt = $readConnection->prepare(
67
+ 'select sales_flat_order.entity_id as orderid, '
68
+ .'sales_flat_order_item.created_at as orderdate, '
69
+ .'customer_email as email, '
70
+ .'ifnull(parent.name, sales_flat_order_item.name) as itemtitle, '
71
+ .'concat('.$readConnection->quote($baseUrl).', ifnull(parent.url_path, catalog_product_flat_1.url_path)) as itemurl, '
72
+ .'item_id as itemlineid, '
73
+ .'postcode as zip, '
74
+ .'customer_firstname as firstname, '
75
+ .'customer_lastname as lastname, '
76
+ .'ifnull(parent.sku, sales_flat_order_item.sku) as sku, '
77
+ .'grand_total as price, '
78
+ .'concat('.$readConnection->quote($baseMediaUrl).', ifnull(parent.small_image, catalog_product_flat_1.small_image)) as itemimageurl '
79
+ .'from sales_flat_order,'
80
+ .'sales_flat_order_item, '
81
+ .'sales_flat_order_address, '
82
+ .'catalog_product_flat_1 '
83
+ .'left join catalog_product_super_link on catalog_product_flat_1.entity_id = catalog_product_super_link.product_id '
84
+ .'left join catalog_product_flat_1 as parent on catalog_product_super_link.parent_id = parent.entity_id '
85
+ .'where sales_flat_order.entity_id = sales_flat_order_item.order_id '
86
+ .'and sales_flat_order.entity_id = sales_flat_order_address.parent_id '
87
+ .'and sales_flat_order_item.product_id = catalog_product_flat_1.entity_id '
88
+ .'and sales_flat_order_item.created_at > str_to_date(\''.$startDate.'\', \'%m/%d/%Y\')', array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
89
+ $stmt->execute();
90
+
91
+ $handle = fopen($path . 'histfeed.csv', 'w');
92
+
93
+ fwrite($handle, "ORDERID\tORDERDATE\tEMAIL\tITEMTITLE\tITEMURL\tITEMLINEID\tZIP\tFIRSTNAME\tLASTNAME\tSKU\tPRICE\tITEMIMAGEURL");
94
+ fwrite($handle, "\n");
95
+
96
+ while ($row = $stmt->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) {
97
+ foreach($row as $column){
98
+ fwrite($handle, str_replace("\t", "\\t", $column));
99
+ fwrite($handle, "\t");
100
+ }
101
+
102
+ fwrite($handle, "\n");
103
+ }
104
+ $stmt = null;
105
+ fclose($handle);
106
+
107
+ $message = $this->__('The historical feed was successfully generated. Click the &quot;Download historical feed&quot; link to download.');
108
+ $catalogFeed = false;
109
+ }
110
+ else{
111
+ /* form processing */
112
+ $scope = $post['scope'];
113
+
114
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
115
+ $baseMediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
116
+ if(isset($scope)){
117
+ $baseUrl = Mage::app()->getStore($scope)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
118
+ $baseMediaUrl = Mage::app()->getStore($scope)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
119
+ }
120
+
121
+ $handle = fopen($path . 'catfeed.csv', 'w');
122
+
123
+ fwrite($handle, "SKU\tIMAGEURL\tTITLE\tPRICE\tCURRENCY\tACTIVE\tITEMURL\tCATEGORY\tKEYWORDS\tREPLACEMENTSKU\tINSTOCK\tVIRTUALPARENTCODE\tCATEGORYPATHJSON\tISCATEGORY");
124
+ fwrite($handle, "\n");
125
+
126
+ $products = Mage::getModel('catalog/product')->setStoreId($scope)->getCollection()->addAttributeToSelect('name')->addAttributeToSelect('*')->addAttributeToSelect('price')->addAttributeToSelect('image');
127
+ if ($products) {
128
+ foreach ($products as $product) {
129
+ $product->setStoreId($scope);
130
+ fwrite($handle, $product->getSku());
131
+ fwrite($handle, "\t");
132
+ if($product->getImage() != null && $product->getImage() != "no_selection") {
133
+ fwrite($handle, Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getImage() ));
134
+ } else if ($product->getSmallImage() != null && $product->getSmallImage() != "no_selection") {
135
+ fwrite($handle, Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getSmallImage() ));
136
+ } else if ($product->getThumbnail() != null && $product->getThumbnail() != "no_selection") {
137
+ fwrite($handle, Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getThumbnail() ));
138
+ }
139
+ fwrite($handle, "\t");
140
+ fwrite($handle, $product->getName());
141
+ fwrite($handle, "\t");
142
+ fwrite($handle, $product->getPrice());
143
+ fwrite($handle, "\t");
144
+ //CURRENCY
145
+ fwrite($handle, "\t");
146
+ //ACTIVE
147
+ fwrite($handle, "Y");
148
+ fwrite($handle, "\t");
149
+ //ITEMURL
150
+ fwrite($handle, $product->getProductUrl());
151
+ fwrite($handle, "\t");
152
+ //CATEGORY
153
+ $ids = $product->getCategoryIds();
154
+ fwrite($handle, (isset($ids[0]) ? $ids[0] : ''));
155
+ fwrite($handle, "\t");
156
+ // KEYWORDS
157
+ fwrite($handle, "\t");
158
+ // REPLACEMENTSKU
159
+ fwrite($handle, "\t");
160
+ //VIRTUALPARENTCODE
161
+ fwrite($handle, "\t");
162
+ //CATEGORYPATHJSON
163
+ fwrite($handle, "\t");
164
+ //ISCATEGORY
165
+ fwrite($handle, "n");
166
+ fwrite($handle, "\n");
167
+ }
168
+ }
169
+
170
+ $categories = Mage::getModel('catalog/category')->setStoreId($scope)->getCollection()->addAttributeToSelect('name');
171
+ if ($categories) {
172
+ foreach ($categories as $category) {
173
+ if ($category->getId() == 1) {
174
+ continue;
175
+ }
176
+ $category->setStoreId($scope);
177
+ fwrite($handle, $category->getId());
178
+ fwrite($handle, "\t");
179
+ //IMAGEURL
180
+ fwrite($handle, "\t");
181
+ //TITLE
182
+ fwrite($handle, $category->getName());
183
+ fwrite($handle, "\t");
184
+ //PRICE
185
+ fwrite($handle, "\t");
186
+ //CURRENCY
187
+ fwrite($handle, "\t");
188
+ //ACTIVE
189
+ fwrite($handle, "Y");
190
+ fwrite($handle, "\t");
191
+ //ITEMURL
192
+ fwrite($handle, $category->getUrl());
193
+ fwrite($handle, "\t");
194
+ //CATEGORY
195
+ fwrite($handle, $category->getParentCategory()->getId());
196
+ fwrite($handle, "\t");
197
+ //KEYWORDS
198
+ fwrite($handle, "\t");
199
+ //REPLACEMENTSKU
200
+ fwrite($handle, "\t");
201
+ //VIRTUALPARENTCODE
202
+ fwrite($handle, "\t");
203
+ //CATEGORYPATHJSON
204
+ fwrite($handle, "\t");
205
+ //ISCATEGORY
206
+ fwrite($handle, "Y");
207
+ fwrite($handle, "\n");
208
+
209
+ }
210
+ }
211
+
212
+ fclose($handle);
213
+
214
+ $message = $this->__('The catalog feed was successfully generated. Click the &quot;Download catalog feed&quot; link to download.');
215
+ }
216
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
217
+ } catch (Exception $e) {
218
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
219
+ }
220
+
221
+ if($catalogFeed){
222
+ $this->_redirect('*/*/', array('active_tab' => 'turnto_catalog_feed_tab'));
223
+ }else{
224
+ $this->_redirectUrl(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'media/turnto/histfeed.csv');
225
+ }
226
+ }
227
+ }
app/code/community/Turnto/Admin/controllers/IndexController.php CHANGED
@@ -1,120 +1,133 @@
1
- <?php
2
-
3
- class Turnto_Admin_IndexController extends Mage_Core_Controller_Front_Action{
4
- public function indexAction(){
5
- $resource = Mage::getSingleton('core/resource');
6
- $readConnection = $resource->getConnection('core_read');
7
-
8
- $params = $this->getRequest()->getParams();
9
- $scope = $params['scope'];
10
- $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
11
- $baseMediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
12
- if(isset($scope)){
13
- $baseUrl = Mage::app()->getStore($scope)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
14
- $baseMediaUrl = Mage::app()->getStore($scope)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
15
- }
16
-
17
- echo "SKU\tIMAGEURL\tTITLE\tPRICE\tCURRENCY\tACTIVE\tITEMURL\tCATEGORY\tKEYWORDS\tREPLACEMENTSKU\tINSTOCK\tVIRTUALPARENTCODE\tCATEGORYPATHJSON\tISCATEGORY";
18
- echo "\n";
19
-
20
- $products = Mage::getModel('catalog/product')->setStoreId($scope)->getCollection()->addAttributeToSelect('name')->addAttributeToSelect('*')->addAttributeToSelect('price')->addAttributeToSelect('image');
21
- if ($products) {
22
- foreach ($products as $product) {
23
- $parents = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
24
- if(isset($parents[0]))
25
- {
26
- // skip products with a parent
27
- continue;
28
- }
29
- $product->setStoreId($scope);
30
- echo $product->getSku();
31
- echo "\t";
32
- //echo Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getImage() );
33
- if($product->getImage() != null && $product->getImage() != "no_selection") {
34
- echo Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getImage() );
35
- } else if ($product->getSmallImage() != null && $product->getSmallImage() != "no_selection") {
36
- echo Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getSmallImage() );
37
- } else if ($product->getThumbnail() != null && $product->getThumbnail() != "no_selection") {
38
- echo Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getThumbnail() );
39
- }
40
- echo "\t";
41
- echo $product->getName();
42
- echo "\t";
43
- echo $product->getPrice();
44
- echo "\t";
45
- //CURRENCY
46
- echo "\t";
47
- //ACTIVE
48
- echo 'Y';
49
- echo "\t";
50
- //ITEMURL
51
- echo $product->getProductUrl();
52
- echo "\t";
53
- //CATEGORY
54
- $ids = $product->getCategoryIds();
55
- echo (isset($ids[0]) ? $ids[0] : '');
56
- echo "\t";
57
- // KEYWORDS
58
- echo "\t";
59
- // REPLACEMENTSKU
60
- echo "\t";
61
- //VIRTUALPARENTCODE
62
- echo "\t";
63
- //CATEGORYPATHJSON
64
- echo "\t";
65
- //ISCATEGORY
66
- echo "n";
67
- echo "\n";
68
- }
69
- }
70
-
71
- $categories = Mage::getModel('catalog/category')->setStoreId($scope)->getCollection()->addAttributeToSelect('*');
72
- if ($categories) {
73
- foreach ($categories as $category) {
74
- if ($category->getId() == 1) {
75
- continue;
76
- }
77
- $category->setStoreId($scope);
78
- echo $category->getId();
79
- echo "\t";
80
- //IMAGEURL
81
- echo "\t";
82
- //TITLE
83
- echo $category->getName();
84
- echo "\t";
85
- //PRICE
86
- echo "\t";
87
- //CURRENCY
88
- echo "\t";
89
- //ACTIVE
90
- echo "Y";
91
- echo "\t";
92
- //ITEMURL
93
- echo $category->getUrl();
94
- echo "\t";
95
- //CATEGORY
96
- echo $category->getParentCategory()->getId();
97
- echo "\t";
98
- //KEYWORDS
99
- echo "\t";
100
- //REPLACEMENTSKU
101
- echo "\t";
102
- //VIRTUALPARENTCODE
103
- echo "\t";
104
- //CATEGORYPATHJSON
105
- echo "\t";
106
- //ISCATEGORY
107
- echo "Y";
108
- echo "\n";
109
-
110
- }
111
- }
112
-
113
-
114
- return;
115
-
116
-
117
- }
118
- }
119
-
120
-
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Turnto_Admin_IndexController extends Mage_Core_Controller_Front_Action{
4
+ public function indexAction(){
5
+ $resource = Mage::getSingleton('core/resource');
6
+ $readConnection = $resource->getConnection('core_read');
7
+ $params = $this->getRequest()->getParams();
8
+ $storeId = $params['storeId'];
9
+ $websiteId = $params['websiteId'];
10
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
11
+ $baseMediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
12
+ if(!isset($storeId)){
13
+ $storeId = 1;
14
+ }
15
+ $baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
16
+ $baseMediaUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product';
17
+
18
+ if(!isset($websiteId)){
19
+ $websiteId=1;
20
+ }
21
+
22
+ echo "SKU\tIMAGEURL\tTITLE\tPRICE\tCURRENCY\tACTIVE\tITEMURL\tCATEGORY\tKEYWORDS\tREPLACEMENTSKU\tINSTOCK\tVIRTUALPARENTCODE\tCATEGORYPATHJSON\tISCATEGORY";
23
+ echo "\n";
24
+
25
+ $products = Mage::getModel('catalog/product')->setStoreId($storeId)->getCollection()->addAttributeToSelect('name')->addAttributeToSelect('*')->addAttributeToSelect('price')->addAttributeToSelect('image')->addWebsiteFilter($websiteId);
26
+ $products->setPageSize(100);
27
+ $pages = $products->getLastPageNumber();
28
+ $currentPage = 1;
29
+ if ($products) {
30
+ do {
31
+ $products->setCurPage($currentPage);
32
+ foreach ($products as $product) {
33
+ $parents = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
34
+ if(isset($parents[0]))
35
+ {
36
+ // skip products with a parent
37
+ continue;
38
+ }
39
+ $product->setStoreId($storeId);
40
+ echo $product->getSku();
41
+ echo "\t";
42
+ //echo Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getImage() );
43
+ if($product->getImage() != null && $product->getImage() != "no_selection") {
44
+ echo Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getImage() );
45
+ } else if ($product->getSmallImage() != null && $product->getSmallImage() != "no_selection") {
46
+ echo Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getSmallImage() );
47
+ } else if ($product->getThumbnail() != null && $product->getThumbnail() != "no_selection") {
48
+ echo Mage::getModel('catalog/product_media_config')->getMediaUrl( $product->getThumbnail() );
49
+ }
50
+ echo "\t";
51
+ echo $product->getName();
52
+ echo "\t";
53
+ echo $product->getPrice();
54
+ echo "\t";
55
+ //CURRENCY
56
+ echo "\t";
57
+ //ACTIVE
58
+ echo 'Y';
59
+ echo "\t";
60
+ //ITEMURL
61
+ echo $product->getProductUrl();
62
+ echo "\t";
63
+ //CATEGORY
64
+ $ids = $product->getCategoryIds();
65
+ echo (isset($ids[0]) ? $ids[0] : '');
66
+ echo "\t";
67
+ // KEYWORDS
68
+ echo "\t";
69
+ // REPLACEMENTSKU
70
+ echo "\t";
71
+ //VIRTUALPARENTCODE
72
+ echo "\t";
73
+ //CATEGORYPATHJSON
74
+ echo "\t";
75
+ //ISCATEGORY
76
+ echo "n";
77
+ echo "\n";
78
+ }
79
+ $currentPage++;
80
+ $products->clear();
81
+ } while ($currentPage <= $pages);
82
+ }
83
+
84
+ $categories = Mage::getModel('catalog/category')->setStoreId($storeId)->getCollection()->addAttributeToSelect('*');
85
+ if ($categories) {
86
+ foreach ($categories as $category) {
87
+ if ($category->getId() == 1) {
88
+ continue;
89
+ }
90
+ $category->setStoreId($storeId);
91
+ echo $category->getId();
92
+ echo "\t";
93
+ //IMAGEURL
94
+ echo "\t";
95
+ //TITLE
96
+ echo $category->getName();
97
+ echo "\t";
98
+ //PRICE
99
+ echo "\t";
100
+ //CURRENCY
101
+ echo "\t";
102
+ //ACTIVE
103
+ echo "Y";
104
+ echo "\t";
105
+ //ITEMURL
106
+ echo $category->getUrl();
107
+ echo "\t";
108
+ //CATEGORY
109
+ echo $category->getParentCategory()->getId();
110
+ echo "\t";
111
+ //KEYWORDS
112
+ echo "\t";
113
+ //REPLACEMENTSKU
114
+ echo "\t";
115
+ //VIRTUALPARENTCODE
116
+ echo "\t";
117
+ //CATEGORYPATHJSON
118
+ echo "\t";
119
+ //ISCATEGORY
120
+ echo "Y";
121
+ echo "\n";
122
+
123
+ }
124
+ }
125
+
126
+
127
+ return;
128
+
129
+
130
+ }
131
+ }
132
+
133
+
app/design/adminhtml/default/default/template/turnto/catalog_feed_tab.phtml CHANGED
@@ -1,10 +1,10 @@
1
  <h4>Catalog Feed</h4>
2
  <p style="width:650px">Go to your Settings in TurnTo Management area and enter:
3
  <br>
4
- <i><?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . 'turntocatalogfeed';?><?php if(count(Mage::registry('sites')) > 1) { ?>?scope=SCOPE_ID<?php } ?></i>
5
  <br>
6
- <?php if(count(Mage::registry('sites')) > 1) { ?>
7
- <b>NOTE: You appear to have two sites on your magento installation so you will need to supply a scope in the URL. Replace <i>SCOPE_ID</i> in the url above with the appropriate scope from the drop-down below (just the number. For instance: scope=1)</b>
8
  <br>
9
  <?php } ?>
10
  <br>
@@ -32,19 +32,22 @@ To manually create a catalog feed press Generate to build a catalog feed. This f
32
  <td><input id="authKey" name="authKey" type="text" /></td>
33
  </tr>
34
  -->
35
- <?php if(count(Mage::registry('sites')) > 1) { ?>
36
  <tr>
37
- <td>Scope:</td>
38
- <td><select id="scope" name="scope">
39
- <?php
40
- $sites = Mage::registry('sites');
41
- foreach($sites as $site) {
42
- echo '<option value="'.$site->getId().'">'.$site->getId().': '.$site->getName().'</option>';
43
- }
44
- ?>
45
- </td>
 
 
 
 
 
46
  </tr>
47
- <?php } ?>
48
  <tr>
49
  <td></td>
50
  <td align="right">
1
  <h4>Catalog Feed</h4>
2
  <p style="width:650px">Go to your Settings in TurnTo Management area and enter:
3
  <br>
4
+ <i><?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . 'turntocatalogfeed';?><?php if(count(Mage::registry('websites')) > 1) { ?>?websiteId=WEBSITE_ID<?php } ?><?php if(count(Mage::registry('stores')) > 1) { ?>&storeId=STORE_ID<?php } ?></i>
5
  <br>
6
+ <?php if(count(Mage::registry('stores')) > 1 || count(Mage::registry('websites'))) { ?>
7
+ <b>NOTE: You appear to have multiple sites or stores on your magento installation so you will need to supply a scope in the URL. Replace <i>WEBSITE_ID</i> and <i>STORE_ID</i> in the url above with the appropriate values from the drop-downs below (just the number. For instance: siteId=1)</b>
8
  <br>
9
  <?php } ?>
10
  <br>
32
  <td><input id="authKey" name="authKey" type="text" /></td>
33
  </tr>
34
  -->
 
35
  <tr>
36
+ <?php
37
+ echo '<td>Website/Store:</td>';
38
+ echo '<td><select id="websiteId" name="websiteId">';
39
+ foreach (Mage::registry('websites') as $website) {
40
+ foreach ($website->getGroups() as $group) {
41
+ $stores = $group->getStores();
42
+ foreach ($stores as $store) {
43
+ //echo '<option value="'.$website->getId().'_'.store->getId().'">Website</option>';
44
+ echo '<option value="'.$website->getId().'_'.$store->getId().'">'.$website->getId().': '.$website->getName().' '.$store->getId().': '.$store->getName().'</option>';
45
+ }
46
+ }
47
+ }
48
+ echo '</select></td>'
49
+ ?>
50
  </tr>
 
51
  <tr>
52
  <td></td>
53
  <td align="right">
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>socialcommerce_suite_by_turnto</name>
4
- <version>2.1.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.turntonetworks.com/terms-of-use">TurnTo Networks</license>
7
  <channel>community</channel>
@@ -10,11 +10,12 @@
10
  <description>The TurnTo Social Commerce Suite helps you put the good will you have earned from your customers to work by opening direct communications between your shoppers and your past customers.</description>
11
  <notes>TurnTo Admin Extension&#xD;
12
  2.0 Adds support for Single Sign On&#xD;
13
- 2.1 Re-wrote catalog feed generator</notes>
14
- <authors><author><name>TurnTo Networks</name><user>TurnTo</user><email>contact@turnto.com</email></author></authors>
15
- <date>2014-08-11</date>
16
- <time>19:38:24</time>
17
- <contents><target name="magecommunity"><dir name="Turnto"><dir name="Admin"><dir name="Block"><file name="CatalogFeed.php" hash="f974cfdc687bf5edb3fdccb879547200"/><file name="HistoricalFeed.php" hash="a4d2b29c6d8bb2ed59aa884e02abc23b"/><file name="Overview.php" hash="51c8ed09153f1dc3b3d02aa0ab83f195"/><file name="ShowTabsAdminBlock.php" hash="d904239a91cc367e93c138eff3e2b074"/></dir><dir name="Helper"><file name="Data.php" hash="78a1e318ccf05caac4ca7a8c2bd74e43"/></dir><dir name="controllers"><dir name="AdminControllers"><file name="TurntoController.php" hash="72374095498b8f1d8d6aaee8e9abb7ce"/></dir><file name="IndexController.php" hash="38e7ea32a280d77f89d38f6e7f767138"/><file name=".IndexController.php.swp" hash="5c6828d792a9488bd97ec92017881459"/></dir><dir name="etc"><file name="config.xml" hash="27ba1dd7b8e34b0587ac647142aee2c7"/></dir></dir><dir name="Login"><dir name="Block"><file name="Login.php" hash="a51bc0ee76d20a9f4cb32bb21420ecd9"/><file name="Reg.php" hash="4eece8d78391b6578b0ba5e2c764dba5"/></dir><dir name="Helper"><file name="Data.php" hash="e87f15957335101d5ae643befcc06817"/></dir><dir name="controllers"><file name="IndexController.php" hash="087867555ca6d8174fb1301f3b558720"/></dir><dir name="etc"><file name="config.xml" hash="f165478215331e4eea171856de2b65fe"/></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Turnto_Admin.xml" hash="0932b63ab068e1e8b12ff7b997ae83ee"/><file name="Turnto_Login.xml" hash="734c463c75970bd14ac7d7a90fa2de11"/></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="turnto"><file name="catalog_feed_tab.phtml" hash="65f52f02bf6afa8c414faf95eeb1b826"/><file name="historical_feed_tab.phtml" hash="510bee39f490fe289e28e796ba0d43f2"/><file name="overview.phtml" hash="4cc20b32c3b0cd36cd349f0be44e4615"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="turnto"><dir name="login"><file name="login.phtml" hash="7ec602a8ca09180f324229a77ea3e2db"/><file name="login_form.phtml" hash="a176124e54fc105d09e8a219114d9cfe"/><file name="reg.phtml" hash="7ec602a8ca09180f324229a77ea3e2db"/><file name="reg_form.phtml" hash="8d513aa7b9b582f748f5a484f2e81568"/></dir></dir></dir><dir name="layout"><file name="turnto_login.xml" hash="e9c1993c14add5a7be5c4079547d3609"/></dir></dir></dir></dir></dir></target></contents>
 
18
  <compatible/>
19
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>socialcommerce_suite_by_turnto</name>
4
+ <version>2.1.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.turntonetworks.com/terms-of-use">TurnTo Networks</license>
7
  <channel>community</channel>
10
  <description>The TurnTo Social Commerce Suite helps you put the good will you have earned from your customers to work by opening direct communications between your shoppers and your past customers.</description>
11
  <notes>TurnTo Admin Extension&#xD;
12
  2.0 Adds support for Single Sign On&#xD;
13
+ 2.1 Re-wrote catalog feed generator&#xD;
14
+ </notes>
15
+ <authors><author><name>TurnTo</name><user>TurnTo</user><email>contact@turnto.com</email></author></authors>
16
+ <date>2015-02-20</date>
17
+ <time>19:59:30</time>
18
+ <contents><target name="magecommunity"><dir name="Turnto"><dir name="Admin"><dir name="Block"><file name="CatalogFeed.php" hash="f974cfdc687bf5edb3fdccb879547200"/><file name="HistoricalFeed.php" hash="a4d2b29c6d8bb2ed59aa884e02abc23b"/><file name="Overview.php" hash="51c8ed09153f1dc3b3d02aa0ab83f195"/><file name="ShowTabsAdminBlock.php" hash="d904239a91cc367e93c138eff3e2b074"/></dir><dir name="Helper"><file name="Data.php" hash="78a1e318ccf05caac4ca7a8c2bd74e43"/></dir><dir name="controllers"><dir name="AdminControllers"><file name="TurntoController.php" hash="690057e9429e3454939976232f0ccb22"/><file name="TurntoController.php.bkup" hash="72374095498b8f1d8d6aaee8e9abb7ce"/><file name=".TurntoController.php.swp" hash="2e5f388df8fa1bf93d34c12644454856"/></dir><file name="IndexController.php" hash="47f6387a680b85bdeeca6b89fe9c76aa"/><file name=".IndexController.php.swo" hash="9fe1be1d74e273018c523559e88f8950"/></dir><dir name="etc"><file name="config.xml" hash="27ba1dd7b8e34b0587ac647142aee2c7"/></dir></dir><dir name="Login"><dir name="Block"><file name="Login.php" hash="a51bc0ee76d20a9f4cb32bb21420ecd9"/><file name="Reg.php" hash="4eece8d78391b6578b0ba5e2c764dba5"/></dir><dir name="Helper"><file name="Data.php" hash="e87f15957335101d5ae643befcc06817"/></dir><dir name="controllers"><file name="IndexController.php" hash="087867555ca6d8174fb1301f3b558720"/></dir><dir name="etc"><file name="config.xml" hash="f165478215331e4eea171856de2b65fe"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Turnto_Admin.xml" hash="0932b63ab068e1e8b12ff7b997ae83ee"/><file name="Turnto_Login.xml" hash="734c463c75970bd14ac7d7a90fa2de11"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="turnto"><file name="catalog_feed_tab.phtml" hash="c7623db3227221f10a32de69322bead9"/><file name="historical_feed_tab.phtml" hash="510bee39f490fe289e28e796ba0d43f2"/><file name="overview.phtml" hash="4cc20b32c3b0cd36cd349f0be44e4615"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="turnto"><dir name="login"><file name="login.phtml" hash="7ec602a8ca09180f324229a77ea3e2db"/><file name="login_form.phtml" hash="a176124e54fc105d09e8a219114d9cfe"/><file name="reg.phtml" hash="7ec602a8ca09180f324229a77ea3e2db"/><file name="reg_form.phtml" hash="8d513aa7b9b582f748f5a484f2e81568"/></dir></dir></dir><dir name="layout"><file name="turnto_login.xml" hash="e9c1993c14add5a7be5c4079547d3609"/></dir></dir></dir></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
21
  </package>