Mage_PDF_per_Product - Version 4.0.0

Version Notes

This extension puts a PDF icon on every product page. The PDF icon links to a Catalog-on-Demand Always Fresh flyer. This is meant to be used in conjunction with Print Catalog Software as a Service (SaaS) extension at http://www.magentocommerce.com/magento-connect/print-catalog-software-as-a-service-saas.html

Download this release

Release Info

Developer Magento Core Team
Extension Mage_PDF_per_Product
Version 4.0.0
Comparing to
See all releases


Code changes from version 3.0.9 to 4.0.0

Files changed (25) hide show
  1. app/code/community/Mage/Codi/Block/Adminhtml/Menu.php +0 -10
  2. app/code/community/Mage/Codi/Block/Adminhtml/Switcher.php +0 -109
  3. app/code/community/Mage/Codi/Block/Customer/Codi.php +0 -526
  4. app/code/community/Mage/Codi/Codi_Process.php +0 -20
  5. app/code/community/Mage/Codi/Helper/Createzip.php +0 -87
  6. app/code/community/Mage/Codi/Helper/Data.php +0 -322
  7. app/code/community/Mage/Codi/Model/Codi.php +0 -1447
  8. app/code/community/Mage/Codi/controllers/Adminhtml/MenuController.php +0 -327
  9. app/code/community/Mage/Codi/controllers/DeleteController.php +0 -37
  10. app/code/community/Mage/Codi/controllers/NsyncController.php +0 -178
  11. app/code/community/Mage/Codi/controllers/SyncController.php +0 -215
  12. app/code/community/Mage/Codi/etc/config.xml +0 -146
  13. app/code/community/Mage/Codi/sql/codi_setup/mysql4-install-3.0.4.php +0 -19
  14. app/code/community/Mage/Codi/sql/codi_setup/mysql4-install-3.0.6.php +0 -19
  15. app/code/community/Mage/CodiPDF/Block/Adminhtml/Menu.php +10 -0
  16. app/code/community/Mage/CodiPDF/Model/Codipdf.php +57 -0
  17. app/code/community/Mage/CodiPDF/controllers/Adminhtml/MenuController.php +116 -0
  18. app/code/community/Mage/CodiPDF/etc/config.xml +65 -0
  19. app/design/adminhtml/default/default/layout/{codi.xml → codipdf.xml} +3 -3
  20. app/design/adminhtml/default/default/template/{codi → codipdf}/index.phtml +34 -487
  21. app/design/frontend/default/default/template/catalog/product/view.phtml +12 -12
  22. app/etc/modules/{Mage_Codi.xml → Mage_CodiPDF.xml} +2 -2
  23. package.xml +7 -7
  24. skin/adminhtml/default/default/images/codimport_run.gif +0 -0
  25. skin/adminhtml/default/default/images/codimport_yes.gif +0 -0
app/code/community/Mage/Codi/Block/Adminhtml/Menu.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- class Mage_Codi_Block_Adminhtml_Menu extends Mage_Adminhtml_Block_Template
4
- {
5
- public function __construct()
6
- {
7
- parent::__construct();
8
- $this->setTemplate('codi/index.phtml');
9
- }
10
- }
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Block/Adminhtml/Switcher.php DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Mage
22
- * @package Mage_Adminhtml
23
- * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
-
28
- class Mage_Codi_Block_Adminhtml_Switcher extends Mage_Adminhtml_Block_Template
29
- {
30
- protected function _prepareLayout()
31
- {
32
- $this->setTemplate('codi/switcher.phtml');
33
- return parent::_prepareLayout();
34
- }
35
-
36
- /**
37
- * Enter description here...
38
- *
39
- * @return array
40
- */
41
- public function getStoreSelectOptions()
42
- {
43
- $section = $this->getRequest()->getParam('section');
44
-
45
- $curWebsite = $this->getRequest()->getParam('website');
46
- $curStore = $this->getRequest()->getParam('store');
47
-
48
- $storeModel = Mage::getSingleton('adminhtml/system_store');
49
- /* @var $storeModel Mage_Adminhtml_Model_System_Store */
50
-
51
- $url = Mage::getModel('adminhtml/url');
52
-
53
- $options = array();
54
- $options['default'] = array(
55
- 'label' => Mage::helper('adminhtml')->__('Default Config'),
56
- 'url' => $url->getUrl('*/*/*', array('section'=>$section)),
57
- 'selected' => !$curWebsite && !$curStore,
58
- 'style' => 'background:#ccc; font-weight:bold;',
59
- );
60
-
61
- foreach ($storeModel->getWebsiteCollection() as $website) {
62
- $websiteShow = false;
63
- foreach ($storeModel->getGroupCollection() as $group) {
64
- if ($group->getWebsiteId() != $website->getId()) {
65
- continue;
66
- }
67
- $groupShow = false;
68
- foreach ($storeModel->getStoreCollection() as $store) {
69
- if ($store->getGroupId() != $group->getId()) {
70
- continue;
71
- }
72
- if ($websiteShow) {
73
- $websiteShow = true;
74
- $options['website_' . $website->getCode()] = array(
75
- 'label' => $website->getName(),
76
- 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode())),
77
- 'selected' => !$curStore && $curWebsite == $website->getCode(),
78
- 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
79
- );
80
- }
81
- if (!$groupShow) {
82
- $groupShow = true;
83
- $options['group_' . $group->getId() . '_open'] = array(
84
- 'is_group' => true,
85
- 'is_close' => false,
86
- 'label' => $group->getName(),
87
- 'style' => 'padding-left:32px;'
88
- );
89
- }
90
- $options['store_' . $store->getCode()] = array(
91
- 'label' => $store->getName(),
92
- 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode(), 'store'=>$store->getCode())),
93
- 'selected' => $curStore == $store->getCode(),
94
- 'style' => '',
95
- );
96
- }
97
- if ($groupShow) {
98
- $options['group_' . $group->getId() . '_close'] = array(
99
- 'is_group' => true,
100
- 'is_close' => true,
101
- );
102
- }
103
- }
104
- }
105
-
106
- return $options;
107
- }
108
-
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Block/Customer/Codi.php DELETED
@@ -1,526 +0,0 @@
1
- <?php
2
- ini_set("max_execution_time", 3600);
3
- ini_set('session.gc_maxlifetime', 3600);
4
- ini_set("memory_limit","256M");
5
-
6
- class Mage_Codi_Block_Customer_Codi extends Mage_Wishlist_Block_Customer_Wishlist
7
- {
8
-
9
- protected $_wishlistLoaded = false;
10
- public $m_DataFile = "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductMfg\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tCategory\tReviews\tSupplementalInfo";
11
- // public $ProductModel ;
12
- // public $ConfigurableModel ;
13
- public $mediaurl ;
14
- public $RootCategories ;
15
- public $enablereviews ;
16
- public $StoreId ;
17
- public $reviewsModel ;
18
- public $ratingModel ;
19
-
20
- public function _construct()
21
- {
22
- // $this->ProductModel = Mage::getModel('catalog/product') ;
23
- // $this->ConfigurableModel = Mage::getModel('catalog/product_type_configurable') ;
24
- $this->mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) ;
25
-
26
- // Get Root Categories to eliminate them from being send -Start
27
- $RootCategoriesArray = Mage::getModel('adminhtml/system_config_source_category')->toOptionArray();
28
- $RootCategories = array();
29
- foreach($RootCategoriesArray as $RootCategory):
30
- if($RootCategory['value']) array_push($RootCategories, $RootCategory['value'] );
31
- endforeach;
32
-
33
- $this->RootCategories = $RootCategories ;
34
- // Get Root Categories to eliminate them from being send -End
35
-
36
- $this->enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
37
- $this->fromchild = Mage::getStoreConfig('codi/codi/fromchild') ;
38
-
39
- // Get StoreID -Start
40
- foreach (Mage::app()->getWebsites() as $website)
41
- {
42
- $defaultGroup = $website->getDefaultGroup();
43
- $StoreId = $defaultGroup->getDefaultStoreId();
44
- }
45
-
46
- $this->StoreId = $StoreId ;
47
- // Get StoreID -End
48
-
49
- $this->reviewsModel = Mage::getModel('review/review') ;
50
- $this->ratingModel = Mage::getModel('rating/rating_option_vote') ;
51
-
52
- $this->_logFile = "Catalog-on-demand.log";
53
- }
54
-
55
-
56
- protected function _prepareLayout()
57
- {
58
- if ($headBlock = $this->getLayout()->getBlock('head')) {
59
- $headBlock->setTitle($this->__('My Wishlist'));
60
- }
61
- }
62
-
63
- public function getWishlist()
64
- {
65
- if(!$this->_wishlistLoaded) {
66
- Mage::registry('wishlist')
67
- ->loadByCustomer(Mage::getSingleton('customer/session')->getCustomer());
68
-
69
- $collection = Mage::registry('wishlist')->getProductCollection()
70
- ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
71
- ->addStoreFilter();
72
-
73
- Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
74
- Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
75
-
76
- $this->_wishlistLoaded = true;
77
- }
78
- return Mage::registry('wishlist')->getProductCollection();
79
- }
80
-
81
- public function ProcessDataFileImport($m_DataFile)
82
- {
83
- $codimodel = Mage::getSingleton('codi/codi');
84
- $userid = Mage::getStoreConfig('codi/codi/codusername') ;
85
- $password = Mage::getStoreConfig('codi/codi/codpassword') ;
86
- $url = "https://webservices.catalog-on-demand.com/onDemandPublishingProcessor.do" ;
87
- $paramsarray = array(
88
- 'Operation' => "ProcessDataFileImport" ,
89
- 'UserID' => $userid ,
90
- 'Password' => $password ,
91
- 'ClearDatabase' => "All" ,
92
- 'CatalogProject'=> "Magento" ,
93
- 'DataFileText' => str_replace("'" , "&apos;" , $m_DataFile) );
94
-
95
- $Responsemsg = $codimodel->Call( $url, $paramsarray );
96
- if( $Responsemsg )
97
- {
98
- if($Responsemsg->Message=="OK")
99
- {
100
- echo "Your site data has been posted to the Catalog-On-Demand database and will be available for sharing and/or publishing within 5-10 minutes.";
101
- }
102
- }
103
- else
104
- echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
105
- }
106
-
107
- public function LaunchSponsoredCoDSite($m_DataFile)
108
- {
109
- $codimodel = Mage::getSingleton('codi/codi');
110
- $userid = Mage::getStoreConfig('codi/codi/codusername') ;
111
- $password = Mage::getStoreConfig('codi/codi/codpassword') ;
112
-
113
- $customerid = "" ;
114
- $customerdatasourceid = "" ;
115
- $validateuser = "" ;
116
- $url = "https://webservices.catalog-on-demand.com/smanager/api.do?Operation=ValidateUser&ResponseGroups=All&FunctionGroups=All" ;
117
- $paramsarray = array('UserID' => $userid ,
118
- 'Password' => $password );
119
- $Responsemsg = $codimodel->Call( $url, $paramsarray );
120
- if( $Responsemsg )
121
- {
122
- if($Responsemsg->Message=="OK")
123
- {
124
- $customerid = (string)$Responsemsg->ValidateUserResponse->User->Customer->CustomerID ;
125
- $customername = (string)$Responsemsg->ValidateUserResponse->User->Customer->Name ;
126
- $customerdatasourceid = (string)$Responsemsg->ValidateUserResponse->User->Customer->DataSource->ID ;
127
- $validateuser = (string)$Responsemsg->Message;
128
- }
129
-
130
- echo "<html><body>" ;
131
- $form = ""; for ($i=0 ; $i<=100 ; $i++) { $form .= "<br>" ; } echo $form ; //hide tmp characters
132
- ?>
133
- <FORM name='publishitems' method='POST' enctype='multipart/form-data' action='https://webservices.catalog-on-demand.com/aservices/api.do'>
134
- <input type='hidden' name='Operation' value='LaunchSponsoredCoDSite'>
135
- <input type='hidden' name='HideScreens' value='SelectItems'>
136
- <input type='hidden' name='UserID' value='<?php echo htmlentities($userid) ?>'>
137
- <input type='hidden' name='Password' value='<?php echo htmlentities($password) ?>'>
138
- <input type='hidden' name='Sponsor' value='<?php echo htmlentities($customerid) ?>'>
139
- <input type='hidden' name='DataFileText' value='<?php echo str_replace("'" , "&apos;" , $m_DataFile) ?>'>
140
- </FORM>
141
- <SCRIPT language="JavaScript">
142
- document.publishitems.submit();
143
- </SCRIPT>
144
- </body></html>
145
- <?php
146
- }
147
- else
148
- echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
149
- }
150
-
151
- public function ProducttoString( $product , $from )
152
- {
153
- if( $product->isConfigurable() )
154
- {
155
- return $this->ProducttoStringConfigurable( $product , $from ) ;
156
- }
157
- else
158
- {
159
- return $this->ProducttoStringSimple( $product , $from ) ;
160
- }
161
- }
162
-
163
- public function ProducttoStringConfigurable( $product , $from )
164
- {
165
- set_time_limit(0);
166
-
167
- $ProducttoString = '' ;
168
- $UsedProductIds = Mage::getModel('catalog/product_type_configurable')->getUsedProductIds($product);
169
-
170
- if( $from == "wishlist" )
171
- {
172
- $myproduct = '';
173
- $Comment = '' ;
174
- //Add Comment if exist
175
- $defaultcomment = $this->helper('wishlist')->defaultCommentString() ;
176
- if ( $product->getWishlistItemDescription() !== $defaultcomment )
177
- $Comment = "\\par{\\b Comment}\\par" . $product->getWishlistItemDescription() ;
178
- //Get Full Product
179
- $myproduct = Mage::getModel('catalog/product')->load($product->getProductID());
180
- //Get Product Description
181
- $ProductDescription = $myproduct->getDescription() ;
182
- $ProductDescription .= $Comment ;
183
- }
184
- else
185
- {
186
- $ProductDescription = $product->getDescription() ;
187
- }
188
-
189
- //Get Product Attributes Start
190
- //$excludeAttr = array() ;
191
- $attributes = $product->getAttributes();
192
-
193
- $ProductAttributes = "" ;
194
- foreach ($attributes as $attribute) {
195
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
196
- $value = $attribute->getFrontend()->getValue($product);
197
- if (is_string($value))
198
- {
199
- if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
200
- {
201
- $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
202
- }
203
- }
204
- }
205
- }
206
- $ProductAttributes = substr($ProductAttributes, 0, strlen($ProductAttributes)-1 ) ;
207
- //Get Product Attributes End
208
-
209
- foreach($UsedProductIds as $UsedProductid)
210
- {
211
- $UsedProduct = Mage::getModel('catalog/product')->load($UsedProductid);
212
- if( Mage::getStoreConfig('codi/codi/fromchild') )
213
- $UsedProductPrice = $UsedProduct->getFinalPrice() ;
214
- else
215
- $UsedProductPrice = $product->getFinalPrice() ; //default behavior
216
- //************************ Get Attributes Start *******************************
217
- //Extract Attributes
218
- //$ImageURL = (string)$this->helper('catalog/image')->init($UsedProduct, 'image');
219
- //$mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
220
- $ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
221
-
222
- //Get Item Attributes Start
223
- //$excludeAttr = array() ;
224
- $attributes = $UsedProduct->getAttributes();
225
-
226
- $ItemitemAttributes = "" ;
227
- $AllowAttributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
228
- foreach ($AllowAttributes as $attribute)
229
- {
230
- $AttributeCode = $attribute->getProductAttribute()->getAttributeCode() ;
231
- $AttributeLabel = $attribute->getProductAttribute()->getFrontend()->getLabel() ;
232
- $AttribId = $UsedProduct->getData($AttributeCode) ;
233
-
234
- $AttributeValue = "" ;
235
- foreach ( $attribute->getProductAttribute()->getSource()->getAllOptions() as $option )
236
- {
237
- if( $option['value'] == $AttribId )
238
- {
239
- $AttributeValue = $option['label'];
240
- }
241
- }
242
-
243
- $ItemitemAttributes .= $AttributeLabel . "=" . $AttributeValue . "|" ;
244
-
245
- //Get Delta Price Start
246
- foreach( $attribute->getPrices() as $addedPrice )
247
- {
248
- if ( $AttributeValue == $addedPrice['label'])
249
- {
250
- if( $addedPrice['is_percent'] )
251
- $UsedProductPrice += $UsedProductPrice * $addedPrice['pricing_value'] / 100;
252
- else
253
- $UsedProductPrice += $addedPrice['pricing_value'] ;
254
- }
255
- }
256
- //Get Delta Price End
257
- }
258
-
259
- $ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 );
260
-
261
- //Get Item Attributes End
262
- //************************ Get Attributes End ************************************
263
-
264
- //************************* Get Categories names Start ***************************
265
-
266
- $categories = $product->getCategoryIds();
267
-
268
- $CategoriesString = "" ;
269
- foreach($categories as $k => $_category_id){
270
-
271
- $_category = Mage::getModel('catalog/category')->load($_category_id) ;
272
- $path = $_category->getPathInStore();
273
- $pathIds = array_reverse(explode(',', $path));
274
-
275
- foreach($pathIds as $m => $_cat_id){
276
- $_cat = Mage::getModel('catalog/category')->load($_cat_id) ;
277
- // if( $_cat->getName() != '' && (string)$_cat->getLevel() != '1' && !(in_array($_cat_id, $this->RootCategories)) )
278
- if( ($_cat->getName() != '') && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
279
- $CategoriesString .= $_cat->getName() . "#$#" ;
280
- }
281
-
282
- if( substr($CategoriesString, strlen($CategoriesString)-3, 3) == "#$#" )
283
- {
284
- $CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-3 ) ;
285
- $CategoriesString .= "|";
286
- }
287
-
288
- }
289
-
290
- $CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-1 ) ;
291
-
292
- if ($CategoriesString=='') $CategoriesString = 'Uncategorized' ;
293
-
294
- //************************* Get Categories names End ***************************
295
-
296
- //************************* Get Reviews Start ***********************
297
- //$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
298
- $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
299
- //************************* Get Reviews End *************************
300
-
301
- //************************* Concatenate Product Info Start ***********************
302
- $ProducttoString .= "\r\n" . $this->cleanStr( $UsedProduct->getSku() ) ; //ItemID
303
- $ProducttoString .= "\t" . "" ; //ItemQty
304
- $ProducttoString .= "\t" . "" ; //ItemUom
305
- // $ProducttoString .= "\t" . $this->cleanStr( $product->getPrice() ) ; //ItemPrice
306
- $ProducttoString .= "\t" . $this->cleanStr( $UsedProductPrice ) ; //ItemPrice
307
- $ProducttoString .= "\t" . ""; //ItemDescription
308
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
309
- $ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ItemitemAttributes
310
- $ProducttoString .= "\t" . ""; //ItemitemGraphic
311
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
312
- $ProducttoString .= "\t" . "" ; //ProductMfg
313
- $ProducttoString .= "\t" . $this->cleanStr( $ProductDescription ) ; //ProductDescription
314
- $ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
315
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
316
- $ProducttoString .= "\t" . $this->cleanStr( $ProductAttributes ) ; //ProductAttributes
317
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
318
- $ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
319
- $ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
320
- //************************* Concatenate Product Info End ************************* cleanStr
321
- }
322
-
323
- return $ProducttoString ;
324
- }
325
- /////////////////////////////////////////// Simple Products ///////////////////////////////////////////////////////////////////
326
- public function ProducttoStringSimple( $product , $from )
327
- {
328
- set_time_limit(0);
329
-
330
- $ProducttoString = '' ;
331
- if($from == "wishlist")
332
- {
333
- $Comment = '' ;
334
- //Add Comment if exist
335
- $defaultcomment = $this->helper('wishlist')->defaultCommentString() ;
336
- if ( $product->getWishlistItemDescription() !== $defaultcomment )
337
- $Comment = "\\par{\\b Comment}\\par" . $product->getWishlistItemDescription() ;
338
- //Get Full Product
339
- $product = Mage::getModel('catalog/product')->load($product->getProductID());
340
- //Get Product Description
341
- $ProductDescription = $product->getDescription() ;
342
- $ProductDescription .= $Comment ;
343
- }
344
- else
345
- {
346
- $ProductDescription = $product->getDescription() ;
347
- }
348
-
349
- //************************ Get Attributes Start *******************************
350
- //Extract Attributes
351
- //$ImageURL = (string)$this->helper('catalog/image')->init($product, 'image');
352
- //$mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
353
- $ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
354
-
355
- //$excludeAttr = array() ;
356
- $attributes = $product->getAttributes();
357
- $ItemitemAttributes = "" ;
358
- foreach ($attributes as $attribute) {
359
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
360
- $value = $attribute->getFrontend()->getValue($product);
361
- if (is_string($value))
362
- {
363
- if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
364
- {
365
- $ItemitemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
366
- }
367
- }
368
- }
369
- }
370
- $ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 ) ;
371
- //************************ Get Attributes End ************************************
372
-
373
- //************************* Get Categories names Start ***************************
374
-
375
- $categories = $product->getCategoryIds();
376
- $CategoriesString = "" ;
377
- foreach($categories as $k => $_category_id){
378
-
379
- $_category = Mage::getModel('catalog/category')->load($_category_id) ;
380
- $path = $_category->getPathInStore();
381
- $pathIds = array_reverse(explode(',', $path));
382
-
383
- foreach($pathIds as $m => $_cat_id){
384
- $_cat = Mage::getModel('catalog/category')->load($_cat_id) ;
385
- // if( $_cat->getName() != '' && (string)$_cat->getLevel() != '1' && !(in_array($_cat_id, $this->RootCategories)) )
386
- if( ($_cat->getName() != '') && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
387
- $CategoriesString .= $_cat->getName() . "#$#" ;
388
- }
389
-
390
- if( substr($CategoriesString, strlen($CategoriesString)-3, 3) == "#$#" )
391
- {
392
- $CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-3 );
393
- $CategoriesString .= "|";
394
- }
395
- }
396
-
397
- $CategoriesString = substr($CategoriesString, 0, strlen($CategoriesString)-1 ) ;
398
- if ($CategoriesString == '' ) $CategoriesString = 'Uncategorized' ;
399
- //************************* Get Categories names End ***************************
400
-
401
- //************************* Get Reviews Start ***********************
402
- //$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
403
- //if($enablereviews) { $Reviews = $this->getReviews($product->getId()) ; }
404
- $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
405
- //************************* Get Reviews End *************************
406
-
407
- //************************* Concatenate Product Info Start ***********************
408
-
409
- $ProducttoString .= "\r\n" . $this->cleanStr( $product->getSku() ) ; //ItemID
410
- $ProducttoString .= "\t" . "" ; //ItemQty
411
- $ProducttoString .= "\t" . "" ; //ItemUom
412
- $ProducttoString .= "\t" . $this->cleanStr( $product->getFinalPrice() ) ; //ItemPrice
413
- $ProducttoString .= "\t" . ""; //ItemDescription
414
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
415
- $ProducttoString .= "\t" . ""; //ItemitemAttributes
416
- $ProducttoString .= "\t" . ""; //ItemitemGraphic
417
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
418
- $ProducttoString .= "\t" . "" ; //ProductMfg
419
- $ProducttoString .= "\t" . $this->cleanStr( $ProductDescription ) ; //ProductDescription
420
- $ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
421
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
422
- $ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ProductAttributes
423
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
424
- $ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
425
- $ProducttoString .= "\t" . $this->cleanStr( $product->getShortDescription() ); //ShortDescription (Quick Overview)
426
- //************************* Concatenate Product Info End ************************* cleanStr
427
-
428
- return $ProducttoString ;
429
- }
430
-
431
- public function getReviews( $productid )
432
- {
433
- $reviewsCollection = $this->reviewsModel->getCollection()
434
- ->addStoreFilter($this->StoreId)
435
- ->addStatusFilter('approved')
436
- ->addEntityFilter('product', $productid)
437
- ->setDateOrder();
438
-
439
- $Reviews = "" ;
440
- foreach($reviewsCollection as $review)
441
- {
442
- $ratingCollection = $this->ratingModel
443
- ->getResourceCollection()
444
- ->setReviewFilter($review->getReviewId())
445
- ->setStoreFilter($this->StoreId)
446
- ->addRatingInfo($this->StoreId)
447
- ->load();
448
- $Reviews .= "<p><b>".$review->getTitle()."(". $review->getNickname() .")</b><br>".$review->getDetail()."</p>" ;
449
- }
450
- return $Reviews ;
451
- }
452
-
453
- public function getWishListDataFile()
454
- {
455
- $m_DataFile = '' ;
456
-
457
- foreach($this->getWishlist() as $item):
458
- $m_DataFile .= $this->ProducttoString($item , "wishlist" ) ;
459
- endforeach ;
460
-
461
- return $this->m_DataFile . $m_DataFile ;
462
- }
463
-
464
- public function getcurrencysign()
465
- {
466
- try {
467
- $currencystr = Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE) ;
468
- $currency = new Zend_Currency($currencystr);
469
- Zend_Registry::set('Zend_Currency', $currency);
470
- return $currency->getSymbol();
471
- } catch (Exception $e) {
472
- return "US";
473
- }
474
- }
475
-
476
- public function ProcessBackgroundJob()
477
- {
478
- $m_DataFile = $this->getWishListDataFile() ;
479
-
480
- $codimodel = Mage::getSingleton('codi/codi');
481
- $userid = Mage::getStoreConfig('codi/codi/codusername') ;
482
- $password = Mage::getStoreConfig('codi/codi/codpassword') ;
483
-
484
- //Get Currency Sign
485
- $currencysign = $this->getcurrencysign() ;
486
- //Preparing the call
487
- $UserEmail = $this->getuseremail() ;
488
- $JobName = $this->getRequest()->getParam('JobName') ;
489
-
490
- $options = "_JobName=" . $JobName ;
491
- $options .= "||CurrencySymbol=" . $currencysign ;
492
- $options .= "||ClientAppVersion=" . "Magento" . Mage::getVersion() . "-Codi" . $codimodel->version ;
493
-
494
- $url = "https://webservices.catalog-on-demand.com/onDemandPublishingProcessor.do?Operation=ProcessBackgroundJob";
495
- $paramsarray = array('UserID' => $userid,
496
- 'Password' => $password,
497
- 'Email' => $UserEmail,
498
- 'Options' => $options,
499
- 'DataFileText' => $m_DataFile);
500
- //Calling
501
- $UserEmail = Mage::getSingleton('customer/session')->getCustomer()->getEmail() ; //Get User Email
502
- $Responsemsg = $codimodel->Call( $url, $paramsarray );
503
- if( $Responsemsg )
504
- {
505
- if($Responsemsg->Message=="OK")
506
- echo "Your Wishlist has been submitted to Catalog-On-Demand for publishing and should be complete within 5-10 minutes. Please monitor your email ($UserEmail) for a link to your PDF publication." ;
507
- else
508
- {
509
- echo "Error No. " . $Responsemsg->Errors->Error->Code . "<br>";
510
- echo $Responsemsg->Errors->Error->Description . "<br>";
511
- }
512
- }
513
- else
514
- echo "*There appears to be some problem in your installation’s ability to communicate with the Catalog-On-Demand server. Please contact Catalog-On-Demand support to report this problem." ;
515
- }
516
-
517
- public function cleanStr($localstr)
518
- {
519
- $localstr = str_replace("\t","", $localstr ) ;
520
- $localstr = str_replace("\r\n","<br>", $localstr ) ;
521
- $localstr = str_replace("\r","<br>", $localstr ) ;
522
- $localstr = str_replace("\n","<br>", $localstr ) ;
523
- return $localstr ;
524
- }
525
-
526
- }// class end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Codi_Process.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- $baseDir = dirname(__FILE__);
4
-
5
- $_baseDirArray = explode("app", $baseDir);
6
- $basePath = $_baseDirArray[0].'/';
7
-
8
- require $baseDir . '/../../../../../app/Mage.php';
9
-
10
- Mage::app();
11
-
12
- Mage::log("Notice: Start Create data file.", null, "Catalog-on-demand.log");
13
-
14
- $CodiModel = Mage::getModel('codi/codi');
15
-
16
- $CodiModel->run_codi_import($basePath);
17
-
18
- Mage::log("Notice: Finish Create data file.", null, "Catalog-on-demand.log");
19
-
20
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Helper/Createzip.php DELETED
@@ -1,87 +0,0 @@
1
- <?php
2
- /* Create zip of the files */
3
-
4
- class Mage_Codi_Helper_Createzip extends Mage_Core_Helper_Abstract
5
- {
6
- function get_files_from_folder($directory,$filename='',$put_into='') {
7
- if ($handle = opendir($directory)) {
8
- while (false !== ($file = readdir($handle))) {
9
- if (is_file($directory.$file)) {
10
- $fileContents = file_get_contents($directory.$file);
11
- $this->addFile($fileContents, $put_into.$file);
12
- } elseif ($file != '.' and $file != '..' and is_dir($directory.$file)) {
13
- $this->addDirectory($put_into.$file.'/');
14
- $this->get_files_from_folder($directory.$file.'/',$filename, $put_into.$file.'/');
15
- }
16
- }
17
- $data = $this->getZippedfile();
18
- $f = fopen($directory."/".$filename,"wb");
19
- fwrite($f,$data);
20
- fclose($f);
21
- }
22
- closedir($handle);
23
- }
24
- /* creates a compressed zip file */
25
- function create_zip($files = array(),$destination = '',$overwrite = false,$strreplace='')
26
- {
27
- //if the zip file already exists and overwrite is false, return false
28
- if(file_exists($destination) && !$overwrite) { return false; }
29
- //vars
30
- $valid_files = array();
31
- //if files were passed in...
32
- if(is_array($files)) {
33
- //cycle through each file
34
- foreach($files as $file) {
35
- //make sure the file exists
36
- if(file_exists($file)) {
37
- $valid_files[] = $file;
38
- }
39
- }
40
- }
41
- //if we have good files...
42
- if(count($valid_files)) {
43
- //create the archive
44
- $zip = new ZipArchive();
45
- if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
46
- return false;
47
- }
48
- //add the files
49
- foreach($valid_files as $file) {
50
- $newfile=str_replace($strreplace,"",$file);
51
- $zip->addFile($file,$newfile);
52
- }
53
- //debug
54
- //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;
55
- //close the zip -- done!
56
- $zip->close();
57
- //check to make sure the file exists
58
- return file_exists($destination);
59
- }
60
- else
61
- {
62
- return false;
63
- }
64
- }
65
- //Fuction to create zip for import the data
66
- function createimportzip($filename){
67
- $zipfilename=$filename.'.zip';
68
- $DataFile = $filename.'.txt';
69
- $catalogSection='CatalogSection.txt';
70
- $catalogProject='CatalogProject.txt';
71
- $helper=Mage::helper('codi');
72
- //Change for zip
73
- $files_to_zip = array($basePath.'CoDzip/CoDfiles/'.$filename.'.txt',
74
- $basePath.'CoDzip/CoDfiles/CatalogSection.txt',
75
- $basePath.'CoDzip/CoDfiles/CatalogProject.txt');
76
- //if true, good; if false, zip creation failed
77
- $result=$this->create_zip($files_to_zip,'CoDzip/'.$zipfilename,true,$basePath.'CoDzip/CoDfiles/');
78
-
79
- if($result)
80
- {
81
- //Deleting files
82
- if (copy($basePath.'CoDzip/CoDfiles/'.$zipfilename,$basePath.'CoDzip/'.$zipfilename)) {
83
- unlink($basePath.'CoDzip/CoDfiles/'.$zipfilename);
84
- }
85
- }
86
- }
87
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Helper/Data.php DELETED
@@ -1,322 +0,0 @@
1
- <?php
2
- class Mage_Codi_Helper_Data extends Mage_Core_Helper_Abstract
3
- {
4
- function output_file($file, $name, $mime_type='')
5
- {
6
- /*
7
- This function takes a path to a file to output ($file),
8
- the filename that the browser will see ($name) and
9
- the MIME type of the file ($mime_type, optional).
10
-
11
- */
12
- if(!is_readable($file)) die('File not found or inaccessible!');
13
-
14
- $size = filesize($file);
15
- $name = rawurldecode($name);
16
-
17
- /* Figure out the MIME type (if not specified) */
18
- $known_mime_types=array(
19
- "pdf" => "application/pdf",
20
- "txt" => "text/plain",
21
- "html" => "text/html",
22
- "htm" => "text/html",
23
- "exe" => "application/octet-stream",
24
- "zip" => "application/zip",
25
- "doc" => "application/msword",
26
- "xls" => "application/vnd.ms-excel",
27
- "ppt" => "application/vnd.ms-powerpoint",
28
- "gif" => "image/gif",
29
- "png" => "image/png",
30
- "jpeg"=> "image/jpg",
31
- "jpg" => "image/jpg",
32
- "php" => "text/plain"
33
- );
34
-
35
- if($mime_type==''){
36
- $file_extension = strtolower(substr(strrchr($file,"."),1));
37
- if(array_key_exists($file_extension, $known_mime_types)){
38
- $mime_type=$known_mime_types[$file_extension];
39
- } else {
40
- $mime_type="application/force-download";
41
- };
42
- };
43
-
44
- @ob_end_clean(); //turn off output buffering to decrease cpu usage
45
-
46
- // required for IE, otherwise Content-Disposition may be ignored
47
- if(ini_get('zlib.output_compression'))
48
- ini_set('zlib.output_compression', 'Off');
49
-
50
- header('Content-Type: ' . $mime_type);
51
- header('Content-Disposition: attachment; filename="'.$name.'"');
52
- header("Content-Transfer-Encoding: binary");
53
- header('Accept-Ranges: bytes');
54
-
55
- /* The three lines below basically make the
56
- download non-cacheable */
57
- header("Cache-control: private");
58
- header('Pragma: private');
59
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
60
-
61
- // multipart-download and download resuming support
62
- if(isset($_SERVER['HTTP_RANGE']))
63
- {
64
- list($a, $range) = explode("=",$_SERVER['HTTP_RANGE'],2);
65
- list($range) = explode(",",$range,2);
66
- list($range, $range_end) = explode("-", $range);
67
- $range=intval($range);
68
- if(!$range_end) {
69
- $range_end=$size-1;
70
- } else {
71
- $range_end=intval($range_end);
72
- }
73
-
74
- $new_length = $range_end-$range+1;
75
- header("HTTP/1.1 206 Partial Content");
76
- header("Content-Length: $new_length");
77
- header("Content-Range: bytes $range-$range_end/$size");
78
- } else {
79
- $new_length=$size;
80
- header("Content-Length: ".$size);
81
- }
82
-
83
- /* output the file itself */
84
- $chunksize = 1*(1024*1024); //you may want to change this
85
- $bytes_send = 0;
86
- if ($file = fopen($file, 'r'))
87
- {
88
- if(isset($_SERVER['HTTP_RANGE']))
89
- fseek($file, $range);
90
-
91
- while(!feof($file) &&
92
- (!connection_aborted()) &&
93
- ($bytes_send<$new_length)
94
- )
95
- {
96
- $buffer = fread($file, $chunksize);
97
- print($buffer); //echo($buffer); // is also possible
98
- flush();
99
- $bytes_send += strlen($buffer);
100
- }
101
- fclose($file);
102
- } else die('Error - can not open file.');
103
-
104
- die();
105
- }
106
-
107
- function deleteFile($basePath='',$filename='')
108
- {
109
- @unlink($basePath.$filename);
110
- //remove text files
111
- $filesn = glob($basePath."CoDzip/CoDfiles/*.txt");
112
- foreach($filesn as $filen)
113
- {
114
- unlink($filen);
115
- }
116
- }
117
- //function for get the theme
118
- function getTheme()
119
- {
120
- foreach (Mage::app()->getWebsites() as $website)
121
- {
122
- $defaultGroup = $website->getDefaultGroup();
123
- $StoreId = $defaultGroup->getDefaultStoreId();
124
- }
125
-
126
- $design = Mage::getSingleton('core/design')->loadChange($StoreId);
127
-
128
- $package = $design->getPackage();
129
- $default_theme = $design->getTheme();
130
-
131
- if ( $package == "" && $default_theme == "" ){
132
-
133
- $package = Mage::getStoreConfig('design/package/name', $StoreId);
134
- $default_theme = Mage::getStoreConfig('design/theme/default', $StoreId);
135
- }
136
-
137
- if ( $package == "" ) $package = "default";
138
- if ( $default_theme == "" ) $default_theme = "default";
139
-
140
- return $package.'/'.$default_theme;
141
-
142
-
143
-
144
- }
145
- function array2json($arr) {
146
-
147
- if(function_exists('json_encode')) return json_encode($arr); //Lastest versions of PHP already has this functionality.
148
- $parts = array();
149
- $is_list = false;
150
-
151
- //Find out if the given array is a numerical array
152
- $keys = array_keys($arr);
153
- $max_length = count($arr)-1;
154
- if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {//See if the first key is 0 and last key is length - 1
155
- $is_list = true;
156
- for($i=0; $i<count($keys); $i++) { //See if each key correspondes to its position
157
- if($i != $keys[$i]) { //A key fails at position check.
158
- $is_list = false; //It is an associative array.
159
- break;
160
- }
161
- }
162
- }
163
-
164
- foreach($arr as $key=>$value) {
165
- if(is_array($value)) { //Custom handling for arrays
166
- if($is_list) $parts[] = array2json($value); /* :RECURSION: */
167
- else $parts[] = '"' . $key . '":' . array2json($value); /* :RECURSION: */
168
- } else {
169
- $str = '';
170
- if(!$is_list) $str = '"' . $key . '":';
171
-
172
- //Custom handling for multiple data types
173
- if(is_numeric($value)) $str .= $value; //Numbers
174
- elseif($value === false) $str .= 'false'; //The booleans
175
- elseif($value === true) $str .= 'true';
176
- else $str .= '"' . addslashes($value) . '"'; //All other things
177
- // :TODO: Is there any more datatype we should be in the lookout for? (Object?)
178
-
179
- $parts[] = $str;
180
- }
181
- }
182
- $json = implode(',',$parts);
183
-
184
- if($is_list) return '[' . $json . ']';//Return numerical JSON
185
- return '{' . $json . '}';//Return associative JSON
186
- }
187
-
188
-
189
- function geTierprice($product)
190
- {
191
-
192
- if (is_null($product)) {
193
- return array();
194
- }
195
- $res='';
196
- $codquantity=Mage::getStoreConfig('codi/codi/codquantity');
197
- $codprice=Mage::getStoreConfig('codi/codi/codprice');
198
- $codsavings=Mage::getStoreConfig('codi/codi/codsavings');
199
-
200
- //[tier qty 1]#$#[tier price 1]#$#[(product price-tier price 1)/product price%]#$$#
201
-
202
- $prices = $product->getFormatedTierPrice();
203
-
204
- $rightstr = '';
205
- if (is_array($prices)) {
206
-
207
- $i='1';
208
- $count=count($prices);
209
- if($count>0)
210
- $res='[TierPriceTable]#$$#'.$codquantity.'#$#'.$codprice.'#$#'.$codsavings."=";
211
-
212
- foreach ($prices as $price) {
213
- $price['price_qty'] = $price['price_qty']*1;
214
- $rightstr.=$price['price_qty'].'#$#';
215
- if ($product->getPrice() != $product->getFinalPrice()) {
216
- if ($price['price']<$product->getFinalPrice()) {
217
-
218
- $rightstr.=Mage::helper('tax')->getPrice($product, $price['website_price'], true).'#$#';
219
-
220
- if($i==$count)
221
- {
222
- $rightstr.=ceil(100 - (( 100/$product->getFinalPrice() ) * $price['price'] )).'%';
223
- }
224
- else
225
- {
226
- $rightstr.=ceil(100 - (( 100/$product->getFinalPrice() ) * $price['price'] )).'%#$$#';
227
- }
228
-
229
- }
230
- } else {
231
- if ($price['price']<$product->getPrice()) {
232
- $rightstr.=Mage::helper('tax')->getPrice($product, $price['website_price'], true).'#$#';
233
-
234
- if($i==$count)
235
- $rightstr.= ceil(100 - (( 100/$product->getPrice() ) * $price['price'] )).'%';
236
- else
237
- $rightstr.= ceil(100 - (( 100/$product->getPrice() ) * $price['price'] )).'%#$$#';
238
- }
239
- }
240
- $i++;
241
- }
242
- }
243
-
244
- return $res.$rightstr;
245
-
246
- }
247
- //Code for Catalog section code
248
- function drawItem($category, $level=0,$name='',$i=1,$j=1,$path='')
249
- {
250
- $html='';
251
-
252
- $catalogSectionModel=Mage::getModel('codi/codi');
253
- //Get Category child
254
- $childrennew=$category->getChildrenCategories();
255
-
256
- $id=$category->getId();
257
- if($level!=1)
258
- {
259
- $path.='-'.$j;
260
- $name=$name.'#$#'.$category->getName();//.' '.$i.$path;
261
- $sql_name=addslashes($name);
262
- $sec_path.=str_replace("-",",",$path);
263
- $seq=$i.$sec_path;
264
- }
265
- else
266
- {
267
- $name=$category->getName();//.' '.$i;
268
- $sql_name=addslashes($name);
269
- $seq=$i;
270
- }
271
-
272
- $catalogSectionModel->addCatalogSection($id,$sql_name);
273
- $html= "General\t".$seq."\t".$name."\t". $sec_Flag . "\n";
274
-
275
- if(count($childrennew))
276
- {
277
- $j = 1;
278
- foreach ($childrennew as $cat)
279
- {
280
- //$cat=$this->createCategoryObj($child->getID());
281
- if($cat!=false)
282
- $htmlChildren.= $this->drawItem($cat, $level+1,$name,$i,$j,$path);
283
- $j++;
284
- }
285
- }
286
- return $html.= $htmlChildren;
287
- }
288
- //Create category object
289
- function createCategoryObj($cid)
290
- {
291
- $collection = Mage::getModel('catalog/category')->getCollection()
292
- ->setStoreId('1')
293
- ->addAttributeToSelect('name')
294
- ->addAttributeToSelect('is_active')
295
- ->addAttributeToFilter('entity_id', array('eq' => $cid));
296
- foreach($collection as $category)
297
- {
298
- if($category)
299
- return $category;
300
- else
301
- return false;
302
- }
303
- }
304
- //get product Postion
305
- function productPostion($category_id,$productId)
306
- {
307
-
308
- $category = Mage::getModel('catalog/category')
309
- ->setStoreId(1)
310
- ->load($category_id);
311
- $positions = $category->getProductsPosition();
312
- if(count($positions)>0)
313
- $position=$positions[$productId];
314
- else
315
- $position='';
316
-
317
- return $position;
318
-
319
- }
320
-
321
- }
322
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/Model/Codi.php DELETED
@@ -1,1447 +0,0 @@
1
- <?php
2
-
3
- class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
4
- {
5
- public $target ;
6
- public $codigrid ; //this flag is to know whether we are displaying our grid or a general grid
7
- public $userid ;
8
- public $password ;
9
- public $disableextension ;
10
- public $version = "3.0.9";
11
-
12
- public $customerid ;
13
- public $customerdatasourceid ;
14
- public $validateuser ;
15
- public $extensionName='Mage_PDF_per_Product';
16
- public $StoreId ;
17
- public $reviewsModel ;
18
- public $ratingModel ;
19
- public $enablereviews ;
20
- public $mediaurl ;
21
-
22
- public function _construct()
23
- {
24
- parent::_construct();
25
- $this->_init('codi/codi');
26
- $this->_logFile = "Catalog-on-demand-items.log";
27
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
28
-
29
- $this->enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews');
30
-
31
- // Get StoreID -Start
32
- foreach (Mage::app()->getWebsites() as $website)
33
- {
34
- $defaultGroup = $website->getDefaultGroup();
35
- $StoreId = $defaultGroup->getDefaultStoreId();
36
- }
37
-
38
- $this->StoreId = $StoreId ;
39
- // Get StoreID -End
40
-
41
- $this->reviewsModel = Mage::getModel('review/review') ;
42
- $this->ratingModel = Mage::getModel('rating/rating_option_vote') ;
43
- $this->mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
44
- }
45
-
46
- public function setStoreConfig( $myarray )
47
- {
48
- $section = 'codi' ;
49
- $website = '' ;
50
- $store = '';
51
-
52
- $groups =
53
- array(
54
- 'codi' =>
55
- array(
56
- 'fields' => $myarray
57
- ));
58
- Mage::getModel('adminhtml/config_data')
59
- ->setSection($section)
60
- ->setWebsite($website)
61
- ->setStore($store)
62
- ->setGroups($groups)
63
- ->save();
64
- }
65
-
66
- public function adminstart()
67
- {
68
- Mage::log("Notice : Admin Start", null, $this->_logFile);
69
-
70
- $AdminNotified = Mage::getSingleton('core/session')->getAdminNotified();
71
- if (!$AdminNotified)
72
- {
73
- Mage::getSingleton('core/session')->setAdminNotified(true);
74
- try
75
- {
76
- $codimodel = Mage::getSingleton('codi/codi');
77
- //Get Application Parameters Response (Notification)
78
- $url = "https://webservices.catalog-on-demand.com/smanager/api.do?Operation=GetApplicationParameters&Application=CoDExtensionForMagento" ;
79
- $paramsarray = array('UserID' => Mage::getStoreConfig('codi/codi/codusername'),
80
- 'Password' => Mage::getStoreConfig('codi/codi/codpassword') );
81
- $Responsemsg = $this->Call( $url, $paramsarray );
82
- if ( $Responsemsg )
83
- {
84
- if (!$Responsemsg->Errors)
85
- {
86
- foreach ($Responsemsg->GetApplicationParametersResponse->ApplicationParameter as $ApplicationParameter)
87
- {
88
- //Get Version
89
- if ((string)$ApplicationParameter->Name == "Version")
90
- $Version = (string)$ApplicationParameter->Value;
91
- //Get Release Notes Link
92
- if ((string)$ApplicationParameter->Name == "ReleaseNotesLink")
93
- $ReleaseNotesLink = (string)$ApplicationParameter->Value;
94
- //Get the Notification Message
95
- if ((string)$ApplicationParameter->Name == "NotificationMessage")
96
- $NotificationMessage = (string)$ApplicationParameter->Value;
97
- }
98
-
99
- $title = "Catalog-On-Demand version " . $Version . " now available";
100
-
101
- $feedData[] = array(
102
- 'severity' => 2,
103
- 'date_added' => NOW(),
104
- 'title' => (string)$title,
105
- 'description' => (string)$NotificationMessage,
106
- 'url' => (string)$ReleaseNotesLink,
107
- );
108
-
109
- if ( version_compare($Version, $codimodel->version) == 1) {
110
- Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData)); }
111
- }
112
- }
113
- }
114
- catch(Exception $e){}
115
- }
116
- }
117
-
118
- public function InitImportStatuses(){
119
-
120
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
121
-
122
- $write->query("DROP TABLE IF EXISTS codi_import_status");
123
- $write->query("CREATE TABLE codi_import_status(
124
- id int(11) NOT NULL auto_increment PRIMARY KEY,
125
- message varchar(50),
126
- finished int(1) default 0)"
127
- );
128
- }
129
-
130
- public function existTable(){
131
-
132
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
133
-
134
- $write->query("CREATE TABLE IF NOT EXISTS codi_import_status(
135
- id int(11) NOT NULL auto_increment PRIMARY KEY,
136
- message varchar(50),
137
- finished int(1) default 0)"
138
- );
139
-
140
- }
141
-
142
- public function addImportStatus( $message, $finished = 0 ){
143
-
144
- $this->existTable();
145
-
146
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
147
- $query = "insert into codi_import_status (message, finished) values('".$message."', $finished)";
148
- $write->query($query);
149
- }
150
-
151
- public function getImportStatuses(){
152
-
153
- $this->existTable();
154
-
155
- $read= Mage::getSingleton('core/resource')->getConnection('core_read');
156
-
157
- $query = "select id, message, finished from codi_import_status order by id desc limit 1";
158
-
159
- $messages = null;
160
-
161
- $result = $read->query($query);
162
-
163
- if($row = $result->fetch() ){
164
- $messages = array('message'=>$row['message'], 'id'=>$row['id'], 'finished'=>$row['finished']);
165
- }
166
-
167
- return $messages;
168
- }
169
-
170
- public function deleteTable(){
171
-
172
- $this->existTable();
173
-
174
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
175
- $query = "delete from codi_import_status";
176
- $write->query($query);
177
- }
178
-
179
- public function isStart(){
180
-
181
- $this->existTable();
182
-
183
- $read= Mage::getSingleton('core/resource')->getConnection('core_read');
184
-
185
- $query = "select id, message, finished from codi_import_status where message = 'start' order by id desc limit 1";
186
-
187
- $result = $read->query($query);
188
-
189
- if($row = $result->fetch() ){
190
- return true;
191
- }
192
-
193
- return false;
194
- }
195
- //Changed in 3.0.3
196
- public function createFile($basePath){
197
-
198
- $fh = fopen($basePath.'CoDzip/CoDfiles/temp.txt', 'w');
199
-
200
- if ( !$fh )
201
- {
202
- return false;
203
- }
204
-
205
- fclose($fh);
206
-
207
- //unlink($basePath.'CoDzip/CoDfiles/temp.txt');
208
- return true;
209
- }
210
-
211
- //Changed in 3.0.6
212
- public function createFileInit($basePath){
213
-
214
- $fh = fopen($basePath.'CoDzip/CoDfiles/ttemp.txt', 'w');
215
-
216
- if ( !$fh )
217
- {
218
- return false;
219
- }
220
-
221
- fclose($fh);
222
-
223
- unlink($basePath.'CoDzip/CoDfiles/ttemp.txt');
224
- return true;
225
- }
226
-
227
- public function run_codi_import_manually($basepath){
228
-
229
- $this->run_codi_import($basepath);
230
- }
231
-
232
- public function run_codi_import($basePath)
233
- {
234
- Mage::log("Notice : Codi Import Start", null, $this->_logFile);
235
-
236
- ini_set('memory_limit','1024M');
237
-
238
- $this->InitImportStatuses();
239
-
240
- $fh = fopen($basePath.'CoDzip/CoDfiles/temp.txt', 'w');
241
-
242
- if ( !$fh )
243
- {
244
- Mage::log("ERROR : Cann't open file for building data file:".$basePath, null, $this->_logFile);
245
- $this->addImportStatus("fileerror", 1);
246
- return;
247
- }
248
-
249
- fwrite($fh, "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductMfg\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tCategory\tReviews\tSupplementalInfo");
250
-
251
- $products = Mage::getModel('catalog/product')->getCollection();
252
- $products->addAttributeToFilter('status', 1);//enabled
253
- $products->addAttributeToFilter('visibility', 4);//catalog, search
254
- $products->addAttributeToSelect('*');
255
- $prodIds = $products->getAllIds();
256
-
257
- $this->addImportStatus("start");
258
-
259
- $status = "end";
260
- foreach($prodIds as $productId) {
261
-
262
- set_time_limit(0);
263
-
264
- $message = $this->getImportStatuses();
265
- if ( isset($message) && $message['message'] == "cancel") {
266
- $status = "cancel";
267
- break;
268
- }
269
-
270
- $product = Mage::getModel('catalog/product');
271
- $product->load($productId);
272
-
273
- fwrite($fh, $this->ProducttoString($product, "product"));
274
- }
275
-
276
- fclose($fh);
277
- Mage::log("Notice : Codi Import End : ".$status, null, $this->_logFile);
278
- //Clean up
279
- unset($products);
280
- unset($product);
281
-
282
- if ( $status == "end" )
283
- $this->addImportStatus($status, 1);
284
- }
285
-
286
- public function ProducttoString( $product , $from )
287
- {
288
-
289
- if( $product->isConfigurable() )
290
- {
291
- return $this->ProducttoStringConfigurable( $product , $from ) ;
292
- }
293
-
294
- elseif( $product->isGrouped() )
295
- {
296
- return $this->ProducttoStringGrouped( $product , $from ) ;
297
- }
298
- else
299
- {
300
- return $this->ProducttoStringSimple( $product , $from ) ;
301
- }
302
- }
303
- ////////////////////////////////////// Grouped Products //////////////////////////////////////////////////////////
304
- public function ProducttoStringGrouped( $product , $from )
305
- {
306
- $ProducttoString = '' ;
307
- $getAssociatedProductIds = Mage::getModel('catalog/product_type_grouped')->getAssociatedProductIds($product);
308
-
309
- $ProductDescription = '';
310
- if(Mage::getStoreConfig('codi/codi/codincludeshortdescription')=="checked")
311
- {
312
- $shortDescription = $product->getShortDescription();
313
- if(strpos($shortDescription,'<p>')!==false)
314
- {
315
- $new=strlen($shortDescription);
316
- $pos = strrpos($shortDescription, '</p>')+4;
317
- if($new!=$pos)
318
- {
319
- $extra="<p>";
320
- $pextra="</p>";
321
- $ProductDescription .= substr($shortDescription, 0, $pos) . $extra . substr($shortDescription, $pos).$pextra;
322
- }
323
- else $ProductDescription .= $shortDescription ;
324
- }
325
- else
326
- $ProductDescription .= "<p>".$shortDescription ."</p>";
327
-
328
- }
329
- $longDescription = $product->getDescription() ;
330
- if(strpos($longDescription,'<p>')!==false)
331
- {
332
- $new=strlen($longDescription);
333
- $pos = strrpos($longDescription, '</p>')+4;
334
- if($new!=$pos)
335
- {
336
- $extra="<p>";
337
- $pextra="</p>";
338
- $ProductDescription .= substr($longDescription, 0, $pos) . $extra . substr($longDescription, $pos).$pextra;
339
- }
340
- else $ProductDescription .= $longDescription ;
341
- }
342
- else
343
- $ProductDescription .= "<p>".$longDescription ."</p>" ;
344
- //Get Product Attributes Start
345
- $attributes = $product->getAttributes();
346
-
347
- $ProductAttributes = "" ;
348
- foreach ($attributes as $attribute) {
349
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
350
- $value = $attribute->getFrontend()->getValue($product);
351
- if (is_string($value))
352
- {
353
- if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
354
- {
355
- $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
356
- }
357
- }
358
- }
359
- }
360
- $ProductAttributes = substr($ProductAttributes, 0, strlen($ProductAttributes)-1 ) ;
361
- //Get Product Attributes End
362
-
363
- //******************** Get Tier Price option *********************//
364
-
365
- if(Mage::getStoreConfig('codi/codi/codpublishtieredpricing')=='checked')
366
- {
367
- $TierPriceAttributes =Mage::helper('codi')->geTierprice($product);
368
- $sp="|";
369
- if(($ProductAttributes=='') || ($TierPriceAttributes==''))
370
- $sp='';
371
-
372
- if($ProductAttributes=='')
373
-
374
-
375
- $ProductAttributes.= $sp.$TierPriceAttributes;
376
- }
377
- //************End Tier Price option *************//
378
- //************************* Get Categories names Start ***************************
379
- //Changed in 3.0.3 removed the category names
380
- $CategoriesString = "" ;
381
-
382
- //************************* Get Categories names End ***************************
383
-
384
-
385
- foreach($getAssociatedProductIds as $UsedProductid)
386
- {
387
- $UsedProduct = Mage::getModel('catalog/product')->load($UsedProductid);
388
- $ItemName= $UsedProduct->getName() ;
389
- if( Mage::getStoreConfig('codi/codi/fromchild') )
390
- $UsedProductPrice = $UsedProduct->getFinalPrice() ;
391
- else
392
- $UsedProductPrice = $UsedProduct->getFinalPrice() ; //default behavior
393
- //************************ Get Attributes Start *******************************
394
-
395
- //Extract Attributes
396
-
397
- $ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
398
- $ItemImageURL = $this->mediaurl . "catalog/product" . $UsedProduct->getImage();
399
- //Get Item Attributes Start
400
-
401
- //$excludeAttr = array() ;
402
- $attributes = $UsedProduct->getAttributes();
403
- $ItemitemAttributes = "" ;
404
- foreach ($attributes as $attribute) {
405
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
406
- $value = $attribute->getFrontend()->getValue($UsedProduct);
407
- if (is_string($value))
408
- {
409
- if (strlen($value) && $UsedProduct->hasData($attribute->getAttributeCode()))
410
- {
411
- $ItemitemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
412
- }
413
- }
414
- }
415
- }
416
- $ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 ) ;
417
-
418
-
419
-
420
- //Get Item Attributes End
421
- //************************ Get Attributes End ************************************
422
- //************************* Get Reviews Start ***********************
423
- //$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
424
- $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
425
- //************************* Get Reviews End *************************
426
-
427
- //************************* Concatenate Product Info Start ***********************
428
- $ProducttoString .= "\r\n" . $this->cleanStr( $UsedProduct->getSku() ) ; //ItemID
429
- $ProducttoString .= "\t" . "" ; //ItemQty
430
- $ProducttoString .= "\t" . "" ; //ItemUom
431
- // $ProducttoString .= "\t" . $this->cleanStr( $product->getPrice() ) ; //ItemPrice
432
- $ProducttoString .= "\t" . $this->cleanStr( $UsedProductPrice ) ; //ItemPrice
433
- $ProducttoString .= "\t" . $this->cleanStr( $ItemName) ; //ItemDescription
434
- $ProducttoString .= "\t" . $this->cleanStr( $UsedProduct ->getProductUrl() ); //ItemLink
435
- $ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ItemitemAttributes
436
- $ProducttoString .= "\t" . $this->cleanStr( $ItemImageURL ) ; //ItemitemGraphic
437
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
438
- $ProducttoString .= "\t" . "" ;
439
- //add paragraph tag in description
440
-
441
- $ProducttoString .= "\t" . $this->cleanStr($ProductDescription) ;
442
-
443
- //ProductDescription
444
- $ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
445
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
446
- $ProducttoString .= "\t" . $this->cleanStr( $ProductAttributes ) ; //ProductAttributes
447
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
448
- $ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
449
- $shortdescription=$product->getShortDescription();
450
- if(strpos($shortdescription,'<p>')!==false)
451
-
452
- $ProducttoString .= "\t" . $this->cleanStr($shortdescription) ;
453
-
454
- else $ProducttoString .= "\t" . $this->cleanStr( "<p>".$shortdescription ."</p>") ; //ShortDescription (Quick Overview)
455
- //************************* Concatenate Product Info End ************************* cleanStr
456
- }
457
- unset($ProductDescription);
458
- unset($ImageURL);
459
- unset($product);
460
- unset($ItemitemAttributes);
461
- unset($CategoriesString);
462
- unset($Reviews);
463
- unset($UsedProduct);
464
-
465
- return $ProducttoString ;
466
- }
467
-
468
-
469
- ////////////////////////////////////// Configurable Products //////////////////////////////////////////////////////////
470
- public function ProducttoStringConfigurable( $product , $from )
471
- {
472
- $ProducttoString = '' ;
473
- $UsedProductIds = Mage::getModel('catalog/product_type_configurable')->getUsedProductIds($product);
474
-
475
- $ProductDescription = '';
476
- if(Mage::getStoreConfig('codi/codi/codincludeshortdescription')=="checked")
477
- {
478
- $shortDescription = $product->getShortDescription();
479
- if(strpos($shortDescription,'<p>')!==false)
480
- {
481
- $new=strlen($shortDescription);
482
- $pos = strrpos($shortDescription, '</p>')+4;
483
- if($new!=$pos)
484
- {
485
- $extra="<p>";
486
- $pextra="</p>";
487
- $ProductDescription .= substr($shortDescription, 0, $pos) . $extra . substr($shortDescription, $pos).$pextra;
488
- }
489
- else $ProductDescription .= $shortDescription ;
490
- }
491
- else
492
- $ProductDescription .= "<p>".$shortDescription ."</p>";
493
-
494
- }
495
- $longDescription = $product->getDescription() ;
496
- if(strpos($longDescription,'<p>')!==false)
497
- {
498
- $new=strlen($longDescription);
499
- $pos = strrpos($longDescription, '</p>')+4;
500
- if($new!=$pos)
501
- {
502
- $extra="<p>";
503
- $pextra="</p>";
504
- $ProductDescription .= substr($longDescription, 0, $pos) . $extra . substr($longDescription, $pos).$pextra;
505
- }
506
- else $ProductDescription .= $longDescription ;
507
-
508
- }
509
- else
510
- $ProductDescription .= "<p>".$longDescription ."</p>" ;
511
- //Get Product Attributes Start
512
- //$excludeAttr = array() ;
513
- $attributes = $product->getAttributes();
514
-
515
- $ProductAttributes = "" ;
516
- foreach ($attributes as $attribute) {
517
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
518
- $value = $attribute->getFrontend()->getValue($product);
519
- if (is_string($value))
520
- {
521
- if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
522
- {
523
- $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
524
- }
525
- }
526
- }
527
- }
528
- $ProductAttributes = substr($ProductAttributes, 0, strlen($ProductAttributes)-1 ) ;
529
- //Get Product Attributes End
530
-
531
- //******************** Get Tier Price option *********************//
532
-
533
- if(Mage::getStoreConfig('codi/codi/codpublishtieredpricing')=='checked')
534
- {
535
- $TierPriceAttributes =Mage::helper('codi')->geTierprice($product);
536
- $sp="|";
537
- if(($ProductAttributes=='') || ($TierPriceAttributes==''))
538
- $sp='';
539
-
540
- if($ProductAttributes=='')
541
-
542
-
543
- $ProductAttributes.= $sp.$TierPriceAttributes;
544
- }
545
- //************End Tier Price option *************//
546
- //************************* Get Categories names Start ***************************
547
- //Changed in 3.0.3 removed the category names
548
- $CategoriesString = "" ;
549
-
550
- //************************* Get Categories names End ***************************
551
-
552
- foreach($UsedProductIds as $UsedProductid)
553
- {
554
- $UsedProduct = Mage::getModel('catalog/product')->load($UsedProductid);
555
- if( Mage::getStoreConfig('codi/codi/fromchild') )
556
- $UsedProductPrice = $UsedProduct->getFinalPrice() ;
557
- else
558
- $UsedProductPrice = $product->getFinalPrice() ; //default behavior
559
- //************************ Get Attributes Start *******************************
560
-
561
- //Extract Attributes
562
-
563
- $ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
564
-
565
- //Get Item Attributes Start
566
-
567
- $attributes = $UsedProduct->getAttributes();
568
-
569
- $ItemitemAttributes = "" ;
570
- $AllowAttributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
571
- foreach ($AllowAttributes as $attribute)
572
- {
573
- $AttributeCode = $attribute->getProductAttribute()->getAttributeCode() ;
574
- $AttributeLabel = $attribute->getProductAttribute()->getFrontend()->getLabel() ;
575
- $AttribId = $UsedProduct->getData($AttributeCode) ;
576
-
577
- $AttributeValue = "" ;
578
- foreach ( $attribute->getProductAttribute()->getSource()->getAllOptions() as $option )
579
- {
580
- if( $option['value'] == $AttribId )
581
- {
582
- $AttributeValue = $option['label'];
583
- }
584
- }
585
-
586
- $ItemitemAttributes .= $AttributeLabel . "=" . $AttributeValue . "|" ;
587
-
588
- //Get Delta Price Start
589
- foreach( $attribute->getPrices() as $addedPrice )
590
- {
591
- if ( $AttributeValue == $addedPrice['label'])
592
- {
593
- if( $addedPrice['is_percent'] )
594
- $UsedProductPrice += $UsedProductPrice * $addedPrice['pricing_value'] / 100;
595
- else
596
- $UsedProductPrice += $addedPrice['pricing_value'] ;
597
- }
598
- }
599
- //Get Delta Price End
600
- }
601
-
602
- $ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 );
603
-
604
-
605
-
606
- //Get Item Attributes End
607
- //************************ Get Attributes End ************************************
608
- //************************* Get Reviews Start ***********************
609
- //$enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
610
- $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
611
- //************************* Get Reviews End *************************
612
-
613
- //************************* Concatenate Product Info Start ***********************
614
- $ProducttoString .= "\r\n" . $this->cleanStr( $UsedProduct->getSku() ) ; //ItemID
615
- $ProducttoString .= "\t" . "" ; //ItemQty
616
- $ProducttoString .= "\t" . "" ; //ItemUom
617
- // $ProducttoString .= "\t" . $this->cleanStr( $product->getPrice() ) ; //ItemPrice
618
- $ProducttoString .= "\t" . $this->cleanStr( $UsedProductPrice ) ; //ItemPrice
619
- $ProducttoString .= "\t" . ""; //ItemDescription
620
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
621
- $ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ItemitemAttributes
622
- $ProducttoString .= "\t" . ""; //ItemitemGraphic
623
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
624
- $ProducttoString .= "\t" . "" ;
625
-
626
- $ProducttoString .= "\t" . $this->cleanStr($ProductDescription) ;
627
-
628
- //ProductDescription
629
- $ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
630
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
631
- $ProducttoString .= "\t" . $this->cleanStr( $ProductAttributes ) ; //ProductAttributes
632
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
633
- $ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
634
- $shortdescription=$product->getShortDescription();
635
- if(strpos($shortdescription,'<p>')!==false)
636
-
637
- $ProducttoString .= "\t" . $this->cleanStr($shortdescription) ;
638
-
639
- else $ProducttoString .= "\t" . $this->cleanStr( "<p>".$shortdescription ."</p>") ; //ShortDescription (Quick Overview)
640
- //************************* Concatenate Product Info End ************************* cleanStr
641
- }
642
- unset($ProductDescription);
643
- unset($ImageURL);
644
- unset($product);
645
- unset($ItemitemAttributes);
646
- unset($CategoriesString);
647
- unset($Reviews);
648
-
649
-
650
- return $ProducttoString ;
651
- }
652
-
653
-
654
- /////////////////////////////////////////// Simple Products ///////////////////////////////////////////////////////////////////
655
- public function ProducttoStringSimple( $product , $from )
656
- {
657
- $ProducttoString = '' ;
658
- //Change for short description
659
- //$ProductDescription = $product->getDescription() ;
660
- $ProductDescription = '';
661
-
662
- if(Mage::getStoreConfig('codi/codi/codincludeshortdescription')=="checked")
663
- {
664
- $shortDescription = $product->getShortDescription();
665
- if(strpos($shortDescription,'<p>')!==false)
666
- {
667
- $new=strlen($shortDescription);
668
- $pos = strrpos($shortDescription, '</p>')+4;
669
- if($new!=$pos)
670
- {
671
- $extra="<p>";
672
- $pextra="</p>";
673
- $ProductDescription .= substr($shortDescription, 0, $pos) . $extra . substr($shortDescription, $pos).$pextra;
674
- }
675
- else $ProductDescription .= $shortDescription ;
676
- }
677
- else
678
- $ProductDescription .= "<p>".$shortDescription ."</p>";
679
-
680
- }
681
- $longDescription = $product->getDescription() ;
682
- if(strpos($longDescription,'<p>')!==false)
683
- {
684
- $new=strlen($longDescription);
685
- $pos = strrpos($longDescription, '</p>')+4;
686
- if($new!=$pos)
687
- {
688
- $extra="<p>";
689
- $pextra="</p>";
690
- $ProductDescription .= substr($longDescription, 0, $pos) . $extra . substr($longDescription, $pos).$pextra;
691
- }
692
- else $ProductDescription .= $longDescription ;
693
- }
694
- else
695
- $ProductDescription .= "<p>".$longDescription ."</p>" ;
696
-
697
- //************************ Get Attributes Start *******************************
698
- //Extract Attributes
699
-
700
- $ImageURL = $this->mediaurl . "catalog/product" . $product->getImage();
701
-
702
- //$excludeAttr = array() ;
703
- $attributes = $product->getAttributes();
704
- $ItemitemAttributes = "" ;
705
- foreach ($attributes as $attribute) {
706
- if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), array() )) {
707
- $value = $attribute->getFrontend()->getValue($product);
708
- if (is_string($value))
709
- {
710
- if (strlen($value) && $product->hasData($attribute->getAttributeCode()))
711
- {
712
- $ItemitemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|" ;
713
- }
714
- }
715
- }
716
- }
717
- $ItemitemAttributes = substr($ItemitemAttributes, 0, strlen($ItemitemAttributes)-1 ) ;
718
- //************************ Get Attributes End ************************************
719
- //******************** Get Tier Price option *********************//
720
-
721
- if(Mage::getStoreConfig('codi/codi/codpublishtieredpricing')=='checked')
722
- {
723
- $TierPriceAttributes =Mage::helper('codi')->geTierprice($product);
724
- $sp="|";
725
- if(($ItemitemAttributes=='') || ($TierPriceAttributes==''))
726
- $sp='';
727
-
728
- $ItemitemAttributes.= $sp.$TierPriceAttributes;
729
- }
730
- //************End Tier Price option *************//
731
-
732
-
733
-
734
- //************************* Get Categories names Start ***************************
735
- //Changed into 3.0.3 removed the category name
736
-
737
- $CategoriesString = "" ;
738
-
739
- //************************* Get Categories names End ***************************
740
-
741
- //************************* Get Reviews Start ***********************
742
- $Reviews = $this->enablereviews ? $this->getReviews($product->getId()) : '' ;
743
- //************************* Get Reviews End *************************
744
-
745
- //************************* Concatenate Product Info Start ***********************
746
-
747
- $ProducttoString .= "\r\n" . $this->cleanStr( $product->getSku() ) ; //ItemID
748
- $ProducttoString .= "\t" . "" ; //ItemQty
749
- $ProducttoString .= "\t" . "" ; //ItemUom
750
- $ProducttoString .= "\t" . $this->cleanStr( $product->getFinalPrice() ) ; //ItemPrice
751
- $ProducttoString .= "\t" . ""; //ItemDescription
752
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ); //ItemLink
753
- $ProducttoString .= "\t" . ""; //ItemitemAttributes
754
- $ProducttoString .= "\t" . ""; //ItemitemGraphic
755
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName() ); //ProductName
756
- $ProducttoString .= "\t" . "" ;
757
- //ProductMfg
758
- $ProducttoString .= "\t" . $this->cleanStr( $ProductDescription) ; //ProductDescription
759
- $ProducttoString .= "\t" . $this->cleanStr( $ImageURL ); //ProductGraphic
760
- $ProducttoString .= "\t" . $this->cleanStr( $product->getProductUrl() ) ; //ProductLink
761
- $ProducttoString .= "\t" . $this->cleanStr( $ItemitemAttributes ) ; //ProductAttributes
762
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Category
763
- $ProducttoString .= "\t" . $this->cleanStr( $Reviews ); //Reviews
764
- $shortdescription=$product->getShortDescription();
765
- if(strpos($shortdescription,'<p>')!==false)
766
-
767
- $ProducttoString .= "\t" . $this->cleanStr($shortdescription) ;
768
-
769
- else $ProducttoString .= "\t" . $this->cleanStr( "<p>".$shortdescription ."</p>") ; //ShortDescription (Quick Overview)
770
- //************************* Concatenate Product Info End ************************* cleanStr
771
-
772
- unset($ProductDescription);
773
- unset($ImageURL);
774
- unset($product);
775
- unset($ItemitemAttributes);
776
- unset($CategoriesString);
777
- unset($Reviews);
778
-
779
- return $ProducttoString ;
780
- }
781
-
782
- public function cleanStr($localstr)
783
- {
784
- //$specialChar=array('&#11;'=>'','&#27;'=>'');
785
-
786
- $localstr = str_replace("\t","", $localstr ) ;
787
- $localstr = str_replace("\r\n","<br>", $localstr ) ;
788
- $localstr = str_replace("\r","<br>", $localstr ) ;
789
- $localstr = str_replace("\n","<br>", $localstr ) ;
790
- $localstr = str_replace("","",$localstr) ;
791
- //Changed for special character
792
-
793
-
794
-
795
- return $localstr ;
796
- }
797
-
798
- public function getReviews( $productid )
799
- {
800
- $reviewsCollection = $this->reviewsModel->getCollection()
801
- ->addStoreFilter($this->StoreId)
802
- ->addStatusFilter('approved')
803
- ->addEntityFilter('product', $productid)
804
- ->setDateOrder();
805
-
806
- $Reviews = "" ;
807
- foreach($reviewsCollection as $review)
808
- {
809
- $ratingCollection = $this->ratingModel
810
- ->getResourceCollection()
811
- ->setReviewFilter($review->getReviewId())
812
- ->setStoreFilter($this->StoreId)
813
- ->addRatingInfo($this->StoreId)
814
- ->load();
815
- $Reviews .= "<p><b>".$review->getTitle()."(". $review->getNickname() .")</b><br>".$review->getDetail()."</p>" ;
816
- }
817
- return $Reviews ;
818
- }
819
-
820
- public function checkvalidity()
821
- {
822
- $userid = Mage::getStoreConfig('codi/codi/codusername') ;
823
- $password = Mage::getStoreConfig('codi/codi/codpassword') ;
824
- $url = "https://webservices.catalog-on-demand.com/smanager/api.do?Operation=ValidateUser&ResponseGroups=All&FunctionGroups=All" ;
825
- $paramsarray = array('UserID' => $userid ,
826
- 'Password' => $password );
827
- $Responsemsg = $this->Call( $url, $paramsarray );
828
- if( $Responsemsg )
829
- return $Responsemsg->Message=="OK" ? true : false ;
830
- else
831
- return false ;
832
- }
833
-
834
- //////////////////////////////////// Calling Start /////////////////////////////////////////////////////
835
- public function CallusingZend( $url, $paramsarray )
836
- {
837
- $client = new Zend_Http_Client();
838
- $client->setUri($url);
839
- $client->setParameterPost('UserID', $this->userid);
840
- $client->setParameterPost('Password', $this->password);
841
-
842
- $mystr = '';
843
- foreach($paramsarray as $key=>$value)
844
- {
845
- $client->setParameterPost($key, $value);
846
- $mystr .= $key . $value ;
847
- }
848
-
849
- $response = $client->request('POST');
850
- $result = $response->getBody() ;
851
- return $result;
852
- }
853
-
854
- public function CallusingCurl( $url, $paramsarray )
855
- {
856
- $poststr = '';
857
- foreach($paramsarray as $key=>$value)
858
- {
859
- $poststr .= $key ."=". urlencode($value) ."&";
860
- }
861
-
862
- $ch = curl_init();
863
- curl_setopt($ch, CURLOPT_URL,$url);
864
- curl_setopt($ch, CURLOPT_FAILONERROR, 1);
865
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
866
- curl_setopt($ch, CURLOPT_POST,1);
867
- curl_setopt($ch, CURLOPT_POSTFIELDS, $poststr);
868
- $result = curl_exec($ch);
869
- curl_close($ch);
870
-
871
- return $result;
872
- }
873
-
874
- public function Call( $url, $paramsarray )
875
- {
876
- $result = "" ;
877
- try
878
- {
879
- $result = $this->CallusingZend( $url, $paramsarray );
880
- }
881
- catch(Exception $e)
882
- {
883
- try
884
- {
885
- $result = $this->CallusingCurl( $url, $paramsarray );
886
- }
887
- catch(Exception $e){}
888
- }
889
-
890
- $Responsemsg = false ;
891
-
892
- return $result ;
893
- }
894
- //////////////////////////////////// Calling End /////////////////////////////////////////////////////
895
- public function getComment($datetime='')
896
- {
897
- $Comment = "";
898
- ////////////////////////////////////////////////////////////
899
- $extension_version = $this->version;//(string) Mage::getConfig()->getNode()->modules->Mage_Codi->version;
900
- $app_version = Mage::getVersion();
901
- $php_version = phpversion();
902
-
903
- foreach (Mage::app()->getWebsites() as $website)
904
- {
905
- $defaultGroup = $website->getDefaultGroup();
906
- $StoreId = $defaultGroup->getDefaultStoreId();
907
- }
908
-
909
- $design = Mage::getSingleton('core/design')->loadChange($StoreId);
910
- $package = $design->getPackage();
911
- $default_theme = $design->getTheme();
912
-
913
- if ( $package == "" && $default_theme == "" ){
914
-
915
- $package = Mage::getStoreConfig('design/package/name', $StoreId);
916
- $default_theme = Mage::getStoreConfig('design/theme/default', $StoreId);
917
- }
918
-
919
- if ( $package == "" ) $package = "default";
920
- if ( $default_theme == "" ) $default_theme = "default";
921
-
922
- $theme = "default";
923
- if ( $package != "default" || $default_theme != "default" )
924
- $theme = $package."/".$default_theme;
925
-
926
- $codbgcheck = ( Mage::getStoreConfig('codi/codi/codbgcheck') == '1' )?'Yes':'No' ;
927
-
928
- $enablefreshflyers = ( Mage::getStoreConfig('codi/codi/enablefreshflyers') == 'checked' )?'Yes':'No' ;
929
- $enablereviews = ( Mage::getStoreConfig('codi/codi/codenablereviews') == 'checked' )?'Yes':'No' ;
930
- $fromchild = ( Mage::getStoreConfig('codi/codi/fromchild') == 'checked' )?'Yes':'No' ;
931
-
932
- $codflyerlinkimgurl = Mage::getStoreConfig('codi/codi/codflyerlinkimgurl') ;
933
- $codflyerlinkimg = ( Mage::getStoreConfig('codi/codi/codflyerlinkimg') == 'Custom' )? $codflyerlinkimgurl:'Default';
934
- $codflyerlinkimgalt = Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') ;
935
-
936
- $codbeforename = ( Mage::getStoreConfig('codi/codi/codbeforename') == 'checked' )?'Yes':'No' ;
937
- $codaftername = ( Mage::getStoreConfig('codi/codi/codaftername') == 'checked' )?'Yes':'No' ;
938
- $codbeforeemailto = ( Mage::getStoreConfig('codi/codi/codbeforeemailto') == 'checked' )?'Yes':'No' ;
939
- $codafteremailto = ( Mage::getStoreConfig('codi/codi/codafteremailto') == 'checked' )?'Yes':'No' ;
940
- $codbeforeOR = ( Mage::getStoreConfig('codi/codi/codbeforeOR') == 'checked' )?'Yes':'No' ;
941
- $codafterOR = ( Mage::getStoreConfig('codi/codi/codafterOR') == 'checked' )?'Yes':'No' ;
942
- $codbeforeoverview = ( Mage::getStoreConfig('codi/codi/codbeforeoverview') == 'checked' ) ?'Yes':'No';
943
- $codafteroverview = ( Mage::getStoreConfig('codi/codi/codafteroverview') == 'checked' )?'Yes':'No';
944
- //Changed for include short description
945
- $includeshortdescription = (Mage::getStoreConfig('codi/codi/codincludeshortdescription')== 'checked' )?'Yes':'No';
946
-
947
- $Comment = "App extension version: ".$extension_version." \r\n";
948
- $Comment .= "Magento version: ".$app_version." \r\n";
949
- $Comment .= "PHP: ".$php_version." \r\n";
950
- $Comment .= "Theme: ".$theme." \r\n";
951
- $Comment .= "Create data file using background process: ".$codbgcheck." \r\n";
952
- $Comment .= "Enable Always Fresh Flyers: ".$enablefreshflyers." \r\n";
953
- $Comment .= "Include Short Description: ".$includeshortdescription." \r\n";
954
- $Comment .= "Enable Reviews: ".$enablereviews." \r\n";
955
- $Comment .= "Get price from associated products: ".$fromchild." \r\n";
956
- $Comment .= "Image to be used for flyer link: ".$codflyerlinkimg." \r\n";
957
- $Comment .= "Alt text for flyer link image: ".$codflyerlinkimgalt." \r\n";
958
- $Comment .= "Display options: \r\n";
959
- $Comment .= " Display before product name: ".$codbeforename." \r\n";
960
- $Comment .= " Display after product name: ".$codaftername." \r\n";
961
- $Comment .= " Display before Email to a friend: ".$codbeforeemailto." \r\n";
962
- $Comment .= " Display after Email to a friend: ".$codafteremailto." \r\n";
963
- $Comment .= " Display before OR: ".$codbeforeOR." \r\n";
964
- $Comment .= " Display after OR: ".$codafterOR." \r\n";
965
- $Comment .= " Display before Quick Overview: ".$codbeforeoverview." \r\n";
966
- $Comment .= " Display after Quick Overview: ".$codafteroverview." \r\n";
967
-
968
- //Change for site url
969
- $siteurl = Mage::getUrl('/');
970
- $Comment .="Site Url: ".$siteurl."\r\n";
971
- $datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
972
- if($datafilelaunch=='magento')
973
- {
974
- $datafilelaunch='cronjob';
975
-
976
- }
977
-
978
- //code for version 2.2.16
979
-
980
- $Comment .="Data File Launch Mode: ".$datafilelaunch."\r\n";
981
-
982
- $url = Mage::getUrl('codi/nsync') ;
983
- $pos = strrpos ($url , 'key') ;
984
- if ( $pos != 0 )
985
- $cronjoburl = substr( $url , 0 , $pos ) ;
986
- else
987
- $cronjoburl = $url;
988
-
989
- if(($datafilelaunch=='cronjob') || ($datafilelaunch=='manual'))
990
- {
991
- $Comment .="Cron job command: wget ".$cronjoburl."\r\n";
992
- }
993
- else{
994
- $waitforminute=Mage::getStoreConfig('codi/codi/codwaitforminute')/60;
995
- $Comment .="WaitFor: ".number_format($waitforminute,2,'.','')."\r\n";
996
-
997
- }
998
-
999
- $Comment .="Extension Name: ".$this->extensionName."\r\n";
1000
- $Comment .="Date and time of most recent data file: ".$datetime."\r\n";
1001
- //Changed for Tier Price options
1002
-
1003
- $publishtieredpricing=Mage::getStoreConfig('codi/codi/codpublishtieredpricing');
1004
- if($publishtieredpricing=='checked')
1005
- {
1006
- $codquantity=Mage::getStoreConfig('codi/codi/codquantity');
1007
- $codprice=Mage::getStoreConfig('codi/codi/codprice');
1008
- $codsavings=Mage::getStoreConfig('codi/codi/codsavings');
1009
- $publish=($publishtieredpricing == 'checked' )?'Yes':'No';
1010
- $Comment .= "Tiered Pricing Options: \r\n";
1011
- $Comment .= " Publish tiered pricing: ".$publish." \r\n";
1012
- $Comment .= " Label for quantity column: ".$codquantity." \r\n";
1013
- $Comment .= " Label for price column: ".$codprice." \r\n";
1014
- $Comment .= " Label for savings: ".$codsavings." \r\n";
1015
-
1016
- }
1017
-
1018
-
1019
- return $Comment;
1020
- ////////////////////////////////////////////////////////////
1021
- }
1022
- //code for version 2.2.16
1023
- public function new_run_codi_import($basePath)
1024
- {
1025
-
1026
- Mage::log("Notice : Codi Import Start", null, $this->_logFile);
1027
-
1028
- ini_set('memory_limit','1024M');
1029
-
1030
- $this->InitImportStatuses();
1031
-
1032
- $fh = fopen($basePath.'CoDzip/CoDfiles/temp.txt', 'w');
1033
-
1034
- if ( !$fh )
1035
- {
1036
- Mage::log("ERROR : Cann't open file for building data file:".$basePath, null, $this->_logFile);
1037
- $this->addImportStatus("fileerror", 1);
1038
- return;
1039
- }
1040
-
1041
- fwrite($fh, "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductMfg\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tCategory\tReviews\tSupplementalInfo");
1042
-
1043
- $products = Mage::getModel('catalog/product')->getCollection();
1044
- $products->addAttributeToFilter('status', 1);//enabled
1045
- $products->addAttributeToFilter('visibility', 4);//catalog, search
1046
- $products->addAttributeToSelect('*');
1047
-
1048
- $prodIds = $products->getAllIds();
1049
-
1050
- $this->addImportStatus("start");
1051
-
1052
- $status = "end";
1053
- $i='0';
1054
- try{
1055
- foreach($prodIds as $productId)
1056
- {
1057
- set_time_limit(20);
1058
- $message = $this->getImportStatuses();
1059
- if ( isset($message) && $message['message'] == "cancel") {
1060
- $status = "cancel";
1061
- break;
1062
- }
1063
- $product = Mage::getModel('catalog/product');
1064
- $product->load($productId);
1065
- Mage::log("Notice : Codi Import Products :".$i, null, $this->_logFile);
1066
- fwrite($fh, $this->ProducttoString($product, "product"));
1067
- $i++;
1068
- }
1069
- }
1070
-
1071
- catch (Exception $e)
1072
- {
1073
- Mage::log("Notice : Codi Import Products Exception :".$e->getMessage(), null, $this->_logFile);
1074
- }
1075
- //clean up the memory
1076
- unset($product);
1077
- unset($prodIds);
1078
- unset($products);
1079
-
1080
- fclose($fh);
1081
- Mage::log("Notice : Codi Import End : ".$status, null, $this->_logFile);
1082
-
1083
- if ( $status == "end" )
1084
- $this->addImportStatus($status, 1);
1085
-
1086
- }
1087
- //code for create CatalogSection.txt
1088
- public function createCatalogSection()
1089
- {
1090
- Mage::log("Notice : Create Catalog Section Start: ", null, $this->_logFile);
1091
-
1092
- $helper=Mage::helper('codi');
1093
- $dir = dirname(__FILE__);
1094
- $_baseDirArray = explode("app", $dir);
1095
- $basePath = $_baseDirArray[0];
1096
- $progress=100;
1097
- /*
1098
- //Create object for Codi Model
1099
- //Create table Codi Catalog Section for insert category hirarchy path
1100
- */
1101
- $catalogSectionModel=Mage::getModel('codi/codi');
1102
- $catalogSectionModel->InitCatalogSectionTable();
1103
-
1104
- $collection = Mage::getModel('catalog/category')->getCollection()
1105
- ->setStoreId('1')
1106
- ->addAttributeToSelect('name')
1107
- ->addAttributeToSelect('is_active')
1108
- ->addAttributeToFilter('level', array('eq' => 2))
1109
- ->addAttributeToFilter('is_active', array('eq' => 1))
1110
- ->addAttributeToSort('position', 'asc');
1111
- //echo $collection->getSelect();
1112
-
1113
-
1114
- $i=1;
1115
- $count=count($collection);
1116
- if($count>0)
1117
- {
1118
-
1119
- foreach($collection as $category)
1120
- {
1121
- $name=$category->getName();
1122
- $id=$category->getId();
1123
- $file = $basePath.'/CoDzip/CoDfiles/CatalogSection.txt';
1124
- file_put_contents($file,"sec_Project\tsec_Sequence\tsec_HierarchyPath\tsec_Flag\n");
1125
- $stringe.=$helper->drawItem($category,1,$name,$i);
1126
- file_put_contents($file,$stringe,FILE_APPEND);
1127
- $i++;
1128
- }
1129
- }
1130
- $lastId=$i;
1131
- $str="General\t".$lastId."\tUncategorized\t". $sec_Flag . "\n";
1132
- file_put_contents($file,$str,FILE_APPEND);
1133
- if($count==0)
1134
- {
1135
- $progress=0;
1136
- }
1137
-
1138
- //clean up the memory
1139
- unset($catalogSectionModel);
1140
- unset($collection);
1141
- unset($stringe);
1142
-
1143
- Mage::log("Notice : Create Catalog Section End: ", null, $this->_logFile);
1144
- return $progress;
1145
- }
1146
- //code for create Catalog Project
1147
- public function createCatalogProject($fromcron=0)
1148
- {
1149
- $dir = dirname(__FILE__);
1150
- $_baseDirArray = explode("app", $dir);
1151
- $basePath = $_baseDirArray[0];
1152
- Mage::log("Notice : Create Catalog Project Start", null, $this->_logFile);
1153
-
1154
- ini_set('memory_limit','1024M');
1155
-
1156
- $this->InitImportStatuses();
1157
-
1158
- $fh = fopen($basePath.'CoDzip/CoDfiles/CatalogProject.txt', 'w');
1159
-
1160
- if ( !$fh )
1161
- {
1162
- Mage::log("ERROR : Cann't open file for building data file:".$basePath, null, $this->_logFile);
1163
- return;
1164
- }
1165
-
1166
- fwrite($fh, "proj_Key\tproj_ProdName\tproj_Sequence\tproj_Name\tproj_HierarchyPath\tproj_Flag\tproj_ProdLayout");
1167
-
1168
- $products = Mage::getModel('catalog/product')->getCollection();
1169
- $products->addAttributeToFilter('status', 1);//enabled
1170
- $products->addAttributeToFilter('visibility', 4);//catalog, search
1171
- $products->addAttributeToSelect('*');
1172
-
1173
- $prodIds = $products->getAllIds();
1174
- $totalproduct=count($prodIds);
1175
- $this->addImportStatus("start");
1176
-
1177
- $status = "end";
1178
- $i='0';
1179
-
1180
- try{
1181
-
1182
- foreach($prodIds as $productId)
1183
- {
1184
- set_time_limit(20);
1185
- $message = $this->getImportStatuses();
1186
- if ( isset($message) && $message['message'] == "cancel") {
1187
- $status = "cancel";
1188
- break;
1189
- }
1190
- $product = Mage::getModel('catalog/product');
1191
- $product->load($productId);
1192
- Mage::log("Notice : Codi Import Products :".$i, null, $this->_logFile);
1193
- fwrite($fh, $this->CatalogProjucttoString($product, "product"));
1194
- $i++;
1195
-
1196
- }
1197
- //Change for zip code if not call from cronjob
1198
- if($fromcron==0)
1199
- {
1200
- $DataFile = 'CoDMagento';
1201
- Mage::helper('codi/createzip')->createimportzip($DataFile);
1202
- }
1203
- }
1204
- catch (Exception $e)
1205
- {
1206
- return 'error';
1207
- Mage::log("Notice : Codi Catalog Project Exception :".$e->getMessage(), null, $this->_logFile);
1208
- }
1209
- //clean up the memory
1210
- unset($products);
1211
- unset($prodIds);
1212
- unset($product);
1213
- fclose($fh);
1214
- $progress='10';
1215
- Mage::log("Notice :Codi Catalog Project End : ".$status, null, $this->_logFile);
1216
-
1217
- return $progress;
1218
- }
1219
- //Code for Catalog projuct section
1220
- public function CatalogProjucttoString( $product , $from )
1221
- {
1222
-
1223
- if( $product->isConfigurable() )
1224
- {
1225
- return $this->ProjucttoStringConfigurable( $product , $from ) ;
1226
- }
1227
- else
1228
- {
1229
- return $this->ProjucttoStringSimple( $product , $from ) ;
1230
- }
1231
- }
1232
-
1233
- public function ProjucttoStringConfigurable( $product , $from )
1234
- {
1235
- //get All associated products
1236
- $UsedProductIds = Mage::getModel('catalog/product_type_configurable')->getUsedProductIds($product);
1237
- $countUsedProductIds=count($UsedProductIds);
1238
- if($countUsedProductIds>0)
1239
- {
1240
- ini_set('memory_limit','1024M');
1241
- $ProducttoString = '' ;
1242
- //************************* Get Categories names Start ***************************
1243
- $categories = $product->getCategoryIds();
1244
- $CategoriesString = "" ;
1245
- $helper=Mage::helper('codi');
1246
- $catelogSectionModel=Mage::getModel('codi/codi');
1247
- if($categories)
1248
- {
1249
- foreach($categories as $k => $_category_id)
1250
- {
1251
- set_time_limit(20);
1252
- $_cat = Mage::getModel('catalog/category')->load($_category_id);
1253
- if(($_cat->getName() != '') && ($_cat->getIsActive() == 1) && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
1254
- {
1255
- $data=$catelogSectionModel->isCatalogSectionStart($_category_id);
1256
- $CategoriesString=$data['category_hirarchy_path'];
1257
- //code for product position
1258
- $position=$helper->productPostion($_category_id,$product->getId());
1259
- if ($CategoriesString==false) $CategoriesString = 'Uncategorized' ;
1260
- //************************* Concatenate Product Info Start ***********************
1261
- $ProducttoString .= "\r\n" . $product->getId().'#$#'. $this->cleanStr( $product->getName()); //ProductKey
1262
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
1263
- $ProducttoString .= "\t" . $this->cleanStr( $position ) ; //Prod Sequence
1264
- $ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
1265
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Hirarachi Path
1266
- $ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
1267
- $ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
1268
- //************************* Concatenate Product Info End ************************* cleanStr
1269
- }
1270
- }
1271
- }
1272
- else
1273
- {
1274
- $ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
1275
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
1276
- $ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
1277
- $ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
1278
- $ProducttoString .= "\t" . $this->cleanStr('Uncategorized'); //Hirarachi Path
1279
- $ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
1280
- $ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
1281
-
1282
-
1283
-
1284
- }
1285
- //Clean up
1286
- unset($categories);
1287
- unset($catelogSectionModel);
1288
- unset($CategoriesString);
1289
- unset($position);
1290
- unset($product);
1291
- }
1292
- else
1293
- {
1294
- $ProducttoString='';
1295
- }
1296
-
1297
-
1298
- return $ProducttoString ;
1299
- }
1300
-
1301
- /////////////////////////////////////////// Simple Products ///////////////////////////////////////////////////////////////////
1302
- public function ProjucttoStringSimple( $product , $from )
1303
- {
1304
- ini_set('memory_limit','1024M');
1305
- $ProducttoString = '' ;
1306
- //************************* Get Categories names Start ***************************
1307
- $categories = $product->getCategoryIds();
1308
- $CategoriesString = "" ;
1309
- $catelogSectionModel=Mage::getModel('codi/codi');
1310
- $helper=Mage::helper('codi');
1311
- if($categories)
1312
- {
1313
- foreach($categories as $k => $_category_id){
1314
- set_time_limit(20);
1315
- //Code for add category hirarchi_path
1316
- $_cat = Mage::getModel('catalog/category')->load($_category_id);
1317
- if(($_cat->getName() != '') && ($_cat->getIsActive() == 1) && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
1318
- {
1319
- $data=$catelogSectionModel->isCatalogSectionStart($_category_id);
1320
- $CategoriesString=$data['category_hirarchy_path'];
1321
- //code for product position
1322
- $position=$helper->productPostion($_category_id,$product->getId());
1323
-
1324
- if ($CategoriesString == false ) $CategoriesString = 'Uncategorized' ;
1325
- //************************* Concatenate Product Info Start ***********************
1326
- $ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
1327
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
1328
- $ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
1329
- $ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
1330
- $ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Hirarachi Path
1331
- $ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
1332
- $ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
1333
- //************************* Concatenate Product Info End ************************* cleanStr
1334
- }
1335
- }
1336
- }
1337
- else
1338
- {
1339
- $ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
1340
- $ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
1341
- $ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
1342
- $ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
1343
- $ProducttoString .= "\t" . $this->cleanStr('Uncategorized'); //Hirarachi Path
1344
- $ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
1345
- $ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
1346
-
1347
-
1348
-
1349
- }
1350
- //Clean up
1351
- unset($categories);
1352
- unset($catelogSectionModel);
1353
- unset($CategoriesString);
1354
- unset($position);
1355
- unset($product);
1356
-
1357
- return $ProducttoString ;
1358
- }
1359
- //Functions for Codi CatalogSection Table
1360
- public function InitCatalogSectionTable(){
1361
-
1362
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1363
-
1364
- $write->query("DROP TABLE IF EXISTS codi_catalog_section");
1365
- $write->query("CREATE TABLE codi_catalog_section(
1366
- category_id int(11) NOT NULL PRIMARY KEY,
1367
- category_hirarchy_path text)"
1368
- );
1369
- }
1370
-
1371
- public function existCatalogSectionTable(){
1372
-
1373
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1374
-
1375
- $write->query("CREATE TABLE IF NOT EXISTS codi_catalog_section(
1376
- category_id int(11) NOT NULL PRIMARY KEY,
1377
- category_hirarchy_path text)"
1378
- );
1379
-
1380
- }
1381
-
1382
- public function addCatalogSection( $category_id=1, $category_hirarchy_path = 'Uncategorized' ){
1383
-
1384
- $this->existCatalogSectionTable();
1385
-
1386
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1387
- $query = "insert into codi_catalog_section (category_id, category_hirarchy_path) values('".$category_id."', '".$category_hirarchy_path."')";
1388
- $write->query($query);
1389
- }
1390
- public function deleteCatalogSectionTable(){
1391
-
1392
- $this->existCatalogSectionTable();
1393
-
1394
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1395
- $query = "delete from codi_catalog_section";
1396
- $write->query($query);
1397
- }
1398
-
1399
- public function isCatalogSectionStart($category_id=1){
1400
-
1401
- $this->existCatalogSectionTable();
1402
-
1403
- $read= Mage::getSingleton('core/resource')->getConnection('core_read');
1404
-
1405
- $query = "select category_hirarchy_path from codi_catalog_section where category_id = '".$category_id."' order by category_id desc limit 1";
1406
-
1407
- $result = $read->query($query);
1408
-
1409
- if($row = $result->fetch() ){
1410
-
1411
- return $row;
1412
- }
1413
-
1414
- return false;
1415
- } //Function for save data import progress status
1416
-
1417
- public function saveProgressData($message='start',$finished=0,$created_time='',$update=0,$var='')
1418
- {
1419
- $tableName = Mage::getSingleton('core/resource')->getTableName('codi_progress_status');
1420
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1421
- if($update==0)
1422
- {
1423
- $query = "insert into ".$tableName." (message, finished,created_time) values('".$message."', $finished,$created_time)";
1424
- }
1425
- else
1426
- {
1427
- /*$query = "update ".$tableName." set message='".$message."', finished=".$finished.", created_time =".$created_time." where id=".$var;*/
1428
- $query = "delete FROM ".$tableName." where finished=1";
1429
-
1430
- }
1431
- $write->query($query);
1432
- return $write->lastInsertId();
1433
- }
1434
-
1435
- //Function to get last row details
1436
- public function getstatus()
1437
- {
1438
- $tableName = Mage::getSingleton('core/resource')->getTableName('codi_progress_status');
1439
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
1440
-
1441
- $query = "select message,finished,created_time from ".$tableName." where finished=1 order by id desc limit 1";
1442
- $var=$write->query($query);
1443
-
1444
- return $var;
1445
- }
1446
-
1447
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/controllers/Adminhtml/MenuController.php DELETED
@@ -1,327 +0,0 @@
1
- <?php
2
- ini_set("max_execution_time", 3600);
3
- ini_set('session.gc_maxlifetime', 3600);
4
- ini_set("memory_limit","512M");
5
-
6
- class Mage_Codi_Adminhtml_MenuController extends Mage_Adminhtml_Controller_Action
7
- {
8
-
9
- public $CodiBlock ;
10
-
11
- protected function _construct()
12
- {
13
- $this->CodiBlock = $this->getLayout()->createBlock('codi/customer_codi');
14
- $this->_logFile = "Catalog-on-demand.log";
15
- }
16
-
17
- public function indexAction()
18
- {
19
- $this->loadLayout();
20
- $this->_setActiveMenu('catalog');
21
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
22
- $this->renderLayout();
23
- }
24
-
25
- public function authAction()
26
- {
27
- $codimodel = Mage::getSingleton('codi/codi');
28
- $codimodel->target = "auth";
29
- $this->loadLayout();
30
- $this->_setActiveMenu('catalog');
31
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
32
- $this->renderLayout();
33
- }
34
-
35
- public function systemtestAction(){
36
-
37
- $codimodel = Mage::getSingleton('codi/codi');
38
- $codimodel->target = "systemtest";
39
- $this->loadLayout();
40
- $this->_setActiveMenu('catalog');
41
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
42
- $this->renderLayout();
43
- }
44
-
45
- public function createAction(){
46
-
47
- $codimodel = Mage::getSingleton('codi/codi');
48
- $codimodel->target = "create";
49
- $this->loadLayout();
50
- $this->_setActiveMenu('catalog');
51
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
52
- $this->renderLayout();
53
- }
54
-
55
- public function createfileAction(){
56
-
57
- $codimodel = Mage::getSingleton('codi/codi');
58
-
59
- $dir = dirname(__FILE__);
60
-
61
- $_baseDirArray = explode("app", $dir);
62
- $basePath = $_baseDirArray[0].'/';
63
-
64
- if ( !$codimodel->createFile($basePath) ){
65
- Mage::log("ERROR : Cannot create file : ".$basePath, null, $this->_logFile);
66
- print '{"error": "1"}';
67
- return;
68
- }
69
-
70
- $is_process = $this->getRequest()->getParam('is_process');
71
-
72
- Mage::log("Notice: Mage_Codi_MenuController Process : ".$is_process, null, $this->_logFile);
73
-
74
- if ( $is_process == 1 ){
75
-
76
- if( false !== strpos(ini_get("disable_functions"), "exec") ) {
77
-
78
- $this->bgCheckSave();
79
-
80
- print '{"exec": "1"}';
81
-
82
- }else if ( false !== strpos(ini_get("disable_functions"), "shell_exec") ){
83
-
84
- $this->bgCheckSave();
85
-
86
- print '{"shellexec": "1"}';
87
- }else{
88
-
89
- $output = shell_exec("ps ax | grep php");
90
-
91
- Mage::log("Notice: Mage_Codi_MenuController Process : ".$output, null, $this->_logFile);
92
-
93
- if ( strpos($output, "php5") !== false ){
94
- exec("nohup php5 ".$dir."/../../Codi_Process.php > /dev/null & echo $!");
95
- Mage::log("Notice: Mage_Codi_MenuController Process : php5 ", null, $this->_logFile);
96
- }else{
97
- exec("nohup php ".$dir."/../../Codi_Process.php > /dev/null & echo $!");
98
- Mage::log("Notice: Mage_Codi_MenuController Process : php ", null, $this->_logFile);
99
- }
100
-
101
- $codimodel->addImportStatus('auto', 0);
102
- Mage::log("Notice: Mage_Codi_MenuController Process : auto ", null, $this->_logFile);
103
-
104
- print '{"success": "1"}';
105
- }
106
- }
107
- else{
108
-
109
- $codimodel->addImportStatus('manual', 0);
110
-
111
- print '{"success": "1"}';
112
-
113
- }
114
- }
115
-
116
- public function cancelAction(){
117
-
118
- $codimodel = Mage::getSingleton('codi/codi');
119
- $codimodel->addImportStatus('cancel', 1);
120
-
121
- print "cancel";
122
- }
123
-
124
- public function updatestatusAction()
125
- {
126
- $codimodel = Mage::getSingleton('codi/codi');
127
- $message = $codimodel->getImportStatuses();
128
-
129
- $dir = dirname(__FILE__);
130
- $_baseDirArray = explode("app", $dir);
131
- $basePath = $_baseDirArray[0].'/';
132
-
133
- $status = 0;
134
- if ( isset($message) ){
135
-
136
- $status = $message['message'];
137
-
138
- if ( $status== "end" && $message['finished'] == 1 ){
139
-
140
- @unlink($basePath."CoDZip/CoDfiles/temp.txt");
141
- $codimodel->deleteTable();
142
- print '{"finished": "1"}';
143
-
144
- }else if ( $status== "cancel" && $message['finished'] == 1 ) {
145
-
146
- @unlink($basePath."CoDZip/CoDfiles/temp.txt");
147
- $codimodel->deleteTable();
148
- print '{"canceled": "1"}';
149
-
150
- }else if ( $status== "start" && $message['finished'] == 0 ) {
151
-
152
- print '{"processed": "1"}';
153
-
154
- }else if ( $status== "fileerror" && $message['finished'] == 1 ) {
155
-
156
- @unlink($basePath."CoDZip/CoDfiles/temp.txt");
157
- $codimodel->deleteTable();
158
- print '{"fileerror": "1"}';
159
-
160
- }else if ( $status== "manual" && $message['finished'] == 0 ) {
161
-
162
- print '{"processed": "1"}';
163
- $codimodel->run_codi_import_manually($basePath);
164
-
165
- }else if ( $status== "auto" && $message['finished'] == 0 ){
166
- if ( !$codimodel->isStart() ){
167
- @unlink($basePath."CoDZip/CoDfiles/temp.txt");
168
- $codimodel->deleteTable();
169
- print '{"error": "1"}';
170
- }
171
- }
172
- }
173
- }
174
-
175
- public function bgcheckAction(){
176
-
177
- $checked = $this->getRequest()->getParam('check');
178
-
179
- $this->bgCheckSave($checked);
180
- }
181
-
182
- public function bgCheckSave($checked=0){
183
-
184
- $codimodel = Mage::getSingleton('codi/codi');
185
-
186
- $codimodel->setStoreConfig(
187
- array(
188
- "codbgcheck" => array ('value' => $checked)
189
- )
190
- );
191
-
192
- Mage::app()->getCacheInstance()->cleanType('config');
193
- }
194
-
195
- public function authsaveAction()
196
- {
197
- $userid = strtolower((string)$this->getRequest()->getParam('userid'));
198
- $password = (string)$this->getRequest()->getParam('password');
199
- $secretkey = (string)$this->getRequest()->getParam('secretkey');
200
- $enablefreshflyers = (string)$this->getRequest()->getParam('enablefreshflyers');
201
- $enablereviews = (string)$this->getRequest()->getParam('enablereviews');
202
- $fromchild = (string)$this->getRequest()->getParam('fromchild');
203
-
204
- $codflyerlinkimg = (string)$this->getRequest()->getParam('codflyerlinkimg');
205
- $codflyerlinkimgurl = (string)$this->getRequest()->getParam('codflyerlinkimgurl');
206
- $codflyerlinkimgalt = (string)$this->getRequest()->getParam('codflyerlinkimgalt');
207
-
208
- $codbeforename = (string)$this->getRequest()->getParam('codbeforename');
209
- $codaftername = (string)$this->getRequest()->getParam('codaftername');
210
-
211
- $codbeforeemailto = (string)$this->getRequest()->getParam('codbeforeemailto');
212
- $codafteremailto = (string)$this->getRequest()->getParam('codafteremailto');
213
-
214
- $codbeforeOR = (string)$this->getRequest()->getParam('codbeforeOR');
215
- $codafterOR = (string)$this->getRequest()->getParam('codafterOR');
216
-
217
- $codbeforeoverview = (string)$this->getRequest()->getParam('codbeforeoverview');
218
- $codafteroverview = (string)$this->getRequest()->getParam('codafteroverview');
219
-
220
- //ver 2.2.16
221
- $coddatafilelaunch = (string)$this->getRequest()->getParam('datafilelaunch');
222
- //for waitfor minute
223
-
224
- $waitforminute = (string)$this->getRequest()->getParam('waitforminute');
225
- $includeshortdescription = (string)$this->getRequest()->getParam('includeshortdescription');
226
-
227
- //Code for Tier pricing
228
- $codpublishtieredpricing=(string)$this->getRequest()->getParam('publishtieredpricing');
229
- $codquantity=(string)$this->getRequest()->getParam('codquantity');
230
- $codprice=(string)$this->getRequest()->getParam('codprice');
231
- $codsavings=(string)$this->getRequest()->getParam('codsavings');
232
-
233
-
234
- $codimodel = Mage::getSingleton('codi/codi');
235
-
236
- $codimodel->setStoreConfig(
237
- array(
238
- "codusername" => array ('value' => $userid) ,
239
- "codpassword" => array ('value' => $password) ,
240
- "secretkey" => array ('value' => $secretkey) ,
241
- "enablefreshflyers" => array ('value' => $enablefreshflyers) ,
242
- "codenablereviews" => array ('value' => $enablereviews) ,
243
- "fromchild" => array ('value' => $fromchild) ,
244
- "codflyerlinkimg" => array ('value' => $codflyerlinkimg) ,
245
- "codflyerlinkimgurl" => array ('value' => $codflyerlinkimgurl) ,
246
- "codflyerlinkimgalt" => array ('value' => $codflyerlinkimgalt) ,
247
- "codbeforename" => array ('value' => $codbeforename) ,
248
- "codaftername" => array ('value' => $codaftername) ,
249
- "codbeforeemailto" => array ('value' => $codbeforeemailto) ,
250
- "codafteremailto" => array ('value' => $codafteremailto) ,
251
- "codbeforeOR" => array ('value' => $codbeforeOR) ,
252
- "codafterOR" => array ('value' => $codafterOR) ,
253
- "codbeforeoverview" => array ('value' => $codbeforeoverview) ,
254
- "codafteroverview" => array ('value' => $codafteroverview) ,
255
- "coddatafilelaunch" => array ('value' => $coddatafilelaunch) ,
256
- "codwaitforminute" => array ('value' => $waitforminute),
257
- "codincludeshortdescription" => array ('value' => $includeshortdescription),
258
- "codpublishtieredpricing" => array ('value' => $codpublishtieredpricing),
259
- "codquantity" => array ('value' => $codquantity),
260
- "codprice" => array ('value' => $codprice),
261
- "codsavings" => array ('value' => $codsavings),
262
- )
263
- );
264
-
265
- Mage::app()->getCacheInstance()->cleanType('config');
266
-
267
- $this->_redirect('codi/adminhtml_menu/auth');
268
- }
269
-
270
- public function registerAction()
271
- {
272
- $codimodel = Mage::getSingleton('codi/codi');
273
- $codimodel->target = "register";
274
- $this->loadLayout();
275
- $this->_setActiveMenu('catalog');
276
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
277
- $this->renderLayout();
278
- }
279
-
280
- public function documentationAction()
281
- {
282
- $codimodel = Mage::getSingleton('codi/codi');
283
- $codimodel->target = "documentation";
284
- $this->loadLayout();
285
- $this->_setActiveMenu('catalog');
286
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
287
- $this->renderLayout();
288
- }
289
-
290
- //Change for version 2.2.15
291
- public function downloadtestAction(){
292
-
293
- $codimodel = Mage::getSingleton('codi/codi');
294
- $codimodel->target = "auth";
295
- $helper=Mage::helper('codi');
296
- $filename='CoDMagento.zip';
297
- //Change for zip code
298
- $helper->output_file('CoDzip/CoDMagento.zip',$filename , 'application/zip');
299
- $this->loadLayout();
300
- $this->_setActiveMenu('catalog');
301
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
302
- $this->renderLayout();
303
- }
304
- public function deletetestAction()
305
- {
306
- $dir = dirname(__FILE__);
307
-
308
- $_baseDirArray = explode("app", $dir);
309
- $basePath = $_baseDirArray[0].'/';
310
-
311
-
312
- $codimodel = Mage::getSingleton('codi/codi');
313
- $codimodel->target = "auth";
314
- $helper=Mage::helper('codi');
315
- //change for zip file
316
- $filename='/CoDzip/CoDMagento.zip';
317
- $helper->deleteFile($basePath,$filename);
318
- $this->loadLayout();
319
- $this->_setActiveMenu('catalog');
320
- $this->_addContent($this->getLayout()->createBlock('codi/adminhtml_menu'));
321
- $this->renderLayout();
322
- $this->_redirect('codi/adminhtml_menu/auth');
323
-
324
-
325
- }
326
-
327
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/controllers/DeleteController.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- require_once 'Mage/Core/Controller/Front/Action.php';
3
- class Mage_Codi_DeleteController extends Mage_Core_Controller_Front_Action
4
- {
5
-
6
- public function indexAction()
7
- {
8
- $this->_logFile = "Catalog-on-demand.log";
9
-
10
- Mage::log("Notice : Mage_Codi_DeleteController", null, $this->_logFile);
11
-
12
- $dir = dirname(__FILE__);
13
- $_baseDirArray = explode("app", $dir);
14
- $basePath = $_baseDirArray[0];
15
-
16
- //code for remove zip files
17
- $files = glob($basePath."CoDzip/*.zip");
18
- foreach($files as $file)
19
- {
20
- //changed for zip file
21
- if($file!=$basePath."CoDzip/CoDMagento.zip")
22
- unlink($file);
23
- }
24
-
25
- //remove text files
26
- $filesn = glob($basePath."CoDzip/CoDfiles/*.txt");
27
-
28
- foreach($filesn as $filen)
29
- {
30
- //if(($filen!=$basePath."CoDzip/CoDfiles/CoDMagento.txt")&&($filen!=$basePath."CoDzip/CoDfiles/CatalogProject.txt")&&($filen!=$basePath."CoDzip/CoDfiles/CatalogSection.txt"))
31
- unlink($filen);
32
-
33
- }
34
-
35
- Mage::log("Notice : DeleteindexAction End", null, $this->_logFile);
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/controllers/NsyncController.php DELETED
@@ -1,178 +0,0 @@
1
- <?php
2
- ini_set("max_execution_time", 3600);
3
- ini_set("memory_limit","1024M");
4
- require_once 'Mage/Core/Controller/Front/Action.php';
5
- class Mage_Codi_NsyncController extends Mage_Core_Controller_Front_Action
6
- {
7
- public $CodiBlock ;
8
-
9
- public function indexAction()
10
- {
11
- $this->_logFile = "Catalog-on-demand.log";
12
- //Code for progress
13
- $message='start';
14
- $finished=1;
15
- $created_time=time();
16
- $CodiModel = Mage::getModel('codi/codi');
17
-
18
- $var=$CodiModel->saveProgressData($message,$finished,$created_time);
19
- //echo $var;die();
20
-
21
-
22
- Mage::log("Notice: Mage_Codi_NSyncController", null, $this->_logFile);
23
-
24
- $error_msg = "";
25
-
26
-
27
- $dir = dirname(__FILE__);
28
- $_baseDirArray = explode("app", $dir);
29
- $basePath = $_baseDirArray[0].'/';
30
-
31
- //Create folder if not exist.
32
- if ( !is_dir($basePath.'CoDzip/CoDfiles/') )
33
- mkdir($basePath.'CoDzip/CoDfiles/');
34
-
35
- $DataFile = 'CoDMagento.txt';
36
- $CodiModel->new_run_codi_import($basePath);
37
-
38
-
39
- $error = "";
40
- $message = $CodiModel->getImportStatuses();
41
- $mes=implode(',',$message);
42
- $status = 0;
43
- if (isset($message) ){
44
- $status = $message['message'];
45
- if ( $status== "end" && $message['finished'] == 1 ){
46
- rename($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/'.$DataFile);
47
- $CodiModel->deleteTable();
48
- $CodiModel->addImportStatus('end', 1);
49
- print '{"success": "1"}';
50
- Mage::log("ERROR : Finished to create product file", null, $this->_logFile);
51
-
52
- }else if ( $status== "cancel" && $message['finished'] == 1 ) {
53
-
54
- $error = "ERROR\nCanceled to create product file";
55
- $CodiModel->deleteTable();
56
- Mage::log("ERROR : Canceled to create product file", null, $this->_logFile);
57
-
58
- }else if ( $status== "fileerror" && $message['finished'] == 1 ) {
59
-
60
- $error = "ERROR\nFailed to create product file";
61
- $CodiModel->deleteTable();
62
- Mage::log("ERROR : Failed to create product file", null, $this->_logFile);
63
-
64
- }else{
65
- $error = "ERROR\nFailed to create product file";
66
- $CodiModel->deleteTable();
67
- Mage::log("ERROR : Failed to create product file 1", null, $this->_logFile);
68
- }
69
- }else{
70
- $error = "ERROR\nFailed to create product file";
71
- $CodiModel->deleteTable();
72
- Mage::log("ERROR : Failed to create product file 2", null, $this->_logFile);
73
- }
74
- // Calling function to create Catalog Section
75
- $CodiModel->createCatalogSection();
76
- //Calling function to create Catalog Project
77
- $CodiModel->createCatalogProject('1');
78
-
79
- //Code for Update values after file download
80
- $message='start';
81
- $update=1;
82
- $finished=2;
83
- $created_time=time();
84
- $CodiModel->saveProgressData($message,$finished,$created_time,$update,$var);
85
- }
86
-
87
- // Below function is for the loader
88
-
89
- public function manualAction()
90
- {
91
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
92
- $products = Mage::getModel('catalog/product')->getCollection();
93
- $products->addAttributeToFilter('status', 1);//enabled
94
- $products->addAttributeToFilter('visibility', 4);//catalog, search
95
- $products->addAttributeToSelect('sku');
96
- $prodIds = $products->getAllIds();
97
-
98
- print Mage::helper('codi')->array2json($prodIds);
99
- }
100
- //create file
101
- public function updatestatusAction()
102
- {
103
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
104
- ini_set('memory_limit','1024M');
105
- set_time_limit(0);
106
- $this->_logFile = "Catalog-on-demand.log";
107
- Mage::log("Notice: Mage_Codi_NSyncController", null, $this->_logFile);
108
-
109
-
110
- $CodiModel = Mage::getModel('codi/codi');
111
- //product is id of the product
112
- $productid=$this->getRequest()->getParam('product');
113
- // counter is no. of product passed
114
- $counter=$this->getRequest()->getParam('counter');
115
- // Total product . counter and total is for calculating how many percent of data is transfered.
116
- $total=$this->getRequest()->getParam('total');
117
- //basepath
118
- $basepath=$this->getRequest()->getParam('basepath');
119
- $fh = fopen($basepath.'CoDzip/CoDfiles/temp.txt', 'a');
120
- try{
121
- // below condition is for the write all heading only first time after that it will not write.
122
- if($counter==1){
123
-
124
- fwrite($fh, "itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductMfg\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tCategory\tReviews\tSupplementalInfo");
125
-
126
- }
127
-
128
- $product = Mage::getModel('catalog/product');
129
- $product->load($productid);
130
-
131
- Mage::log("Notice : Codi Import Products :".$productid, null, $this->_logFile);
132
- fwrite($fh, $CodiModel->ProducttoString($product, "product"));
133
- }catch(Exception $e)
134
- {
135
- echo "error";
136
- return;
137
- }
138
- fclose($fh);
139
- $progress=(string)(($counter/$total)*100);
140
- if($progress=='100'){
141
- $DataFile = 'CoDMagento.txt';
142
- rename($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/'.$DataFile);
143
- //die();
144
- }
145
- unset($product);
146
- echo floor($progress);
147
-
148
-
149
-
150
- }
151
- //Create Catalog section file
152
- public function createcatalogsectionAction()
153
- {
154
- ini_set('memory_limit','1024M');
155
- set_time_limit(0);
156
- //create object of Codi Model
157
- $CodiModel = Mage::getModel('codi/codi');
158
- // Calling function to create CatalogSection
159
- $progress=$CodiModel->createCatalogSection();
160
-
161
- echo $progress;
162
- }
163
-
164
- //Create Catalog section file
165
- public function createcatalogprojectAction()
166
- {
167
- ini_set('memory_limit','1024M');
168
- set_time_limit(0);
169
- //create object of Codi Model
170
- $CodiModel = Mage::getModel('codi/codi');
171
- // Calling function to create CatalogProject
172
- $progress=$CodiModel->createCatalogProject();
173
- echo $progress;
174
-
175
- }
176
-
177
-
178
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/controllers/SyncController.php DELETED
@@ -1,215 +0,0 @@
1
- <?php
2
- ini_set("max_execution_time", 3600);
3
- ini_set("memory_limit","512M");
4
- require_once 'Mage/Core/Controller/Front/Action.php';
5
- class Mage_Codi_SyncController extends Mage_Core_Controller_Front_Action
6
- {
7
- public function indexAction()
8
- {
9
- $this->_logFile = "Catalog-on-demand.log";
10
-
11
- Mage::log("Notice: Mage_Codi_SyncController", null, $this->_logFile);
12
-
13
- $error_msg = "";
14
- //Check validity of Secret Key
15
- if ( $this->getRequest()->getParam('SecretKey') != Mage::getStoreConfig('codi/codi/secretkey') )
16
- {
17
- Mage::log("ERROR : Secret Key Not accepted", null, $this->_logFile);
18
- $error_msg = "ERROR\nSecret Key Not accepted.";
19
- }
20
-
21
- $CodiModel = Mage::getModel('codi/codi');
22
-
23
- $dir = dirname(__FILE__);
24
- $_baseDirArray = explode("app", $dir);
25
- $basePath = $_baseDirArray[0];
26
-
27
- //Create folder if not exist. change for zip
28
- if ( !is_dir($basePath.'CoDzip/') )
29
- {
30
- mkdir($basePath.'CoDzip/');
31
- chmod($basePath.'CoDzip/',777);
32
- if ( !is_dir($basePath.'CoDzip/CoDfiles/') )
33
- {
34
- mkdir($basePath.'CoDzip/CoDfiles/');
35
- chmod($basePath.'CoDzip/CoDfiles/',777);
36
- }
37
- }
38
- /*
39
- if ( !is_dir($basePath.'CoDzip/') )
40
- mkdir($basePath.'CODdataFiles/');
41
- */
42
-
43
- if ( !$CodiModel->createFile($basePath) ){
44
- Mage::log("ERROR : Cannot create file : ".$basePath, null, $this->_logFile);
45
- $error_msg = "ERROR\nThe Magento extension was prevented from creating a file in the folder CoDzip/CoDfiles. The import has been cancelled. Please notify your Magento administrator.";
46
- }
47
- $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
48
- if ( $url == "http://" || $url == "https://" ){
49
-
50
- Mage::log("ERROR : Cannot prepare the callback link : ".$url, null, $this->_logFile);
51
- $error_msg = "ERROR\nCannot prepare the callback link.";
52
- }
53
- if ( $error_msg == "" )
54
- {
55
- $error_msg = "OK";
56
- //respond immediately
57
- $datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
58
- $wait='';
59
- if($datafilelaunch=='cod')
60
- {
61
-
62
- $waitforminute=Mage::getStoreConfig('codi/codi/codwaitforminute')/60;
63
- $wait="\r\nWaitFor=".number_format($waitforminute,2,'.','');
64
- }
65
- }
66
- @ob_end_clean();
67
- header("Connection: close\r\n");
68
- header("Content-Encoding: none\r\n");
69
- ignore_user_abort(true);
70
- ob_start();
71
- echo $error_msg.$wait;
72
- header("Content-Length: ".ob_get_length());
73
- ob_end_flush();
74
- flush();
75
- @ob_end_clean();
76
-
77
- Mage::log("Notice: Response ". $error_msg, null, $this->_logFile);
78
-
79
- if ( $error_msg != "OK" ){
80
- exit(0);
81
- }
82
-
83
- //Code for progress
84
- $message='start';
85
- $finished=1;
86
- $created_time=time();
87
- $CodiModel = Mage::getModel('codi/codi');
88
-
89
- $var=$CodiModel->saveProgressData($message,$finished,$created_time);
90
-
91
- $DataFile = (string)$this->getRequest()->getParam('FileName');
92
- $filename = $basePath.'CoDzip/CoDfiles/CoDMagento.txt';
93
- //Check code for file is exists or not
94
- $fExist=0;
95
- $modifie='';
96
- if (file_exists($filename)) {
97
- $fExist=1;
98
- $modifie=date("M d, Y H:i:s.", filemtime($filename));
99
- copy($filename, $basePath.'CoDzip/CoDfiles/'.$DataFile.'.txt');
100
- }
101
-
102
-
103
- Mage::log("Notice: Response ". $DataFile, null, $this->_logFile);
104
- $datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
105
-
106
- if((($datafilelaunch=="magento") || ($datafilelaunch=="manual") ) && ($fExist==1))
107
- {
108
- Mage::helper('codi/createzip')->createimportzip($DataFile);
109
- Mage::log("Notice: Import Products using Magento Cron job: ".$datafilelaunch, null, $this->_logFile);
110
-
111
- }
112
- else
113
- {
114
- Mage::log("Notice: Import Products using Catalog on demand: ".$datafilelaunch, null, $this->_logFile);
115
- $CodiModel->run_codi_import($basePath);
116
- $error = "";
117
- $message = $CodiModel->getImportStatuses();
118
-
119
- $status = 0;
120
- if ( isset($message) ){
121
- $status = $message['message'];
122
-
123
- if ( $status== "end" && $message['finished'] == 1 ){
124
- $modifie=date("M d, Y H:i:s.", filemtime($basePath.'CoDzip/CoDfiles/temp.txt'));
125
-
126
- // Calling function to create Catalog Section
127
- $progress=$CodiModel->createCatalogSection();
128
- $progress=$CodiModel->createCatalogProject(1);
129
- copy($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/CoDMagento.txt');
130
- rename($basePath.'CoDzip/CoDfiles/temp.txt', $basePath.'CoDzip/CoDfiles/'.$DataFile.'.txt');
131
- Mage::helper('codi/createzip')->createimportzip($DataFile);
132
- $CodiModel->deleteTable();
133
-
134
- Mage::log("ERROR : Finished to create product file", null, $this->_logFile);
135
-
136
- }else if ( $status== "cancel" && $message['finished'] == 1 ) {
137
-
138
- $error = "ERROR\nCanceled to create product file";
139
- $CodiModel->deleteTable();
140
- Mage::log("ERROR : Canceled to create product file", null, $this->_logFile);
141
-
142
- }else if ( $status== "fileerror" && $message['finished'] == 1 ) {
143
-
144
- $error = "ERROR\nFailed to create product file";
145
- $CodiModel->deleteTable();
146
- Mage::log("ERROR : Failed to create product file", null, $this->_logFile);
147
-
148
- }else{
149
- $error = "ERROR\nFailed to create product file";
150
- $CodiModel->deleteTable();
151
- Mage::log("ERROR : Failed to create product file 1", null, $this->_logFile);
152
- }
153
- }else{
154
- $error = "ERROR\nFailed to create product file";
155
- $CodiModel->deleteTable();
156
- Mage::log("ERROR : Failed to create product file 2", null, $this->_logFile);
157
- }
158
- }
159
- //Prepare the callback parameters
160
-
161
- $pos = strpos($url, 'index.php');
162
- $DataFileLink = substr($url, 0, $pos ) . 'CoDzip/' . $DataFile.'.zip';
163
-
164
- Mage::log("Notice: Prepare the callback parameters link: ". $DataFileLink, null, $this->_logFile);
165
-
166
- $ProcessID = (string)$this->getRequest()->getParam('ProcessID');
167
- $url = (string)$this->getRequest()->getParam('CallbackURL');
168
- $DeleteDataFileURL = (string)Mage::getUrl('codi/delete') ;
169
-
170
- $Comment = $CodiModel->getComment($modifie);
171
- Mage::log("Notice: Prepare the Comment : ". $Comment, null, $this->_logFile);
172
- //code for getTheme
173
- $helper=Mage::helper('codi');
174
- $TemplateName=(string)$helper->getTheme();
175
-
176
-
177
- $paramsarray = array( 'ProcessID' => $ProcessID,
178
- 'TemplateName' => $TemplateName,
179
- 'DataFileLink' => $DataFileLink ,
180
- 'DeleteDataFileURL' => $DeleteDataFileURL ,
181
- 'Encoding' => 'utf-8' ,
182
- 'ClearDatabase' => 'MissingOnly' ,
183
- 'PartnerID' => 'CoDMagento' ,
184
- 'CatalogProject' => 'magento',
185
- 'Comment' => $Comment);
186
- if ( $error != "" ) {
187
- $paramsarray = array('ProcessID' => $ProcessID,
188
- 'TemplateName' => $TemplateName,
189
- 'DataFileLink' => $DataFileLink ,
190
- 'DeleteDataFileURL' => $DeleteDataFileURL ,
191
- 'Encoding' => 'utf-8' ,
192
- 'ClearDatabase' => 'MissingOnly' ,
193
- 'PartnerID' => 'CoDMagento' ,
194
- 'CatalogProject' => 'magento',
195
- 'Comment' => $Comment,
196
- 'Error' => $error);
197
- }
198
-
199
- Mage::log("Notice: Prepare the DataFileLink : ". $DataFileLink, null, $this->_logFile);
200
- Mage::log("Notice: Prepare the process ID : ". $ProcessID, null, $this->_logFile);
201
- Mage::log("Notice: Prepare the delete url : ". $DeleteDataFileURL, null, $this->_logFile);
202
- Mage::log("Notice: Prepare the callback url : ". $url, null, $this->_logFile);
203
- Mage::log("Notice: Prepare the template theme : ". $TemplateName, null, $this->_logFile);
204
- $Responsemsg = $CodiModel->Call( $url, $paramsarray );
205
-
206
- //Code for Update values after file download
207
- $message='start';
208
- $update=1;
209
- $finished=2;
210
- $created_time=time();
211
- $CodiModel->saveProgressData($message,$finished,$created_time,$update,$var);
212
-
213
- Mage::log("Notice: Prepare the callback response message ". $Responsemsg, null, $this->_logFile);
214
- }
215
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/etc/config.xml DELETED
@@ -1,146 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Mage_Codi>
5
- <version>3.0.9</version>
6
- </Mage_Codi>
7
- </modules>
8
- <adminhtml>
9
- <menu>
10
- <catalog translate="title" module="catalog">
11
- <title>Catalog</title>
12
- <depends>
13
- <module>Mage_Catalog</module>
14
- </depends>
15
- <children>
16
- <codi translate="title" module="catalog">
17
- <sort_order>-1</sort_order>
18
- <title>Catalog-On-Demand</title>
19
- <action>codi/adminhtml_menu/</action>
20
- </codi>
21
- </children>
22
- </catalog>
23
- </menu>
24
- </adminhtml>
25
- <global> <resources> <codi_setup> <setup> <module>Mage_Codi</module> </setup> <connection> <use>core_setup</use> </connection> </codi_setup> </resources>
26
- <!--
27
- <fieldsets>
28
- <customer_account>
29
- <codinternaluser><create>1</create><update>1</update></codinternaluser>
30
- </customer_account>
31
- </fieldsets>
32
- -->
33
-
34
- <!--
35
- <blocks>
36
- <adminhtml>
37
- <rewrite>
38
- <widget_grid>Mage_Codi_Block_Widget_Grid</widget_grid>
39
- </rewrite>
40
- </adminhtml>
41
- </blocks>
42
- <blocks>
43
- <adminhtml>
44
- <rewrite>
45
- <widget_grid_massaction>Mage_Codi_Block_Widget_Grid_Massaction</widget_grid_massaction>
46
- </rewrite>
47
- </adminhtml>
48
- </blocks>
49
- <blocks>
50
- <adminhtml>
51
- <rewrite>
52
- <catalog_product_grid>Mage_Codi_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
53
- </rewrite>
54
- </adminhtml>
55
- </blocks>
56
- <blocks>
57
- <adminhtml>
58
- <rewrite>
59
- <catalog_product>Mage_Codi_Block_Adminhtml_Catalog_Product</catalog_product>
60
- </rewrite>
61
- </adminhtml>
62
- </blocks>
63
- -->
64
- <!-- V2 Start-->
65
- <models>
66
- <codi>
67
- <class>Mage_Codi_Model</class>
68
- </codi>
69
- </models>
70
- <blocks>
71
- <codi>
72
- <class>Mage_Codi_Block</class>
73
- </codi>
74
- </blocks>
75
- <!--
76
- <events>
77
- <adminhtml_controller_action_predispatch_start>
78
- <observers>
79
- <mage_codi_codi>
80
- <type>singleton</type>
81
- <class>mage_codi_model_codi</class>
82
- <method>adminstart</method>
83
- </mage_codi_codi>
84
- </observers>
85
- </adminhtml_controller_action_predispatch_start>
86
- </events>
87
- <rewrite>
88
- <codi_index_update>
89
- <from><![CDATA[#^/wishlist/index/update/#]]></from>
90
- <to>codi/index/update</to>
91
- </codi_index_update>
92
-
93
- <codi_index_index>
94
- <from><![CDATA[#^/wishlist/$#]]></from>
95
- <to>codi/codifront/index</to>
96
- </codi_index_index>
97
-
98
- <codi_codifront_index1>
99
- <from><![CDATA[#^/wishlist/codifront#]]></from>
100
- <to>codi/codifront/index</to>
101
- </codi_codifront_index1>
102
- </rewrite>
103
- -->
104
- </global>
105
- <frontend>
106
- <routers>
107
- <codi>
108
- <use>standard</use>
109
- <args>
110
- <module>Mage_Codi</module>
111
- <frontName>codi</frontName>
112
- </args>
113
- </codi>
114
- </routers>
115
- <!--
116
- <layout>
117
- <updates>
118
- <codi>
119
- <file>codi.xml</file>
120
- </codi>
121
- </updates>
122
- </layout>
123
- -->
124
- </frontend>
125
- <admin>
126
- <routers>
127
- <codi>
128
- <use>admin</use>
129
- <args>
130
- <module>Mage_Codi</module>
131
- <frontName>codi</frontName>
132
- </args>
133
- </codi>
134
- </routers>
135
- </admin>
136
- <!--<adminhtml>
137
- <layout>
138
- <updates>
139
- <codi>
140
- <file>codi.xml</file>
141
- </codi>
142
- </updates>
143
- </layout>
144
- </adminhtml> -->
145
- <!-- V2 End-->
146
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/sql/codi_setup/mysql4-install-3.0.4.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- $installer->run("
8
-
9
- DROP TABLE IF EXISTS {$this->getTable('codi_progress_status')};
10
- CREATE TABLE {$this->getTable('codi_progress_status')} (
11
- `id` int(11) unsigned NOT NULL auto_increment,
12
- `message` varchar(50) NOT NULL default '',
13
- `finished` smallint(1) NOT NULL default '0',
14
- `created_time` varchar(50) NULL,
15
- PRIMARY KEY (`id`)
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
- ");
18
-
19
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/Codi/sql/codi_setup/mysql4-install-3.0.6.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- $installer->run("
8
-
9
- DROP TABLE IF EXISTS {$this->getTable('codi_progress_status')};
10
- CREATE TABLE {$this->getTable('codi_progress_status')} (
11
- `id` int(11) unsigned NOT NULL auto_increment,
12
- `message` varchar(50) NOT NULL default '',
13
- `finished` smallint(1) NOT NULL default '0',
14
- `created_time` varchar(50) NULL,
15
- PRIMARY KEY (`id`)
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
- ");
18
-
19
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Mage/CodiPDF/Block/Adminhtml/Menu.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Codipdf_Block_Adminhtml_Menu extends Mage_Adminhtml_Block_Template
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setTemplate('codipdf/index.phtml');
9
+ }
10
+ }
app/code/community/Mage/CodiPDF/Model/Codipdf.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Codipdf_Model_Codipdf extends Mage_Core_Model_Abstract
4
+ {
5
+ public $target ;
6
+ public $userid;
7
+ public $disableextension ;
8
+ public $version = "3.0.10";
9
+ public $customerid ;
10
+ public $customerdatasourceid ;
11
+ public $validateuser ;
12
+ public $extensionName='Mage_PDF_per_Product';
13
+ public $StoreId ;
14
+
15
+
16
+ public function _construct() {
17
+ parent::_construct();
18
+ $this->_init('codipdf/codipdf');
19
+ $this->_logFile = "Catalog-on-demand-items.log";
20
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
21
+
22
+
23
+ // Get StoreID -Start
24
+ foreach (Mage::app()->getWebsites() as $website)
25
+ {
26
+ $defaultGroup = $website->getDefaultGroup();
27
+ $StoreId = $defaultGroup->getDefaultStoreId();
28
+ }
29
+
30
+ $this->StoreId = $StoreId ;
31
+ // Get StoreID -End
32
+
33
+ }
34
+
35
+ public function setStoreConfig( $myarray ) {
36
+ $section = 'codipdf' ;
37
+ $website = '' ;
38
+ $store = '';
39
+
40
+ $groups =
41
+ array(
42
+ 'codipdf' =>
43
+ array(
44
+ 'fields' => $myarray
45
+ ));
46
+ Mage::getModel('adminhtml/config_data')
47
+ ->setSection($section)
48
+ ->setWebsite($website)
49
+ ->setStore($store)
50
+ ->setGroups($groups)
51
+ ->save();
52
+ }
53
+
54
+
55
+
56
+
57
+ }
app/code/community/Mage/CodiPDF/controllers/Adminhtml/MenuController.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ ini_set("max_execution_time", 3600);
3
+ ini_set('session.gc_maxlifetime', 3600);
4
+ ini_set("memory_limit","512M");
5
+
6
+ class Mage_CodiPDF_Adminhtml_MenuController extends Mage_Adminhtml_Controller_Action
7
+ {
8
+
9
+ public $CodiBlock ;
10
+
11
+ protected function _construct()
12
+ {
13
+ //$this->CodiBlock = $this->getLayout()->createBlock('codi/customer_codi');
14
+ $this->_logFile = "Catalog-on-demand.log";
15
+ }
16
+
17
+ public function indexAction()
18
+ {
19
+ $this->loadLayout();
20
+ $this->_setActiveMenu('catalog');
21
+ $this->_addContent($this->getLayout()->createBlock('codipdf/adminhtml_menu'));
22
+ $this->renderLayout();
23
+ }
24
+
25
+ public function authAction()
26
+ {
27
+ $codimodel = Mage::getSingleton('codipdf/codipdf');
28
+ $codimodel->target = "auth";
29
+ $this->loadLayout();
30
+ $this->_setActiveMenu('catalog');
31
+ $this->_addContent($this->getLayout()->createBlock('codipdf/adminhtml_menu'));
32
+ $this->renderLayout();
33
+ }
34
+
35
+
36
+ public function authsaveAction()
37
+ {
38
+ $userid = strtolower((string)$this->getRequest()->getParam('userid'));
39
+ $enablefreshflyers = (string)$this->getRequest()->getParam('enablefreshflyers');
40
+
41
+ $codflyerlinkimg = (string)$this->getRequest()->getParam('codflyerlinkimg');
42
+ $codflyerlinkimgurl = (string)$this->getRequest()->getParam('codflyerlinkimgurl');
43
+ $codflyerlinkimgalt = (string)$this->getRequest()->getParam('codflyerlinkimgalt');
44
+
45
+ $codbeforename = (string)$this->getRequest()->getParam('codbeforename');
46
+ $codaftername = (string)$this->getRequest()->getParam('codaftername');
47
+
48
+ $codbeforeemailto = (string)$this->getRequest()->getParam('codbeforeemailto');
49
+ $codafteremailto = (string)$this->getRequest()->getParam('codafteremailto');
50
+
51
+ $codbeforeOR = (string)$this->getRequest()->getParam('codbeforeOR');
52
+ $codafterOR = (string)$this->getRequest()->getParam('codafterOR');
53
+
54
+ $codbeforeoverview = (string)$this->getRequest()->getParam('codbeforeoverview');
55
+ $codafteroverview = (string)$this->getRequest()->getParam('codafteroverview');
56
+
57
+
58
+
59
+ $codimodel = Mage::getSingleton('codipdf/codipdf');
60
+
61
+ $codimodel->setStoreConfig(
62
+ array(
63
+ "codusername" => array ('value' => $userid) ,
64
+ "codpassword" => array ('value' => $password) ,
65
+ "secretkey" => array ('value' => $secretkey) ,
66
+ "enablefreshflyers" => array ('value' => $enablefreshflyers) ,
67
+ "codenablereviews" => array ('value' => $enablereviews) ,
68
+ "fromchild" => array ('value' => $fromchild) ,
69
+ "codflyerlinkimg" => array ('value' => $codflyerlinkimg) ,
70
+ "codflyerlinkimgurl" => array ('value' => $codflyerlinkimgurl) ,
71
+ "codflyerlinkimgalt" => array ('value' => $codflyerlinkimgalt) ,
72
+ "codbeforename" => array ('value' => $codbeforename) ,
73
+ "codaftername" => array ('value' => $codaftername) ,
74
+ "codbeforeemailto" => array ('value' => $codbeforeemailto) ,
75
+ "codafteremailto" => array ('value' => $codafteremailto) ,
76
+ "codbeforeOR" => array ('value' => $codbeforeOR) ,
77
+ "codafterOR" => array ('value' => $codafterOR) ,
78
+ "codbeforeoverview" => array ('value' => $codbeforeoverview) ,
79
+ "codafteroverview" => array ('value' => $codafteroverview) ,
80
+ "coddatafilelaunch" => array ('value' => $coddatafilelaunch) ,
81
+ "codwaitforminute" => array ('value' => $waitforminute),
82
+ "codincludeshortdescription" => array ('value' => $includeshortdescription),
83
+ "codpublishtieredpricing" => array ('value' => $codpublishtieredpricing),
84
+ "codquantity" => array ('value' => $codquantity),
85
+ "codprice" => array ('value' => $codprice),
86
+ "codsavings" => array ('value' => $codsavings),
87
+ )
88
+ );
89
+
90
+ Mage::app()->getCacheInstance()->cleanType('config');
91
+
92
+ $this->_redirect('codipdf/adminhtml_menu/auth');
93
+ }
94
+
95
+ public function registerAction()
96
+ {
97
+ $codimodel = Mage::getSingleton('codipdf/codipdf');
98
+ $codimodel->target = "register";
99
+ $this->loadLayout();
100
+ $this->_setActiveMenu('catalog');
101
+ $this->_addContent($this->getLayout()->createBlock('codipdf/adminhtml_menu'));
102
+ $this->renderLayout();
103
+ }
104
+
105
+ public function documentationAction()
106
+ {
107
+ $codimodel = Mage::getSingleton('codipdf/codipdf');
108
+ $codimodel->target = "documentation";
109
+ $this->loadLayout();
110
+ $this->_setActiveMenu('catalog');
111
+ $this->_addContent($this->getLayout()->createBlock('codipdf/adminhtml_menu'));
112
+ $this->renderLayout();
113
+ }
114
+
115
+ //Change for version 2.2.15
116
+ }
app/code/community/Mage/CodiPDF/etc/config.xml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mage_CodiPDF>
5
+ <version>3.0.9</version>
6
+ </Mage_CodiPDF>
7
+ </modules>
8
+
9
+ <adminhtml>
10
+ <menu>
11
+ <catalog translate="title" module="catalog">
12
+ <title>Catalog</title>
13
+ <depends>
14
+ <module>Mage_Catalog</module>
15
+ </depends>
16
+ <children>
17
+ <codipdf translate="title" module="catalog">
18
+ <sort_order>-1</sort_order>
19
+ <title>Catalog-On-Demand PDF</title>
20
+ <action>codipdf/adminhtml_menu/</action>
21
+ </codipdf>
22
+ </children>
23
+ </catalog>
24
+ </menu>
25
+ </adminhtml>
26
+
27
+ <global>
28
+ <models>
29
+ <codipdf>
30
+ <class>Mage_CodiPDF_Model</class>
31
+ </codipdf>
32
+ </models>
33
+ <blocks>
34
+ <codipdf>
35
+ <class>Mage_CodiPDF_Block</class>
36
+ </codipdf>
37
+ </blocks>
38
+ </global>
39
+
40
+ <frontend>
41
+ <routers>
42
+ <codipdf>
43
+ <use>standard</use>
44
+ <args>
45
+ <module>Mage_CodiPDF</module>
46
+ <frontName>codipdf</frontName>
47
+ </args>
48
+ </codipdf>
49
+ </routers>
50
+
51
+ </frontend>
52
+
53
+ <admin>
54
+ <routers>
55
+ <codipdf>
56
+ <use>admin</use>
57
+ <args>
58
+ <module>Mage_CodiPDF</module>
59
+ <frontName>codipdf</frontName>
60
+ </args>
61
+ </codipdf>
62
+ </routers>
63
+ </admin>
64
+
65
+ </config>
app/design/adminhtml/default/default/layout/{codi.xml → codipdf.xml} RENAMED
@@ -1,12 +1,12 @@
1
  <?xml version="1.0"?>
2
  <layout version="0.1.0">
3
 
4
- <mage_codi_index>
5
- <block type="core/template" name="codi" template="codi/index.phtml" >
6
  <!--<block type="adminhtml/system_config_switcher" name="store_switcher" template="codi/switcher.phtml">
7
  <action method="setUseConfirm"><params>0</params></action>
8
  </block>-->
9
  </block>
10
- </mage_codi_index>
11
 
12
  </layout>
1
  <?xml version="1.0"?>
2
  <layout version="0.1.0">
3
 
4
+ <mage_codipdf_index>
5
+ <block type="core/template" name="codipdf" template="codipdf/index.phtml" >
6
  <!--<block type="adminhtml/system_config_switcher" name="store_switcher" template="codi/switcher.phtml">
7
  <action method="setUseConfirm"><params>0</params></action>
8
  </block>-->
9
  </block>
10
+ </mage_codipdf_index>
11
 
12
  </layout>
app/design/adminhtml/default/default/template/{codi → codipdf}/index.phtml RENAMED
@@ -1,77 +1,30 @@
1
- <?php
2
  error_reporting(E_WARNING);
3
 
4
- $codimodel = Mage::getSingleton('codi/codi');
5
- $userid = Mage::getStoreConfig('codi/codi/codusername') ;
6
- $password = Mage::getStoreConfig('codi/codi/codpassword') ;
7
- $secretkey = Mage::getStoreConfig('codi/codi/secretkey') ;
8
-
9
- $enablefreshflyers = Mage::getStoreConfig('codi/codi/enablefreshflyers') ;
10
- $enablereviews = Mage::getStoreConfig('codi/codi/codenablereviews') ;
11
- $fromchild = Mage::getStoreConfig('codi/codi/fromchild') ;
12
-
13
- $codflyerlinkimg = Mage::getStoreConfig('codi/codi/codflyerlinkimg') ;
14
- $codflyerlinkimgurl = Mage::getStoreConfig('codi/codi/codflyerlinkimgurl') ;
15
- $codflyerlinkimgalt = Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') ;
16
-
17
- $codbeforename = Mage::getStoreConfig('codi/codi/codbeforename') ;
18
- $codaftername = Mage::getStoreConfig('codi/codi/codaftername') ;
19
-
20
- $codbeforeemailto = Mage::getStoreConfig('codi/codi/codbeforeemailto') ;
21
- $codafteremailto = Mage::getStoreConfig('codi/codi/codafteremailto') ;
22
-
23
- $codbeforeOR = Mage::getStoreConfig('codi/codi/codbeforeOR') ;
24
- $codafterOR = Mage::getStoreConfig('codi/codi/codafterOR') ;
25
 
26
- $codbeforeoverview = Mage::getStoreConfig('codi/codi/codbeforeoverview') ;
27
- $codafteroverview = Mage::getStoreConfig('codi/codi/codafteroverview') ;
28
 
29
- $codbgcheck = Mage::getStoreConfig('codi/codi/codbgcheck') ;
30
 
31
- $post_url = $this->getUrl('codi/nsync/manual');
32
- $post_url_upd = $this->getUrl('codi/adminhtml_menu/updatestatus');
33
- $post_url_cancel = $this->getUrl('codi/adminhtml_menu/cancel');
34
- $post_bgprocess_check = $this->getUrl('codi/adminhtml_menu/bgcheck');
35
- //chagned ver 3.0.1
36
- $newpostupdate = $this->getUrl('codi/nsync/updatestatus');
37
- //Changed for category section file
38
- $createCatalogSection = $this->getUrl('codi/nsync/createcatalogsection');
39
 
40
- //Changed for Category project section
41
- $createCatalogProject = $this->getUrl('codi/nsync/createcatalogproject');
42
-
43
- //Changed ver 2.2.15
44
- $download_url = $this->getUrl('codi/adminhtml_menu/downloadtest');
45
- $delete_codi_url = $this->getUrl('codi/adminhtml_menu/deletetest');
46
-
47
- //Chagned ver 2.2.16
48
- $datafilelaunch = Mage::getStoreConfig('codi/codi/coddatafilelaunch');
49
-
50
- $codbg_checked = "";
51
- if ( $codbgcheck == 1 ) $codbg_checked = "checked";
52
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  $extensionName="Mage_PDF_per_Product";
54
- $currentVer = Mage::getConfig()->getModuleConfig('Mage_Codi')->version;
55
 
56
- //Changed ver 3.0.1 Added wait for minute parameter
57
- $waitforminute=Mage::getStoreConfig('codi/codi/codwaitforminute');
58
- $includeshortdescription = Mage::getStoreConfig('codi/codi/codincludeshortdescription');
59
 
60
- //Chagned ver 3.0.2 Added Tier price display settings
61
- $publishtieredpricing=Mage::getStoreConfig('codi/codi/codpublishtieredpricing');
62
- $codquantity=Mage::getStoreConfig('codi/codi/codquantity');
63
- $codprice=Mage::getStoreConfig('codi/codi/codprice');
64
- $codsavings=Mage::getStoreConfig('codi/codi/codsavings');
65
-
66
- //Changed for show download zip file url
67
- $zipurl = $this->getUrl('CoDzip/') ;
68
- $pos = strrpos ($zipurl , 'key') ;
69
- if ( $pos != 0 )
70
- $zipurl = substr( $zipurl , 0 , $pos ) ;
71
- else
72
- $zipurl = $zipurl;
73
-
74
- $zipurl=str_replace("index.php/CoDzip/index/index/", "CoDzip/",$zipurl);
75
 
76
  ?>
77
  <style>
@@ -103,313 +56,57 @@ $codsavings=Mage::getStoreConfig('codi/codi/codsavings');
103
  <div class="columns ">
104
  <div class="side-col" id="page:left">
105
  <h3>Catalog-On-Demand®</h3>
106
- <?php
107
- $CodiModel = Mage::getModel('codi/codi');
108
- $vari=$CodiModel->getstatus();// check status for datafile
109
-
110
- foreach ($vari as $var)
111
- {
112
- $message=$var['message'];
113
- $finished=$var['finished'];
114
- $start_time=$var['created_time'];
115
- }
116
-
117
- $end_time=strtotime('+1 hours',$start_time);
118
- $endwait_time=strtotime('+'.$waitforminute. 'minutes',$start_time);
119
- $current_time=time();
120
-
121
-
122
- if($finished==1 && $endwait_time<$current_time &&$end_time<$current_time)
123
- {
124
- $mess='Sorry! Your last product import failed. Please use Manual mode to create the data file. Click on the help icon for instructions.';
125
-
126
- }
127
-
128
-
129
- if($start_time<$current_time && $current_time<$end_time)
130
- {
131
- $data='Data file is in process';
132
-
133
- ?>
134
- <ul id="product_info_tabs" class="tabs">
135
- <li >
136
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/register');?>" onclick="return false;">
137
- <span>Sign Up</span>
138
- </a>
139
- </li>
140
- <li >
141
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/auth');?>" onclick="return false;" >
142
- <span>Configuration Settings</span>
143
- </a>
144
- </li>
145
- <li >
146
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/systemtest');?>" onclick="return false;">
147
- <span>System Test</span>
148
- </a>
149
- </li>
150
- <li >
151
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/documentation');?>" onclick="return false;">
152
- <span>Documentation</span>
153
- </a>
154
- </li>
155
- </ul>
156
- <?php
157
- }
158
-
159
- else
160
- {
161
- ?>
162
 
163
  <ul id="product_info_tabs" class="tabs">
164
  <li >
165
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/register');?>" class="tab-item-link "
166
- <?php if ( $codimodel->target == "register") echo "style='background-color:#ffffff;'" ; ?>
167
  onclick="window.open ('https://www.catalog-on-demand.com/signup/');" >
168
  <span>Sign Up</span>
169
  </a>
170
  </li>
171
  <li >
172
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/auth');?>" class="tab-item-link "
173
  <?php if ( $codimodel->target == "auth") echo "style='background-color:#ffffff;'" ; ?> >
174
  <span>Configuration Settings</span>
175
  </a>
176
- </li>
177
- <li >
178
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/systemtest');?>" class="tab-item-link "
179
- <?php if ( $codimodel->target == "systemtest") echo "style='background-color:#ffffff;'" ; ?> >
180
- <span>System Test</span>
181
- </a>
182
  </li>
183
  <li >
184
- <a href="<?php echo $this->getUrl('codi/adminhtml_menu/documentation');?>" class="tab-item-link "
185
- <?php if ( $codimodel->target == "documentation") echo "style='background-color:#ffffff;'" ; ?>
186
  onclick="window.open ('http://www.catalog-on-demand.com/plans/catalog-on-demand_for_magento.php');">
187
  <span>Documentation</span>
188
  </a>
189
  </li>
190
  </ul>
191
- <?php
192
- }?>
193
  </div>
 
194
  <div class="main-col" id="content">
195
  <div class="main-col-inner">
196
  <div class="content-header"></div>
197
  <!-- Show message when data file is in process or stopped -->
198
- <div style="color: red;"><?php echo $mess; ?></div>
199
- <div style="color: green;font: 12px/1.5em "><?php echo $data; ?></div>
200
  <?php
201
- $extensions = array('curl','dom', 'hash','iconv','mcrypt' );
 
 
 
202
 
203
- $fail = '';
204
- $pass = '';
205
-
206
- if(version_compare(phpversion(), '5.2.0', '<')) {
207
- $fail .= '<li>You need<strong> PHP 5.2.0</strong> (or greater). Your current version is '.phpversion().'</li>';
208
- }
209
- else {
210
- $pass .='<li>You have<strong> PHP '.phpversion().'</strong></li>';
211
- }
212
-
213
- if( !ini_get('safe_mode') ) {
214
- $pass .='<li>Safe Mode is <strong>off</strong></li>';
215
- }
216
- else { $fail .= '<li>Safe Mode is <strong>on</strong></li>'; }
217
-
218
- foreach($extensions as $extension) {
219
- if( !extension_loaded($extension) ) {
220
- $fail .= '<li> You are missing the <strong>'.$extension.'</strong> extension</li>';
221
- }
222
- else{
223
- $pass .= '<li>You have the <strong>'.$extension.'</strong> extension</li>';
224
- }
225
- }
226
-
227
-
228
- $baseDir = dirname(__FILE__);
229
-
230
- $_baseDirArray = explode("app", $baseDir);
231
- $basePath = $_baseDirArray[0];
232
-
233
- //Create folder if not exist. change for zip
234
- if (!is_dir($basePath.'CoDzip/') )
235
- {
236
- if (!mkdir($basePath.'CoDzip/'))
237
- {
238
- $fail .= "<li>Could not create <strong>CoDzip</strong> folder.</li>";
239
- $fail .= "<li>Please create <strong>CoDzip manually</strong> in ".$basePath."</li>";
240
-
241
- }
242
- }
243
- if (is_dir($basePath.'CoDzip/') )
244
- {
245
- if (!is_dir($basePath.'CoDzip/CoDfiles/') )
246
- {
247
- if (!mkdir($basePath.'CoDzip/CoDfiles/'))
248
- {
249
- $fail .= "<li>Could not create <strong>CoDzip/CoDfiles</strong> folder.</li>";
250
- $fail .= "<li>Please create <strong>CoDzip/CoDfiles manually</strong> in ".$basePath."</li>";
251
- }
252
- }
253
- }
254
- /*if ( !is_dir($basePath.'CoDzip/CoDfiles/') ){
255
- if ( !mkdir($basePath.'CoDzip/CoDFiles/') ){
256
-
257
- $fail .= "<li>Could not create <strong>CoDzip</strong> folder.</li>";
258
- $fail .= "<li>Please create <strong>CoDzip manually</strong> in ".$basePath."</li>";
259
- }
260
- }*/
261
-
262
- $is_file = true;
263
-
264
- if ( !$codimodel->createFileInit($basePath) ){
265
- $fail .= "<li>The Magento extension was prevented from creating a file in the folder CoDzip. Please notify your Magento administrator.</li>";
266
- $is_file = false;
267
- }
268
-
269
- $target = $codimodel->target;
270
-
271
- if ( $target == "auth" && $fail != "" ){
272
- $target = "systemtest";
273
- }
274
-
275
  switch ($target)
276
  {
277
  case "register":
278
  break;
279
  case "documentation":
280
  break;
281
- case "systemtest":
282
-
283
- echo "<div class='entry-edit'>
284
- <div class='entry-edit-head'>
285
- <h4 class='icon-head head-edit-form fieldset-legend'>System Test</h4>
286
- <div>&nbsp;</div>
287
- </div>
288
- <div class='fieldset'>
289
- ";
290
-
291
- if( $fail ) {
292
- echo '<p><strong>Your server is not properly configured to run the Catalog-on-Demand® for Magento® extension.</strong>';
293
- echo '<br>Please contact your hosting provider to report the failure of the following tests:';
294
- echo '<br><ul>'.$fail.'</ul></p>';
295
- echo '<br>The following tests were successfully met:';
296
- echo '<ul>'.$pass.'</ul>';
297
- } else {
298
- echo '<p><strong>Congratulations!</strong>&nbsp; Your server has passed all the tests to properly run the Catalog-on-Demand® for Magento® extension.</p>';
299
- echo '<ul>'.$pass.'</ul>';
300
- }
301
-
302
- echo "<br/>";
303
-
304
-
305
- echo '<p> Current Extension Name : <b>'.$extensionName.'</b></p>';
306
-
307
- echo '<p>Current Extension Version: <b>'.$currentVer.'</b></p>';
308
-
309
-
310
-
311
-
312
- $exec_command = "";
313
-
314
- if( (false !== strpos(ini_get("disable_functions"), "exec")) || (false !== strpos(ini_get("disable_functions"), "shell_exec")) ) {
315
- $exec_command = "<p>The <strong>exec</strong> and/or <strong>shell_exec</strong> functions are disabled in your php.ini. See the line starting with <strong>'disable_functions ='</strong>. Unless you remove both <strong>'exec'</strong> and <strong>'shell_exec'</strong> from this line, you may not use the background process to create data files. This may be a problem if you have a large product database.</p>";
316
- }else{
317
- $exec_command = "The <strong>exec</strong> and <strong>shell_exec</strong> functions are enabled. You may use the background process to create data files.";
318
- }
319
-
320
- echo $exec_command;
321
-
322
- echo "<br/><br/>";
323
-
324
- foreach (Mage::app()->getWebsites() as $website)
325
- {
326
- $defaultGroup = $website->getDefaultGroup();
327
- $StoreId = $defaultGroup->getDefaultStoreId();
328
- }
329
-
330
- $design = Mage::getSingleton('core/design')->loadChange($StoreId);
331
-
332
- $package = $design->getPackage();
333
- $default_theme = $design->getTheme();
334
-
335
- if ( $package == "" && $default_theme == "" ){
336
-
337
- $package = Mage::getStoreConfig('design/package/name', $StoreId);
338
- $default_theme = Mage::getStoreConfig('design/theme/default', $StoreId);
339
- }
340
-
341
- if ( $package == "" ) $package = "default";
342
- if ( $default_theme == "" ) $default_theme = "default";
343
-
344
- $update_guide = "<ul style='list-style:decimal outside none;padding-left:30px;'>";
345
- $update_guide .= "<li><p>Open this file : /app/design/frontend/default/default/template/catalog/product/view.phtml. This will be your 'source' file.</p></li>";
346
- $update_guide .= "<li><p>Your view.phtml ( /app/design/frontend/".$package."/".$default_theme."/template/catalog/product/view.phtml ) will be your 'target' file. </p><p>Please copy the code as follows: </p>";
347
- $update_guide .= "<ul style='list-style:square outside none;padding-left:30px;'>";
348
- $update_guide .= "<li><p>Copy lines 37-50, and paste after the line containing getProduct().</p></li>";
349
- $update_guide .= "<li><p>Copy line 69 and paste before the line containing 'name'.</p></li>";
350
- $update_guide .= "<li><p>Copy line 71 and paste after the line containing 'name'.</p></li>";
351
- $update_guide .= "<li><p>Copy line 79 and paste before the line containing 'Email to a Friend'.</p></li>";
352
- $update_guide .= "<li><p>Copy line 81 and paste after the line containing 'Email to a Friend'.</p></li>";
353
- $update_guide .= "<li><p>Copy line 99 and paste before the line containing 'OR'.</p></li>";
354
- $update_guide .= "<li><p>Copy line 101 and paste after the line containing 'OR'.</p></li>";
355
- $update_guide .= "<li><p>Copy line 115 and paste before the line containing 'Quick Overview'.</p></li>";
356
- $update_guide .= "<li><p>Copy line 117 and paste after the line containing 'Quick Overview'.</p></li>";
357
- $update_guide .= "</ul>";
358
- $update_guide .= "</li>";
359
- $update_guide .= "<ul>";
360
-
361
- if ( $package != "default" || $default_theme != "default" ){
362
-
363
- echo "<p>This is important if you intend to use the Always Fresh™ 'flyer-per-product-page' feature of Catalog-on-Demand®.</p>";
364
- echo "<p>You are using the following theme : <strong>".$package." / ".$default_theme."</strong></p>";
365
- echo "<p>Your site admin will need to edit the view.html for this theme, as follows:</p>";
366
- echo $update_guide;
367
-
368
- }else{
369
- echo "<p>You have the default theme.</p>";
370
- }
371
-
372
- echo "</div></div>";
373
- echo "<br />";
374
-
375
- $text = "";
376
-
377
- if ( $is_file ){
378
-
379
- $message = $codimodel->getImportStatuses();
380
-
381
- if ( isset($message) ){
382
-
383
- $status = $message['message'];
384
-
385
- if ( $status== "end" && $message['finished'] == 1 ){
386
- $text = "<p id='codi_status_template_button'>Your test data file was created successfully. &nbsp;<img src='".$this->getSkinUrl($this->__('images/codimport_yes.gif'))."' /> <button type='button' onclick='download_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Download Data File</span></button> <button type='button' onclick='delete_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Delete Data File</span></button></p>";
387
- $codimodel->deleteTable();
388
- }else if ( $status== "start" && $message['finished'] == 0 ) {
389
- $text = "<p>A test data file is now being created. <span style='margin-left:15px;'><img src='".$this->getSkinUrl($this->__('images/codimport_run.gif'))."' /></span>&nbsp;&nbsp;&nbsp;</p>" ;
390
- }else if ( $status== "fileerror" && $message['finished'] == 0 ) {
391
- $text = "<p>Your test data file was not created. Please contact your administrator.</p>";
392
- $codimodel->deleteTable();
393
- }else{
394
- $text = "<p>Your test data file was not created. Please contact your administrator.</p>";
395
- $codimodel->deleteTable();
396
- }
397
- }
398
- else{
399
- //Changed on version 2.2.15
400
- //$text .= "<a href='#datafilebackground_tooltip'><img src='".$this->getSkinUrl($this->__('images/preview_field_help.png'))."' /></a><input type='checkbox' id='background_process' name='background_process' ".$codbg_checked." style='margin:0px 5px 0px 15px;cursor:pointer' onclick='onBackgroundProcess(this)' />Create data file using background process<br /><br />";
401
- $text .= "<button type='button' class='scalable add' onclick='start_codi_import()' style='margin-left:25px;' ><span>Test</span></button>";
402
- }
403
-
404
-
405
- }
406
- break;
407
  case "auth":
 
408
  ?>
409
 
410
- <?php echo $this->getStoreSwitcherHtml() ?>
411
 
412
- <form name="codiform" action="<?php echo $this->getUrl('codi/adminhtml_menu/authsave') ?>" method="post" id="codiform">
413
  <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
414
  <input name="store" type="hidden" value="<?php echo $this->getRequest()->getParam('store'); ?>" />
415
  <div class="entry-edit">
@@ -430,148 +127,17 @@ switch ($target)
430
  <td class="value"><input name="userid" onchange="makeLowercase();" id="userid" value="<?php echo $userid ?>" class=" input-text" type="text"/></td>
431
  <td><small>&nbsp;</small></td>
432
  </tr>
433
- <tr>
434
- <td class="scope-label"><a href="#secretkey_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
435
- <td class="label"><label for="secretkey">Secret Key</label></td>
436
- <td class="value"><input name="secretkey" id="secretkey" value="<?php echo $secretkey ?>" class=" input-text" type="text"/></td>
437
- <td><small>&nbsp;</small></td>
438
- </tr>
439
- <tr>
440
- <td class="scope-label"><a href="#kickoffurl_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
441
- <td class="label"><label for="secretkey">Kick-off URL</label></td>
442
- <td class="value"><label>
443
- <?php
444
- $url = $this->getUrl('codi/sync') ;
445
- $pos = strrpos ($url , 'key') ;
446
- if ( $pos != 0 )
447
- $kickoffurl = substr( $url , 0 , $pos ) ;
448
- else
449
- $kickoffurl = $url;
450
-
451
- echo "<input class='input-text' type='text' name='kickoffurl' value='".$kickoffurl."'>" ;
452
- ?></label>
453
- </td>
454
- <td><small>&nbsp;</small></td>
455
- </tr>
456
  <tr><td class="scope-label"></td><td class="label"></td><td class="value"></td><td><small>&nbsp;</small></td></tr>
457
- <!-- Changed for version 2.2.16 to add data file launch mode -->
458
- <tr>
459
- <td class="scope-label"><a href="#data_file_launch_mode_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
460
- <td class="label"><label for="DataFileLaunchMode">Data File Launch Mode</label></td>
461
- <td class="value">
462
- <input type="radio" value="manual" id="manual" name="datafilelaunch" <?php if ($datafilelaunch =="manual") echo "checked" ?> onclick="displayBlock('codi_status_template','cronjob','0');"/>&nbsp;<label for="manual">Manual&nbsp;<a href="#manual_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></label><br>
463
- <p id="codi_status_template" name="codi_status_template" style="display:<?php if ($datafilelaunch =="manual") echo 'block'; else echo 'none';?>;">
464
- <?php
465
- $filename = $basePath.'CoDzip/CoDMagento.zip';
466
- if (file_exists($filename)) {
467
-
468
- $url = $this->getUrl('CoDzip/CoDMagento.zip') ;
469
- $pos = strrpos ($url , 'key') ;
470
- if ( $pos != 0 )
471
- $url = substr( $url , 0 , $pos ) ;
472
- else
473
- $url = $url;
474
-
475
- $zipfileurl=str_replace("index.php/CoDzip/CoDMagento.zip/index/", "CoDzip/CoDMagento.zip",$url);
476
- $modifie="<input class='input-text' type='text' name='zipfileurl' value='".$zipfileurl."'><br/>" ;
477
- $modifie.="Last Created Date: " . date("M d, Y H:i:s.", filemtime($filename))."(GMT)";
478
- echo $modifie." <button type='button' onclick='download_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Download Data File</span></button> <button type='button' onclick='delete_codi_file();' class='scalable add' style='margin-left:25px;' ><span>Delete Data File</span></button>";
479
- }
480
- else{
481
- ?>
482
- <button type='button' class='scalable add' onclick='start_codi_import()' style='margin-left:25px;' ><span>Create Data File</span></button>
483
- <?php }?>
484
- </p>
485
-
486
-
487
- <input type="radio" value="cod" id="cod" name="datafilelaunch" <?php if ($datafilelaunch =="cod") echo "checked" ?> onclick="displayBlock('codi_status_template','cronjob','1');" />&nbsp;<label for="cod">Catalog-on-Demand&nbsp;<a href="#codoption_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></label>
488
- <span style="display:<?php if ($datafilelaunch =="cod") echo ''; else echo 'none';?>;" id="waitforminute"><br>Minutes to wait for data file creation : <input type="text" name="waitforminute" onchange="valuevalidation(this.value,5,999,'Please enter only integer value between 5 and 999.','I');" class="waitforminute" width="60px" value="<?php echo $waitforminute;?>">&nbsp;<a href="#waitforminute_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></span><br>
489
- <input type="radio" value="magento" id="magento" name="datafilelaunch" <?php if ($datafilelaunch =="magento") echo "checked" ?> onclick="displayBlock('cronjob','codi_status_template','0');" />&nbsp;<label for="magento">Cron-job &nbsp;<a href="#cronjoburl_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></label>
490
- </td>
491
- <td><small>&nbsp;</small></td>
492
- </tr>
493
- <tr>
494
-
495
- <td class="scope-label"></td>
496
- <td class="label"></td>
497
- <td class="value">
498
- <p id="cronjob" name="cronjob" style="display:<?php if ($datafilelaunch =="magento") echo 'block'; else echo 'none';?>;">
499
- <?php
500
- $url = $this->getUrl('codi/nsync') ;
501
- $pos = strrpos ($url , 'key') ;
502
- if ( $pos != 0 )
503
- $cronjoburl = substr( $url , 0 , $pos ) ;
504
- else
505
- $cronjoburl = $url;
506
 
507
- echo '<input type="text" class="input-text" name="cronjoburl" width="60px" value="wget '.$cronjoburl.'">' ;
508
- ?></p>
509
- </td>
510
- <td><small>&nbsp;</small></td>
511
- </tr>
512
-
513
  <tr>
514
  <td class="scope-label"><a href="#enablefreshflyers_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
515
  <td class="label"><label for="enablefreshflyers">Enable Always Fresh™ Flyers</label></td>
516
  <td class="value"><input name="enablefreshflyers" id="enablefreshflyers" value="checked" <?php if ($enablefreshflyers =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
517
  <td><small>&nbsp;</small></td>
518
  </tr>
519
- <!-- Code for Include Short Description -->
520
- <tr>
521
- <td class="scope-label"><a href="#includeshortdescription_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
522
- <td class="label"><label for="includeshortdescription">Include Short Description</label></td>
523
- <td class="value"><input name="includeshortdescription" id="includeshortdescription" value="checked" <?php if ($includeshortdescription =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
524
- <td><small>&nbsp;</small></td>
525
- </tr>
526
- <tr>
527
- <td class="scope-label"><a href="#enablereviews_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
528
- <td class="label"><label for="enablereviews">Enable Reviews</label></td>
529
- <td class="value"><input name="enablereviews" id="enablereviews" value="checked" <?php if ($enablereviews =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
530
- <td><small>&nbsp;</small></td>
531
- </tr>
532
- <tr>
533
- <td class="scope-label"><a href="#getpricefromchild_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
534
- <td class="label"><label for="fromchild">Get price from associated products</label></td>
535
- <td class="value"><input name="fromchild" id="fromchild" value="checked" <?php if ($fromchild =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
536
- <td><small>&nbsp;</small></td>
537
-
538
- </tr>
539
- <!-- Changes for Tired price option -->
540
  </table>
541
 
542
- <fieldset style="width:460px;">
543
- <legend class="tiredprice"><a href="#tieredpricingoptions_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a>&nbsp; Tiered Pricing Options</legend>
544
- <table class="form-list" cellpadding='0'>
545
- <tr>
546
- <td class="label"><label for="publishtieredpricing">Publish tiered pricing</label></td>
547
- <td class="value"><input name="publishtieredpricing" id="publishtieredpricing" value="checked" <?php if ($publishtieredpricing =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
548
- <td class="scope-label"></td>
549
- <td><small>&nbsp;</small></td>
550
- </tr>
551
-
552
- <tr>
553
- <td class="label"><label for="codquantity">Label for quantity column</label></td>
554
- <td class="value"><input type="text" id="codquantity" name="codquantity" class="input-text" value="<?php if ($codquantity == '') echo 'Quantity'; else echo $codquantity ;?>"></td>
555
- <td class="scope-label"></td>
556
- <td><small>&nbsp;</small></td>
557
- </tr>
558
 
559
- <tr>
560
- <td class="label"><label for="codprice">Label for price column</label></td>
561
- <td class="value"><input type="text" id="codprice" name="codprice" class=" input-text" value="<?php if ($codprice == '') echo 'Price'; else echo $codprice;?>"> </td>
562
- <td class="scope-label"></td>
563
- <td><small>&nbsp;</small></td>
564
- </tr>
565
- <tr>
566
- <td class="label"><label for="codsavings">Label for savings</label></td>
567
- <td class="value"><input type="text" id="codsavings" name="codsavings" class=" input-text" value="<?php if ($codsavings == '') echo 'Savings'; else echo $codsavings;?>" ></td>
568
- <td class="scope-label"></td>
569
- <td><small>&nbsp;</small></td>
570
- </tr>
571
- </table>
572
-
573
- </fieldset>
574
- <!-- End changes for Tired price option -->
575
  <table class="form-list">
576
  <tr><td class="scope-label"></td><td class="label"></td><td class="value"></td><td><small>&nbsp;</small></td></tr>
577
  <tr>
@@ -730,6 +296,7 @@ value="<?php if ($codflyerlinkimgalt == '') echo 'Click for PDF of this product'
730
 
731
  <script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/jquery-1.2.6.noConflict.min.js') ?>"></script>
732
  <script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/jquery.tooltip.js') ?>"></script>
 
733
  <script type="text/javascript">
734
  jQuery("#content a").tooltip({
735
  bodyHandler: function() {
@@ -946,26 +513,6 @@ function displayBlock(show,hide,hideboth)
946
  }
947
 
948
  }
949
- function cancel_codi_import(){
950
-
951
- var url = "<?php echo $post_url_cancel; ?>";
952
- new Ajax.Request(url,
953
- {
954
- method:'post',
955
- onSuccess: function(transport) {
956
- var ret_msg = transport.responseText;
957
-
958
- if ( ret_msg ){
959
-
960
- //var text = "<a href='#datafilebackground_tooltip'><img src=\"<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>\" /></a><br />";
961
- text = "<button type='button' class='scalable add' onclick='start_codi_import()' style='margin-left:25px;' ><span>Create Data File</span></button>";
962
-
963
- var status_div = document.getElementById('codi_status_template');
964
- status_div.innerHTML = text;
965
- }
966
- }
967
- });
968
- }
969
 
970
  function makeLowercase() {
971
  document.getElementById('userid').value = document.getElementById('userid').value.toLowerCase();
1
+ <?php
2
  error_reporting(E_WARNING);
3
 
4
+ $codimodel = Mage::getSingleton('codipdf/codipdf');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ $userid = Mage::getStoreConfig('codipdf/codipdf/codusername') ;
7
+ $enablefreshflyers = Mage::getStoreConfig('codipdf/codipdf/enablefreshflyers') ;
8
 
 
9
 
 
 
 
 
 
 
 
 
10
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ //$fromchild = Mage::getStoreConfig('codi/codi/fromchild') ;
13
+ $codflyerlinkimg = Mage::getStoreConfig('codipdf/codipdf/codflyerlinkimg') ;
14
+ $codflyerlinkimgurl = Mage::getStoreConfig('codipdf/codipdf/codflyerlinkimgurl') ;
15
+ $codflyerlinkimgalt = Mage::getStoreConfig('codipdf/codipdf/codflyerlinkimgalt') ;
16
+ $codbeforename = Mage::getStoreConfig('codipdf/codipdf/codbeforename') ;
17
+ $codaftername = Mage::getStoreConfig('codipdf/codipdf/codaftername') ;
18
+ $codbeforeemailto = Mage::getStoreConfig('codipdf/codipdf/codbeforeemailto') ;
19
+ $codafteremailto = Mage::getStoreConfig('codipdf/codipdf/codafteremailto') ;
20
+ $codbeforeOR = Mage::getStoreConfig('codipdf/codipdf/codbeforeOR') ;
21
+ $codafterOR = Mage::getStoreConfig('codipdf/codipdf/codafterOR') ;
22
+ $codbeforeoverview = Mage::getStoreConfig('codipdf/codipdf/codbeforeoverview') ;
23
+ $codafteroverview = Mage::getStoreConfig('codipdf/codipdf/codafteroverview') ;
24
  $extensionName="Mage_PDF_per_Product";
25
+ $currentVer = Mage::getConfig()->getModuleConfig('Mage_CodiPDF')->version;
26
 
 
 
 
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  ?>
30
  <style>
56
  <div class="columns ">
57
  <div class="side-col" id="page:left">
58
  <h3>Catalog-On-Demand®</h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  <ul id="product_info_tabs" class="tabs">
61
  <li >
62
+ <a href="<?php echo $this->getUrl('codipdf/adminhtml_menu/register');?>" class="tab-item-link "
63
+ <?php if ( $codimodel->target == "register") echo "style='background-color:#ffffff;'" ; ?>
64
  onclick="window.open ('https://www.catalog-on-demand.com/signup/');" >
65
  <span>Sign Up</span>
66
  </a>
67
  </li>
68
  <li >
69
+ <a href="<?php echo $this->getUrl('codipdf/adminhtml_menu/auth');?>" class="tab-item-link "
70
  <?php if ( $codimodel->target == "auth") echo "style='background-color:#ffffff;'" ; ?> >
71
  <span>Configuration Settings</span>
72
  </a>
 
 
 
 
 
 
73
  </li>
74
  <li >
75
+ <a href="<?php echo $this->getUrl('codipdf/adminhtml_menu/documentation');?>" class="tab-item-link "
76
+ <?php if ( $codimodel->target == "documentation") echo "style='background-color:#ffffff;'" ; ?>
77
  onclick="window.open ('http://www.catalog-on-demand.com/plans/catalog-on-demand_for_magento.php');">
78
  <span>Documentation</span>
79
  </a>
80
  </li>
81
  </ul>
82
+
 
83
  </div>
84
+
85
  <div class="main-col" id="content">
86
  <div class="main-col-inner">
87
  <div class="content-header"></div>
88
  <!-- Show message when data file is in process or stopped -->
89
+
90
+
91
  <?php
92
+ //echo '1111';
93
+ //var_dump($target);
94
+
95
+ $target = $codimodel->target;
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  switch ($target)
98
  {
99
  case "register":
100
  break;
101
  case "documentation":
102
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  case "auth":
104
+
105
  ?>
106
 
107
+ <?php echo $this->getStoreSwitcherHtml() ?>
108
 
109
+ <form name="codiform" action="<?php echo $this->getUrl('codipdf/adminhtml_menu/authsave') ?>" method="post" id="codiform">
110
  <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
111
  <input name="store" type="hidden" value="<?php echo $this->getRequest()->getParam('store'); ?>" />
112
  <div class="entry-edit">
127
  <td class="value"><input name="userid" onchange="makeLowercase();" id="userid" value="<?php echo $userid ?>" class=" input-text" type="text"/></td>
128
  <td><small>&nbsp;</small></td>
129
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  <tr><td class="scope-label"></td><td class="label"></td><td class="value"></td><td><small>&nbsp;</small></td></tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
 
 
 
 
 
 
132
  <tr>
133
  <td class="scope-label"><a href="#enablefreshflyers_tooltip"><img src="<?php echo $this->getSkinUrl($this->__('images/preview_field_help.png')) ?>" align="absmiddle" /></a></td>
134
  <td class="label"><label for="enablefreshflyers">Enable Always Fresh™ Flyers</label></td>
135
  <td class="value"><input name="enablefreshflyers" id="enablefreshflyers" value="checked" <?php if ($enablefreshflyers =="checked") echo "checked" ?> class=" input-checkbox" type="checkbox"/></td>
136
  <td><small>&nbsp;</small></td>
137
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  </table>
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  <table class="form-list">
142
  <tr><td class="scope-label"></td><td class="label"></td><td class="value"></td><td><small>&nbsp;</small></td></tr>
143
  <tr>
296
 
297
  <script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/jquery-1.2.6.noConflict.min.js') ?>"></script>
298
  <script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/jquery.tooltip.js') ?>"></script>
299
+
300
  <script type="text/javascript">
301
  jQuery("#content a").tooltip({
302
  bodyHandler: function() {
513
  }
514
 
515
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
 
517
  function makeLowercase() {
518
  document.getElementById('userid').value = document.getElementById('userid').value.toLowerCase();
app/design/frontend/default/default/template/catalog/product/view.phtml CHANGED
@@ -37,18 +37,18 @@
37
  <?php
38
  //Catalog-on-Demand
39
 
40
- if ( Mage::getStoreConfig('codi/codi/codflyerlinkimg') =='Custom')
41
- $codflyerlinkimgurl = Mage::getStoreConfig('codi/codi/codflyerlinkimgurl');
42
  else
43
  $codflyerlinkimgurl = 'http://www.catalog-on-demand.com/print-catalog.png';
44
 
45
- $enablefreshflyers = Mage::getStoreConfig('codi/codi/enablefreshflyers');
46
 
47
  /*$flyerlink = '<a target="_blank" href="http://catalog-on-demand.com/PDF-e-Link/?FlyerA&AID=' . Mage::getStoreConfig('codi/codi/codusername'). '|' . urlencode($_product->getId() . '#$#' . $_product->getName()) . '">'. '<img id="codflyerlinkimgalt" title="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" alt="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" src="' . $codflyerlinkimgurl . '">'. '</a>';*/
48
 
49
  //Change on 5-Dec-2011
50
 
51
- $flyerlink = '<a target="_blank" href="http://www.catalog-on-demand.com/PDF-e-Link/?AID=' . Mage::getStoreConfig('codi/codi/codusername'). '|' . urlencode($_product->getId()) . '">'. '<img id="codflyerlinkimgalt" title="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" alt="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" src="' . $codflyerlinkimgurl . '">'. '</a>';
52
 
53
  //Catalog-on-Demand
54
  ?>
@@ -70,9 +70,9 @@ $flyerlink = '<a target="_blank" href="http://www.catalog-on-demand.com/PDF-e-Li
70
  <div class="product-name">
71
  <h1>
72
  <!--Catalog-on-Demand-->
73
- <?php if(Mage::getStoreConfig('codi/codi/codbeforename')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
74
  <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>
75
- <?php if(Mage::getStoreConfig('codi/codi/codaftername')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
76
  <!--Catalog-on-Demand-->
77
  </h1>
78
  </div>
@@ -80,9 +80,9 @@ $flyerlink = '<a target="_blank" href="http://www.catalog-on-demand.com/PDF-e-Li
80
  <?php if ($this->canEmailToFriend()): ?>
81
  <p class="email-friend">
82
  <!--Catalog-on-Demand-->
83
- <?php if(Mage::getStoreConfig('codi/codi/codbeforeemailto')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
84
  <a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a>
85
- <?php if(Mage::getStoreConfig('codi/codi/codafteremailto')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
86
  <!--Catalog-on-Demand-->
87
  </p>
88
  <?php endif; ?>
@@ -100,9 +100,9 @@ $flyerlink = '<a target="_blank" href="http://www.catalog-on-demand.com/PDF-e-Li
100
  <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
101
  <span class="or">
102
  <!--Catalog-on-Demand-->
103
- <?php if(Mage::getStoreConfig('codi/codi/codbeforeOR')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
104
  <?php echo $this->__('OR') ?>
105
- <?php if(Mage::getStoreConfig('codi/codi/codafterOR')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
106
  <!--Catalog-on-Demand-->
107
  </span>
108
  <?php endif; ?>
@@ -116,9 +116,9 @@ $flyerlink = '<a target="_blank" href="http://www.catalog-on-demand.com/PDF-e-Li
116
  <div class="short-description">
117
  <h2>
118
  <!--Catalog-on-Demand-->
119
- <?php if(Mage::getStoreConfig('codi/codi/codbeforeoverview')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
120
  <?php echo $this->__('Quick Overview') ?>
121
- <?php if(Mage::getStoreConfig('codi/codi/codafteroverview')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
122
  <!--Catalog-on-Demand-->
123
  </h2>
124
  <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
37
  <?php
38
  //Catalog-on-Demand
39
 
40
+ if ( Mage::getStoreConfig('codipdf/codipdf/codflyerlinkimg') =='Custom')
41
+ $codflyerlinkimgurl = Mage::getStoreConfig('codipdf/codipdf/codflyerlinkimgurl');
42
  else
43
  $codflyerlinkimgurl = 'http://www.catalog-on-demand.com/print-catalog.png';
44
 
45
+ $enablefreshflyers = Mage::getStoreConfig('codipdf/codipdf/enablefreshflyers');
46
 
47
  /*$flyerlink = '<a target="_blank" href="http://catalog-on-demand.com/PDF-e-Link/?FlyerA&AID=' . Mage::getStoreConfig('codi/codi/codusername'). '|' . urlencode($_product->getId() . '#$#' . $_product->getName()) . '">'. '<img id="codflyerlinkimgalt" title="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" alt="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" src="' . $codflyerlinkimgurl . '">'. '</a>';*/
48
 
49
  //Change on 5-Dec-2011
50
 
51
+ $flyerlink = '<a target="_blank" href="http://catalog-on-demand.com/PDF-e-Link/?AID=' . Mage::getStoreConfig('codipdf/codipdf/codusername'). '|' . urlencode($_product->getId()) . '">'. '<img id="codflyerlinkimgalt" title="' . Mage::getStoreConfig('codipdf/codipdf/codflyerlinkimgalt') . '" alt="' . Mage::getStoreConfig('codipdf/codipdf/codflyerlinkimgalt') . '" src="' . $codflyerlinkimgurl . '">'. '</a>';
52
 
53
  //Catalog-on-Demand
54
  ?>
70
  <div class="product-name">
71
  <h1>
72
  <!--Catalog-on-Demand-->
73
+ <?php if(Mage::getStoreConfig('codipdf/codipdf/codbeforename')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
74
  <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>
75
+ <?php if(Mage::getStoreConfig('codipdf/codipdf/codaftername')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
76
  <!--Catalog-on-Demand-->
77
  </h1>
78
  </div>
80
  <?php if ($this->canEmailToFriend()): ?>
81
  <p class="email-friend">
82
  <!--Catalog-on-Demand-->
83
+ <?php if(Mage::getStoreConfig('codipdf/codipdf/codbeforeemailto')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
84
  <a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a>
85
+ <?php if(Mage::getStoreConfig('codipdf/codipdf/codafteremailto')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
86
  <!--Catalog-on-Demand-->
87
  </p>
88
  <?php endif; ?>
100
  <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
101
  <span class="or">
102
  <!--Catalog-on-Demand-->
103
+ <?php if(Mage::getStoreConfig('codipdf/codipdf/codbeforeOR')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
104
  <?php echo $this->__('OR') ?>
105
+ <?php if(Mage::getStoreConfig('codipdf/codipdf/codafterOR')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
106
  <!--Catalog-on-Demand-->
107
  </span>
108
  <?php endif; ?>
116
  <div class="short-description">
117
  <h2>
118
  <!--Catalog-on-Demand-->
119
+ <?php if(Mage::getStoreConfig('codipdf/codipdf/codbeforeoverview')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
120
  <?php echo $this->__('Quick Overview') ?>
121
+ <?php if(Mage::getStoreConfig('codipdf/codipdf/codafteroverview')=="checked" && $enablefreshflyers) echo $flyerlink; ?>
122
  <!--Catalog-on-Demand-->
123
  </h2>
124
  <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
app/etc/modules/{Mage_Codi.xml → Mage_CodiPDF.xml} RENAMED
@@ -1,9 +1,9 @@
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
- <Mage_Codi>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- </Mage_Codi>
8
  </modules>
9
  </config>
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
+ <Mage_CodiPDF>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ </Mage_CodiPDF>
8
  </modules>
9
  </config>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_PDF_per_Product</name>
4
- <version>3.0.9</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Catalog-On-Demand</summary>
10
- <description>Catalog-On-Demand</description>
11
- <notes>3.0.9- Allow apostrophe and other special characters in category name</notes>
12
  <authors><author><name>catalogondemand</name><user>auto-converted</user><email>timh@catalog-on-demand.com</email></author></authors>
13
- <date>2012-04-24</date>
14
- <time>11:32:16</time>
15
- <contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="codimport_run.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/><file name="codimport_yes.gif" hash="0afb20898a704a106cb4c598868abf32"/><file name="preview_field_help.png" hash="1b1601459d25e8b1a6b1d109782078d2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="codi"><file name="index.phtml" hash="df25f104d32ba9e1441ded87dd0516f8"/></dir></dir><dir name="layout"><file name="codi.xml" hash="9407985f30403744eb4e758312d62aef"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="ed36b7697b537fb4ff4100530450a832"/></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="jquery"><file name="jquery-1.2.6.noConflict.min.js" hash="090fdb3fbcb4727c0ca20cca87e7e12d"/><file name="jquery.tooltip.js" hash="8217c6611da6cfe45094e58485d013f0"/></dir></dir></target><target name="magecommunity"><dir name="Mage"><dir name="Codi"><dir name="Block"><dir name="Adminhtml"><file name="Menu.php" hash="ae8a9d1be49f00102911ef5fbe97c126"/><file name="Switcher.php" hash="62f36d23f039d7c21ec84b42fd0532ff"/></dir><dir name="Customer"><file name="Codi.php" hash="17c557dbcfadd336dc7ba773d6304fc0"/></dir></dir><dir name="Helper"><file name="Createzip.php" hash="03fe07641f6f3f480b1d1c47b5ab3901"/><file name="Data.php" hash="20fb4b3deed697fd80f61f6b5c36e416"/></dir><dir name="Model"><file name="Codi.php" hash="b205f5d6906b7c96190c7aaa26f239c9"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MenuController.php" hash="0db56a3c8d2bdd2564c8231b1efa8860"/></dir><file name="DeleteController.php" hash="8030915b46c87e5369a7c34d979873b4"/><file name="NsyncController.php" hash="d4bb9b709c9c907731d2f4e609205934"/><file name="SyncController.php" hash="ce7dfa71ab6214fbb825578ea81f55d2"/></dir><dir name="etc"><file name="config.xml" hash="72185be863584c38ffc1bc226afe89b9"/></dir><dir name="sql"><dir name="codi_setup"><file name="mysql4-install-3.0.4.php" hash="ffa1c82119aa4a56a6123dd1c5feca8f"/><file name="mysql4-install-3.0.6.php" hash="ffa1c82119aa4a56a6123dd1c5feca8f"/></dir></dir><file name="Codi_Process.php" hash="07b09ec755a1ae56c3a9f3945aa72035"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_Codi.xml" hash="5d635cd2a0d415b67f095bda0298445d"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_PDF_per_Product</name>
4
+ <version>4.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Catalog-on-Demand PDF for Every Product</summary>
10
+ <description>This extension is meant to be used in conjunction with the Print Catalog Software as a Service (SaaS) extension at http://www.magentocommerce.com/magento-connect/print-catalog-software-as-a-service-saas.html</description>
11
+ <notes>This extension puts a PDF icon on every product page. The PDF icon links to a Catalog-on-Demand Always Fresh flyer. This is meant to be used in conjunction with Print Catalog Software as a Service (SaaS) extension at http://www.magentocommerce.com/magento-connect/print-catalog-software-as-a-service-saas.html</notes>
12
  <authors><author><name>catalogondemand</name><user>auto-converted</user><email>timh@catalog-on-demand.com</email></author></authors>
13
+ <date>2012-11-28</date>
14
+ <time>04:19:21</time>
15
+ <contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="preview_field_help.png" hash="1b1601459d25e8b1a6b1d109782078d2"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="jquery"><file name="jquery-1.2.6.noConflict.min.js" hash="090fdb3fbcb4727c0ca20cca87e7e12d"/><file name="jquery.tooltip.js" hash="8217c6611da6cfe45094e58485d013f0"/></dir></dir></target><target name="magecommunity"><dir name="Mage"><dir name="CodiPDF"><dir name="Block"><dir name="Adminhtml"><file name="Menu.php" hash="13b955237d92a743adae092e3a6d1d79"/></dir></dir><dir name="Model"><file name="Codipdf.php" hash="ff7369a835304a020d94a9df46312315"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MenuController.php" hash="a00d99d9e70e97d1cbf026814f494ea0"/></dir></dir><dir name="etc"><file name="config.xml" hash="ce05ed330c4ddd4af4be268329842e7f"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="964daafcdf1f20fe42076131c13e507d"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="codipdf.xml" hash="bb8f12fceb9abba8f6d70f2c55a03ce9"/></dir><dir name="template"><dir name="codipdf"><file name="index.phtml" hash="2b0d045d57097f4028a568a59b9bcff9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_CodiPDF.xml" hash="4f7e7034579fc9b3bf568208c32cccf3"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
skin/adminhtml/default/default/images/codimport_run.gif DELETED
Binary file
skin/adminhtml/default/default/images/codimport_yes.gif DELETED
Binary file