Mercent_Priceoptimizer - Version 1.0.0

Version Notes

Mercent Retail Price Optimizer

Download this release

Release Info

Developer Mercent Corporation
Extension Mercent_Priceoptimizer
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Mercent/Export/Model/Export.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /****************************************************
3
+ Copyright (c) Mercent Corporation. All rights reserved.
4
+ THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
5
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
6
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
7
+ PARTICULAR PURPOSE.
8
+ @author Tara Goshi and Kathy Farah
9
+ Date: 2012-04-10
10
+ Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
11
+ SCOPE OF LICENSE
12
+ The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
13
+ You may not
14
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
15
+ * publish the software for others to copy;
16
+ * rent, lease or lend the software;
17
+ * transfer the software or this agreement to any third party; or
18
+ * use the software for commercial software hosting services.
19
+
20
+ Attribution Notice: Mercent_Export_Model_Export
21
+ extends the Mage_ImportExport_Model_Export
22
+ developed by Magento
23
+ Specifically Mercent has added the following function: mercentRepricingExport
24
+ *********************************************************/
25
+
26
+ /**
27
+ * Export
28
+ *
29
+ * @category Mercent
30
+ * @package Mercent_Export
31
+ * @author Tara Goshi and Kathy Farah email questions to: support@mercent.com
32
+ */
33
+ class Mercent_Export_Model_Export extends Mage_ImportExport_Model_Export
34
+ {
35
+ // This function calls the export that generates the price optimizer feed from the products for a given store
36
+ // Parameters:
37
+ // storeId => This is the id for the store for which we are generating the price optimizer feed
38
+ public function mercentRepricingExport($storeId)
39
+ {
40
+ if (isset($this->_data[self::FILTER_ELEMENT_GROUP])) {
41
+ $this->addLogComment(Mage::helper('importexport')->__('Begin export of %s', $this->getEntity()));
42
+ $result = $this->_getEntityAdapter()
43
+ ->setWriter($this->_getWriter())
44
+ ->mercentRepricingExport($storeId);
45
+ $countRows = substr_count(trim($result), "\n");
46
+ if (!$countRows) {
47
+ Mage::throwException(
48
+ Mage::helper('importexport')->__('There is no data for export')
49
+ );
50
+ }
51
+ if ($result) {
52
+ $this->addLogComment(array(
53
+ Mage::helper('importexport')->__('Exported %s rows.', $countRows),
54
+ Mage::helper('importexport')->__('Export has been done.')
55
+ ));
56
+ }
57
+ return $result;
58
+ } else {
59
+ Mage::throwException(
60
+ Mage::helper('importexport')->__('No filter data provided')
61
+ );
62
+ }
63
+ }
64
+ }
app/code/community/Mercent/Export/Model/Export/Adapter/Tab.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /****************************************************
3
+ Copyright (c) Mercent Corporation. All rights reserved.
4
+ THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
5
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
6
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
7
+ PARTICULAR PURPOSE.
8
+ @author Tara Goshi and Kathy Farah
9
+ Date: 2012-04-10
10
+ Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
11
+ SCOPE OF LICENSE
12
+ The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
13
+ You may not
14
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
15
+ * publish the software for others to copy;
16
+ * rent, lease or lend the software;
17
+ * transfer the software or this agreement to any third party; or
18
+ * use the software for commercial software hosting services.
19
+
20
+ Attribution Notice: Mercent_Export_Model_Export_Adapter_Tab
21
+ is an original concrete instance of the Mage_ImportExport_Model_Export_Adapter_Abstract
22
+ abstract class developed by Magento
23
+ *********************************************************/
24
+
25
+ /**
26
+ * Export adapter tab (txt).
27
+ *
28
+ * @category Mercent
29
+ * @package Mercent_Export
30
+ * @author Tara Goshi and Kathy Farah email questions to: support@mercent.com
31
+ */
32
+ class Mercent_Export_Model_Export_Adapter_Tab extends Mage_ImportExport_Model_Export_Adapter_Abstract
33
+ {
34
+ /**
35
+ * Field delimiter.
36
+ *
37
+ * @var string
38
+ */
39
+ protected $_delimiter = "\t";
40
+
41
+ /**
42
+ * Field enclosure character.
43
+ *
44
+ * @var string
45
+ */
46
+ protected $_enclosure = '"';
47
+
48
+ /**
49
+ * Source file handler.
50
+ *
51
+ * @var resource
52
+ */
53
+ protected $_fileHandler;
54
+
55
+ /**
56
+ * Object destructor.
57
+ *
58
+ * @return void
59
+ */
60
+ public function __destruct()
61
+ {
62
+ if (is_resource($this->_fileHandler)) {
63
+ fclose($this->_fileHandler);
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Optional
69
+ * used as a lookup table between internal and external field names
70
+ */
71
+ protected $_columnLookup=null;
72
+ /**
73
+ * Method called as last step of object instance creation. Can be overrided in child classes.
74
+ *
75
+ * @return Mage_ImportExport_Model_Export_Adapter_Abstract
76
+ */
77
+ protected function _init()
78
+ {
79
+ $this->_fileHandler = fopen($this->_destination, 'w');
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * MIME-type for 'Content-Type' header.
85
+ *
86
+ * @return string
87
+ */
88
+ public function getContentType()
89
+ {
90
+ return 'text/csv';
91
+ }
92
+
93
+ /**
94
+ * Return file extension for downloading.
95
+ *
96
+ * @return string
97
+ */
98
+ public function getFileExtension()
99
+ {
100
+ return 'txt';
101
+ }
102
+
103
+ /**
104
+ * Set column names.
105
+ *
106
+ * @param array $colNames -- hash used to specify a look-up table for internal field name to output column header name
107
+ * -- key->field name, value->output name
108
+ * @throws Exception
109
+ * @return Mage_ImportExport_Model_Export_Adapter_Abstract
110
+ */
111
+ public function setHeaderColsWithLookup(array $colNames)
112
+ {
113
+ if (null !== $this->_headerCols) {
114
+ Mage::throwException(Mage::helper('importexport')->__('Header column names already set'));
115
+ }
116
+ if (null === $colNames) {
117
+ Mage::throwException(Mage::helper('importexport')->__('No data to use to set header columns'));
118
+ }
119
+
120
+ $this->_columnLookup = array();
121
+ foreach (array_keys($colNames) as $colName) {
122
+ $this->_columnLookup[$colName] = $colNames[$colName];
123
+ $this->_headerCols[$colName] = false;
124
+ }
125
+ fputcsv($this->_fileHandler, $this->_columnLookup, $this->_delimiter, $this->_enclosure);
126
+
127
+ return $this;
128
+ }
129
+ /**
130
+ * Write row data to source file.
131
+ *
132
+ * @param array $rowData
133
+ * @throws Exception
134
+ * @return Mage_ImportExport_Model_Export_Adapter_Abstract
135
+ */
136
+ public function writeRow(array $rowData)
137
+ {
138
+ if (null === $this->_headerCols) {
139
+ $this->setHeaderCols(array_keys($rowData));
140
+ }
141
+
142
+ if($this->_columnLookup !== null)
143
+ {
144
+ $dataLookup = array();
145
+ foreach(array_keys($this->_columnLookup) as $colName)
146
+ {
147
+ if(array_key_exists($colName,$rowData))
148
+ {
149
+ $dataLookup[$colName] = $rowData[$colName];
150
+ }else{
151
+ $dataLookup[$colName] = null;
152
+ }
153
+ }
154
+ fputcsv(
155
+ $this->_fileHandler,
156
+ $dataLookup,
157
+ $this->_delimiter,
158
+ $this->_enclosure
159
+ );
160
+ }else{
161
+ fputcsv(
162
+ $this->_fileHandler,
163
+ array_merge($this->_headerCols, array_intersect_key($rowData, $this->_headerCols)),
164
+ $this->_delimiter,
165
+ $this->_enclosure
166
+ );
167
+ }
168
+ return $this;
169
+ }
170
+ }
app/code/community/Mercent/Export/Model/Export/Entity/Product.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /****************************************************
3
+ Copyright (c) Mercent Corporation. All rights reserved.
4
+ THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
5
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
6
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
7
+ PARTICULAR PURPOSE.
8
+ @author Tara Goshi and Kathy Farah
9
+ Date: 2012-04-10
10
+ Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
11
+ SCOPE OF LICENSE
12
+ The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
13
+ You may not
14
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
15
+ * publish the software for others to copy;
16
+ * rent, lease or lend the software;
17
+ * transfer the software or this agreement to any third party; or
18
+ * use the software for commercial software hosting services.
19
+
20
+ Attribution Notice: Mercent_Export_Model_Export_Entity_Product
21
+ extends the Mage_ImportExport_Model_Export_Entity_Product
22
+ developed by Magento
23
+ Specifically Mercent has added the following function: mercentRepricingExport
24
+ *********************************************************/
25
+
26
+ /**
27
+ * Export Product
28
+ *
29
+ * @category Mercent
30
+ * @package Mercent_Export
31
+ * @author Tara Goshi and Kathy Farah email questions to: support@mercent.com
32
+ */
33
+ class Mercent_Export_Model_Export_Entity_Product extends Mage_ImportExport_Model_Export_Entity_Product
34
+ {
35
+ // This function generates the price optimizer feed for a given store's products
36
+ // Parameters:
37
+ // $storeId => the id for the store we are generating the feed for
38
+ public function mercentRepricingExport($storeId)
39
+ {
40
+ // field look up table for the price optimizer feed
41
+ $attributeParams = array('sku' => 'SKU', 'brand' => 'Brand','manufacturer' => 'Manufacturer',
42
+ 'name' => 'Title','msrp' => 'MSRP',
43
+ 'price' => 'StandardPrice','cost' => 'COGS',
44
+ 'map' => 'MAP','merchant_category' => 'MerchantCategory',
45
+ 'qty'=>'Quantity','is_in_stock' => 'InStock', 'amazon_sku' => 'AmazonSKU');
46
+ //Execution time may be very long
47
+ set_time_limit(0);
48
+
49
+ /** @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */
50
+ $validAttrCodes = $this->_getExportAttrCodes();
51
+ $writer = $this->getWriter();
52
+
53
+ // limit valid attributes to the ones used for the repricing feed
54
+ // looping through to preserver order
55
+ $temp = array();
56
+ $i=0;
57
+ foreach ($validAttrCodes as &$attrCode)
58
+ {
59
+ if(array_key_exists($attrCode,$attributeParams))
60
+ {
61
+ $temp[$i]=$attrCode;
62
+ $i++;
63
+ }
64
+ }
65
+ $validAttrCodes = $temp;
66
+
67
+ $memoryLimit = trim(ini_get('memory_limit'));
68
+ $lastMemoryLimitLetter = strtolower($memoryLimit[strlen($memoryLimit)-1]);
69
+ switch($lastMemoryLimitLetter) {
70
+ case 'g':
71
+ $memoryLimit *= 1024;
72
+ case 'm':
73
+ $memoryLimit *= 1024;
74
+ case 'k':
75
+ $memoryLimit *= 1024;
76
+ break;
77
+ default:
78
+ // minimum memory required by Magento
79
+ $memoryLimit = 250000000;
80
+ }
81
+
82
+ // Tested one product to have up to such size
83
+ $memoryPerProduct = 100000;
84
+ // Decrease memory limit to have supply
85
+ $memoryUsagePercent = 0.8;
86
+ // Minimum Products limit
87
+ $minProductsLimit = 500;
88
+
89
+ $limitProducts = intval(($memoryLimit * $memoryUsagePercent - memory_get_usage(true)) / $memoryPerProduct);
90
+ if ($limitProducts < $minProductsLimit) {
91
+ $limitProducts = $minProductsLimit;
92
+ }
93
+ $offsetProducts = 0;
94
+ $col_category = 'merchant_category';
95
+ $col_type = 'product_type';
96
+
97
+ while (true)
98
+ {
99
+ ++$offsetProducts;
100
+
101
+ $dataRows = array();
102
+ $rowCategories = array();
103
+
104
+ $collection = $this->_prepareEntityCollection(Mage::getResourceModel('catalog/product_collection'))->addStoreFilter($storeId);
105
+ $collection
106
+ ->setStoreId($storeId)
107
+ ->setPage($offsetProducts, $limitProducts);
108
+ if ($collection->getCurPage() < $offsetProducts) {
109
+ break;
110
+ }
111
+ $collection->load();
112
+
113
+ if ($collection->count() == 0) {
114
+ break;
115
+ }
116
+
117
+ $collection->addCategoryIds()->addWebsiteNamesToResult();
118
+
119
+ foreach ($collection as $itemId => $item) { // go through all products
120
+ $rowIsEmpty = true; // row is empty by default
121
+
122
+ foreach ($validAttrCodes as &$attrCode) { // go through all valid attribute codes
123
+ $attrValue = $item->getData($attrCode);
124
+
125
+ if (!empty($this->_attributeValues[$attrCode])) {
126
+ if (isset($this->_attributeValues[$attrCode][$attrValue])) {
127
+ $attrValue = $this->_attributeValues[$attrCode][$attrValue];
128
+ } else {
129
+ $attrValue = null;
130
+ }
131
+ }
132
+ if (is_scalar($attrValue)) {
133
+ $dataRows[$itemId][$storeId][$attrCode] = $attrValue;
134
+ $rowIsEmpty = false; // mark row as not empty
135
+ }
136
+ }
137
+ if ($rowIsEmpty) { // remove empty rows
138
+ unset($dataRows[$itemId][$storeId]);
139
+ } else {
140
+ $dataRows[$itemId][$storeId][$col_type] = $item->getTypeId();
141
+ $rowCategories[$itemId] = $item->getCategoryIds();
142
+ }
143
+ $item = null;
144
+ }
145
+ $collection->clear();
146
+
147
+ if ($collection->getCurPage() < $offsetProducts) {
148
+ break;
149
+ }
150
+
151
+ // remove root categories
152
+ foreach ($rowCategories as $productId => &$categories) {
153
+ $categories = array_intersect($categories, array_keys($this->_categories));
154
+ }
155
+ // prepare catalog inventory information
156
+ $productIds = array_keys($dataRows);
157
+ $stockItemRows = $this->_prepareCatalogInventory($productIds);
158
+
159
+ if ($offsetProducts == 1) {
160
+ // set up column headers
161
+ $writer->setHeaderColsWithLookup($attributeParams);
162
+ }
163
+ //write out data
164
+ foreach ($dataRows as $productId => &$productData) {
165
+ foreach ($productData as $storeId => &$dataRow) {
166
+ //add inventory
167
+ $dataRow += $stockItemRows[$productId];
168
+ // select the longest category to send
169
+ if ($rowCategories[$productId]) {
170
+ $catCount=count($rowCategories[$productId]);
171
+ $longestCatLength=0;
172
+ $longestCat = "";
173
+ for ($i = 0; $i < $catCount; $i++)
174
+ {
175
+ $currCat=$this->_categories[$rowCategories[$productId][$i]];
176
+ if(strlen($currCat) > $longestCatLength)
177
+ {
178
+ $longestCat=$currCat;
179
+ $longestCatLength=strlen($currCat);
180
+ }
181
+ }
182
+ $dataRow[$col_category]=$longestCat;
183
+ }
184
+ $writer->writeRow($dataRow);
185
+ }
186
+ }
187
+ }
188
+ return $writer->getContents();
189
+ }
190
+ }
app/code/community/Mercent/Export/etc/config.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ ****************************************************
4
+ Copyright (c) Mercent Corporation. All rights reserved.
5
+ THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
6
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
7
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
8
+ PARTICULAR PURPOSE.
9
+ @author Tara Goshi and Kathy Farah
10
+ Date: 2012-04-10
11
+ Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
12
+ SCOPE OF LICENSE
13
+ The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
14
+ You may not
15
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
16
+ * publish the software for others to copy;
17
+ * rent, lease or lend the software;
18
+ * transfer the software or this agreement to any third party; or
19
+ * use the software for commercial software hosting services.
20
+
21
+ *********************************************************
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <Mercent_Export>
26
+ <version>1.0.0</version>
27
+ </Mercent_Export>
28
+ </modules>
29
+ <global>
30
+ <models>
31
+ <export>
32
+ <class>Mercent_Export_Model</class>
33
+ </export>
34
+ <importexport>
35
+ <rewrite>
36
+ <export_entity_product>Mercent_Export_Model_Export_Entity_Product</export_entity_product>
37
+ <export>Mercent_Export_Model_Export</export>
38
+ </rewrite>
39
+ </importexport>
40
+ </models>
41
+ <importexport module="importexport">
42
+ <export_file_formats>
43
+ <mtab translate="label">
44
+ <model_token>export/export_adapter_tab</model_token>
45
+ <label>Tab</label>
46
+ </mtab>
47
+ </export_file_formats>
48
+ </importexport>
49
+ </global>
50
+ </config>
app/code/community/Mercent/Repricing/Helper/Data.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /****************************************************
4
+ Copyright (c) Mercent Corporation. All rights reserved.
5
+ THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
6
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
7
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
8
+ PARTICULAR PURPOSE.
9
+ @author Tara Goshi and Kathy Farah
10
+ Date: 2012-04-10
11
+ Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
12
+ SCOPE OF LICENSE
13
+ The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
14
+ You may not
15
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
16
+ * publish the software for others to copy;
17
+ * rent, lease or lend the software;
18
+ * transfer the software or this agreement to any third party; or
19
+ * use the software for commercial software hosting services.
20
+
21
+ *********************************************************/
22
+
23
+ /**
24
+ * Helper_Data
25
+ * This placeholder revents errors when calling helper modules
26
+ * @category Mercent
27
+ * @package Mercent_Repricing
28
+ * @author Tara Goshi and Kathy Farah email questions to: support@mercent.com
29
+ */
30
+ class Mercent_Repricing_Helper_Data extends Mage_Core_Helper_Abstract
31
+ {
32
+
33
+ }
app/code/community/Mercent/Repricing/Model/Feedfrequency.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /****************************************************
3
+ Copyright (c) Mercent Corporation. All rights reserved.
4
+ THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
5
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
6
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
7
+ PARTICULAR PURPOSE.
8
+ @author Tara Goshi and Kathy Farah
9
+ Date: 2012-04-10
10
+ Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
11
+ SCOPE OF LICENSE
12
+ The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
13
+ You may not
14
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
15
+ * publish the software for others to copy;
16
+ * rent, lease or lend the software;
17
+ * transfer the software or this agreement to any third party; or
18
+ * use the software for commercial software hosting services.
19
+
20
+ *********************************************************/
21
+
22
+ /**
23
+ * FeedFrequency
24
+ *
25
+ * @category Mercent
26
+ * @package Mercent_Repricing
27
+ * @author Tara Goshi and Kathy Farah email questions to: support@mercent.com
28
+ */
29
+ class Mercent_Repricing_Model_FeedFrequency
30
+ {
31
+ // This function sets up the options for the cron job that is running the price optimizer feed
32
+ public function toOptionArray()
33
+ {
34
+ return array(
35
+ array('value'=>24, 'label'=>Mage::helper('repricing')->__('Daily')),
36
+ array('value'=>4, 'label'=>Mage::helper('repricing')->__('4 Hours')),
37
+ array('value'=>6, 'label'=>Mage::helper('repricing')->__('6 Hours')),
38
+ array('value'=>12, 'label'=>Mage::helper('repricing')->__('12 Hours')),
39
+ );
40
+ }
41
+ }
app/code/community/Mercent/Repricing/Model/Observer.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /****************************************************
3
+ Copyright (c) Mercent Corporation. All rights reserved.
4
+ THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
5
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
6
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
7
+ PARTICULAR PURPOSE.
8
+ @author Tara Goshi and Kathy Farah
9
+ Date: 2012-04-10
10
+ Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
11
+ SCOPE OF LICENSE
12
+ The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
13
+ You may not
14
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
15
+ * publish the software for others to copy;
16
+ * rent, lease or lend the software;
17
+ * transfer the software or this agreement to any third party; or
18
+ * use the software for commercial software hosting services.
19
+ *********************************************************/
20
+ /**
21
+ * Observer
22
+ *
23
+ * @category Mercent
24
+ * @package Mercent_Export
25
+ * @author Tara Goshi and Kathy Farah email questions to: support@mercent.com
26
+ */
27
+ class Mercent_Repricing_Model_Observer
28
+ {
29
+ // This function runs the price optimizer feed and ftp's it to Mercent, it sets up th environment and then calls the other functions necessary to generate and
30
+ // ftp the feed
31
+ public static function runRepricingFeed()
32
+ {
33
+ $hasAnyFeedRun = 0;
34
+ //Feed name and folder options
35
+ $fileName = 'MercentRepricingFeed.txt';
36
+ $fileDir = sprintf('%s/mercent_repricing', Mage::getBaseDir('media'));
37
+ $file = sprintf('%s/%s', $fileDir, $fileName);
38
+ $logFile = preg_replace('"\.txt$"', '_log.txt', $file);
39
+
40
+ //Create output directory if not exists
41
+ if(!file_exists($fileDir))
42
+ {
43
+ mkdir($fileDir);
44
+ chmod($fileDir, 0777);
45
+ }
46
+
47
+ //Retrieve default mercent repricing settings
48
+ //where Current Configuration Scope is Default Config
49
+ //no storeId passed to getStoreConfig function
50
+ $active = Mage::getStoreConfig('repricingconfig/repricing_group/repricing_active');
51
+ $merchantId = trim(Mage::getStoreConfig('repricingconfig/repricing_group/repricing_account'));
52
+ $host = trim(Mage::getStoreConfig('repricingconfig/repricing_group/repricing_ftpserver'));
53
+ $folder = trim(Mage::getStoreConfig('repricingconfig/repricing_group/repricing_ftpfolder'));
54
+ //Include MerchantID in folder path
55
+ $folder = str_replace('{{merchant_id}}', $merchantId, $folder);
56
+ //Include '/' at the end of folder name if not already included
57
+ $folder = ($folder[strlen($folder)-1] == '/') ? $folder : $folder.'/';
58
+ $password = trim(Mage::getStoreConfig('repricingconfig/repricing_group/repricing_ftppassword'));
59
+ $port = 21;
60
+
61
+ file_put_contents($logFile, date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()))." Repricing Feed Starting\n");//, FILE_APPEND);
62
+
63
+ if ($active && !empty($merchantId) && !empty($host) && !empty($password))
64
+ {
65
+ $hasAnyFeedRun = 1;
66
+ file_put_contents($logFile, date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()))." Run repricing feed for default (no store id specified)\n", FILE_APPEND);
67
+ self::getAndFtpFeed($host, $port, $merchantId, $password, $folder, $file, $fileName, Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID, $logFile);
68
+ }
69
+
70
+ //Loop through each store and run if enabled and if MerchantID is different than default config
71
+ foreach (Mage::app()->getStores() as $store)
72
+ {
73
+ $storeId = $store->getId();
74
+ $activeStore = Mage::getStoreConfig('repricingconfig/repricing_group/repricing_active', $storeId);
75
+ $merchantIdStore = trim(Mage::getStoreConfig('repricingconfig/repricing_group/repricing_account', $storeId));
76
+ $hostStore = trim(Mage::getStoreConfig('repricingconfig/repricing_group/repricing_ftpserver', $storeId));
77
+ $folderStore = trim(Mage::getStoreConfig('repricingconfig/repricing_group/repricing_ftpfolder', $storeId));
78
+ //Include MerchantID in folder path
79
+ $folderStore = str_replace('{{merchant_id}}', $merchantIdStore, $folderStore);
80
+ //Include '/' at the end of folder name if not already included
81
+ $folderStore = ($folderStore[strlen($folderStore)-1] == '/') ? $folderStore : $folderStore.'/';
82
+ $passwordStore = trim(Mage::getStoreConfig('repricingconfig/repricing_group/repricing_ftppassword', $storeId));
83
+
84
+ //If the store is active but the default is not active then run for the store
85
+ //If the store is active and the default is active, run only if merchantId is different
86
+ if ($activeStore && (!$active || $merchantId != $merchantIdStore) && !empty($merchantId) && !empty($hostStore) && !empty($passwordStore))
87
+ {
88
+ $hasAnyFeedRun = 1;
89
+ file_put_contents($logFile, date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time())).' Run repricing feed for StoreID: ' . $storeId . "\n", FILE_APPEND);
90
+ self::getAndFtpFeed($hostStore, $port, $merchantIdStore, $passwordStore, $folderStore, $file, $fileName, $storeId, $logFile);
91
+ }
92
+ }
93
+
94
+ if (!$hasAnyFeedRun)
95
+ {
96
+ file_put_contents($logFile, date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()))." Schedule Enabled but no feed enabled or ftp settings not provided\n", FILE_APPEND);
97
+ }
98
+
99
+ file_put_contents($logFile, date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()))." Repricing Feed Complete\n\n", FILE_APPEND);
100
+ }
101
+
102
+ // This is the function that calls getFeed to generate the feed and then calls ftpFeed to FTP the feed to Mercent. It also prints log messages for success and failure.
103
+ // Parameters:
104
+ // $host => Mercent Server
105
+ // $port => FTP port
106
+ // $username => FTP user name
107
+ // $passaword => FTP password
108
+ // $folder => folder on FTP server where feed will be delivered
109
+ // $file => price optimizer feed
110
+ // $storeId => the store id for the store that the feed was generated from
111
+ // $logFile => log file
112
+ private static function getAndFtpFeed($host, $port, $username, $password, $folder, $file, $fileName, $storeId, $logFile)
113
+ {
114
+ if (self::getFeed($file, $storeId) == 1)
115
+ {
116
+ file_put_contents($logFile, date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()))." File ".$file." has been generated\n", FILE_APPEND);
117
+
118
+ if (self::ftpFeed($host, $port, $username, $password, $folder, $file, $fileName))
119
+ {
120
+ file_put_contents($logFile, date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()))." FTP of ".$fileName." to ".$host." complete\n", FILE_APPEND);
121
+ }
122
+ else
123
+ {
124
+ file_put_contents($logFile, date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()))." FTP of ".$fileName." to ".$host." UNSUCCESSFUL. See system.log for details.\n", FILE_APPEND);
125
+ }
126
+ }
127
+ else
128
+ {
129
+ file_put_contents($logFile, date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()))." File ".$file." has FAILED to generate\n", FILE_APPEND);
130
+ }
131
+
132
+ if(file_exists($file))
133
+ {
134
+ unlink($file);
135
+ }
136
+ }
137
+
138
+ // This is the function that calls the export function to generate the feed for a given store with a given file name
139
+ // Parameters:
140
+ // $file => name of file to write the feed data too
141
+ // $storeID => store id for the store we are generating the feed from
142
+ //
143
+ // Note: Disabled products are excluded from the feed
144
+ private static function getFeed($file, $storeId)
145
+ {
146
+ try
147
+ {
148
+ // get model for export and set export parameters
149
+ $model = Mage::getModel('importexport/export');
150
+ $model->setEntity('catalog_product');
151
+ $exportData = array
152
+ (
153
+ 'entity' => 'catalog_product',
154
+ 'file_format' => 'mtab',
155
+ 'export_filter' => array
156
+ (
157
+ 'status' => '1'
158
+ )
159
+ );
160
+
161
+ $model->setData($exportData);
162
+
163
+ // open the file for the feed for writing and write the export data to it
164
+ if ($f = fopen($file, 'w'))
165
+ {
166
+ $result = $model->mercentRepricingExport($storeId);
167
+ fwrite($f, $result);
168
+ fclose($f);
169
+ }
170
+ else
171
+ {
172
+ throw new Exception("Could not open: ".$file." for writing.");
173
+ }
174
+
175
+ }
176
+ catch (Exception $e)
177
+ {
178
+ Mage::logException($e);
179
+ return 0;
180
+ }
181
+ return 1;
182
+ }
183
+
184
+ // This is the function that ftp's the feed to Mercent
185
+ // Parameters:
186
+ // $host => Mercent Server
187
+ // $port => FTP port
188
+ // $username => FTP user name
189
+ // $passaword => FTP password
190
+ // $folder => folder on FTP server where feed will be delivered
191
+ // $file => price optimizer feed file
192
+ // $fileName => name of the price optimizer feed file
193
+ private static function ftpFeed($host, $port, $username, $password, $folder, $file, $fileName)
194
+ {
195
+ if($connection = ftp_connect($host, $port))
196
+ {
197
+ $login = ftp_login($connection, $username, $password);
198
+ ftp_pasv($connection, true);
199
+ return ftp_put($connection, $folder.$fileName, $file, FTP_BINARY);
200
+ }
201
+ }
202
+ }
app/code/community/Mercent/Repricing/Model/System/Config/Backend/Export/Cron.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /****************************************************
3
+ Copyright (c) Mercent Corporation. All rights reserved.
4
+ THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
5
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
6
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
7
+ PARTICULAR PURPOSE.
8
+ @author Tara Goshi and Kathy Farah
9
+ Date: 2012-04-10
10
+ Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
11
+ SCOPE OF LICENSE
12
+ The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
13
+ You may not
14
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
15
+ * publish the software for others to copy;
16
+ * rent, lease or lend the software;
17
+ * transfer the software or this agreement to any third party; or
18
+ * use the software for commercial software hosting services.
19
+
20
+ Attribution Notice: Mercent_Repricing_Model_System_Config_Backend_Export_Cron
21
+ is an extension of the Mage_Core_Model_Config_Data class
22
+ developed by Magento
23
+ Specifically Mercent overrode the _afterSave function
24
+ *********************************************************/
25
+
26
+ /**
27
+ * Cron
28
+ *
29
+ * @category Mercent
30
+ * @package Mercent_Repricing
31
+ * @author Tara Goshi and Kathy Farah email questions to: support@mercent.com
32
+ */
33
+ class Mercent_Repricing_Model_System_Config_Backend_Export_Cron extends Mage_Core_Model_Config_Data
34
+ {
35
+ const CRON_STRING_PATH = 'crontab/jobs/mercent_repricing_export/schedule/cron_expr';
36
+ const CRON_MODEL_PATH = 'crontab/jobs/mercent_repricing_export/run/model';
37
+
38
+ /**
39
+ * Set Cron settings after save
40
+ *
41
+ * @return Mage_Adminhtml_Model_System_Config_Backend_Log_Cron
42
+ */
43
+ protected function _afterSave()
44
+ {
45
+ $enabled = $this->getData('groups/repricingschedule_group/fields/repricingschedule_active/value');
46
+ $time = $this->getData('groups/repricingschedule_group/fields/repricingschedule_time/value');
47
+ $hour = intval($time[0]);
48
+ $minute = intval($time[1]);
49
+ $frequency = intval($this->getData('groups/repricingschedule_group/fields/repricingschedule_frequency/value'));
50
+
51
+ if (empty($frequency))
52
+ {
53
+ $frequency = '24'; //if not set, use daily
54
+ }
55
+
56
+ $hour = $hour % $frequency; //get the base hour to run
57
+ $hoursCronExp = '';
58
+
59
+ while ($hour < 24)
60
+ {
61
+ $hoursCronExp .= ($hoursCronExp=='' ? '' : ',').$hour;
62
+ $hour += $frequency;
63
+ }
64
+
65
+ if ($enabled) {
66
+ $cronDayOfWeek = date('N');
67
+ $cronExprArray = array(
68
+ $minute, # Minute
69
+ $hoursCronExp, # Hour
70
+ '*', # Day of the Month
71
+ '*', # Month of the Year
72
+ '*', # Day of the Week
73
+ );
74
+ $cronExprString = join(' ', $cronExprArray);
75
+ }
76
+ else {
77
+ $cronExprString = '';
78
+ }
79
+
80
+ try {
81
+ Mage::getModel('core/config_data')
82
+ ->load(self::CRON_STRING_PATH, 'path')
83
+ ->setValue($cronExprString)
84
+ ->setPath(self::CRON_STRING_PATH)
85
+ ->save();
86
+
87
+ Mage::getModel('core/config_data')
88
+ ->load(self::CRON_MODEL_PATH, 'path')
89
+ ->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
90
+ ->setPath(self::CRON_MODEL_PATH)
91
+ ->save();
92
+ }
93
+ catch (Exception $e) {
94
+ Mage::throwException('Unable to save the cron expression.');
95
+ }
96
+ }
97
+ }
app/code/community/Mercent/Repricing/etc/adminhtml.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+
3
+ <!--
4
+ ****************************************************
5
+ Copyright (c) Mercent Corporation. All rights reserved.
6
+ THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
7
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
8
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
9
+ PARTICULAR PURPOSE.
10
+ @author Tara Goshi and Kathy Farah
11
+ Date: 2012-04-10
12
+ Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
13
+ SCOPE OF LICENSE
14
+ The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
15
+ You may not
16
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
17
+ * publish the software for others to copy;
18
+ * rent, lease or lend the software;
19
+ * transfer the software or this agreement to any third party; or
20
+ * use the software for commercial software hosting services.
21
+
22
+ *********************************************************
23
+ -->
24
+
25
+ <config>
26
+ <acl>
27
+ <resources>
28
+ <all>
29
+ <title>Allow Everything</title>
30
+ </all>
31
+ <admin>
32
+ <children>
33
+ <system>
34
+ <children>
35
+ <config>
36
+ <children>
37
+ <repricingconfig translate="title">
38
+ <title>Mercent Price Optimizer</title>
39
+ <sort_order>101</sort_order>
40
+ </repricingconfig>
41
+ </children>
42
+ </config>
43
+ </children>
44
+ </system>
45
+ </children>
46
+ </admin>
47
+ </resources>
48
+ </acl>
49
+ </config>
app/code/community/Mercent/Repricing/etc/config.xml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ ****************************************************
5
+ Copyright (c) Mercent Corporation. All rights reserved.
6
+ THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
7
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
8
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
9
+ PARTICULAR PURPOSE.
10
+ @author Tara Goshi and Kathy Farah
11
+ Date: 2012-04-10
12
+ Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
13
+ SCOPE OF LICENSE
14
+ The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
15
+ You may not
16
+ * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
17
+ * publish the software for others to copy;
18
+ * rent, lease or lend the software;
19
+ * transfer the software or this agreement to any third party; or
20
+ * use the software for commercial software hosting services.
21
+
22
+ *********************************************************
23
+ -->
24
+
25
+ <config>
26
+ <modules>
27
+ <Mercent_Repricing>
28
+ <version>1.0.0</version>
29
+ </Mercent_Repricing>
30
+ </modules>
31
+ <crontab>
32
+ <jobs>
33
+ <mercent_repricing_export>
34
+ <run>
35
+ <model>mercent_repricing/observer::runRepricingFeed</model>
36
+ </run>
37
+ </mercent_repricing_export>
38
+ </jobs>
39
+ </crontab>
40
+ <default>
41
+ <repricingconfig>
42
+ <repricing_group>
43
+ <repricing_ftpserver>sfeeds.mercent.com</repricing_ftpserver>
44
+ <repricing_ftpfolder>{{merchant_id}}/Feeds/</repricing_ftpfolder>
45
+ </repricing_group>
46
+ </repricingconfig>
47
+ </default>
48
+ <global>
49
+ <models>
50
+ <mercent_repricing>
51
+ <class>Mercent_Repricing_Model</class>
52
+ </mercent_repricing>
53
+ </models>
54
+ <helpers>
55
+ <repricing>
56
+ <class>Mercent_Repricing_Helper</class>
57
+ </repricing>
58
+ </helpers>
59
+ </global>
60
+ </config>
app/code/community/Mercent/Repricing/etc/system.xml ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ // Copyright (c) Mercent Corporation. All rights reserved.
5
+ // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
6
+ // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
7
+ // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
8
+ // PARTICULAR PURPOSE.
9
+ // Author: Tara Goshi and Kathy Farah
10
+ // Date: 2012-04-10
11
+ // Summary: Integrates Magento Sites with Mercent Retail Price Optimizer
12
+ // SCOPE OF LICENSE
13
+ // The software is licensed, not sold. This agreement only gives you some rights to use the software. Mercent reserves all other rights.
14
+ // You may not
15
+ // * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
16
+ // * publish the software for others to copy;
17
+ // * rent, lease or lend the software;
18
+ // * transfer the software or this agreement to any third party; or
19
+ // * use the software for commercial software hosting services.
20
+ */
21
+ -->
22
+ <config>
23
+ <tabs>
24
+ <mercent_tab translate="label">
25
+ <label>Mercent Retail</label>
26
+ <sort_order>350</sort_order>
27
+ </mercent_tab>
28
+ </tabs>
29
+ <sections>
30
+ <repricingconfig translate="label">
31
+ <label>Mercent Price Optimizer</label>
32
+ <sort_order>200</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <tab>mercent_tab</tab>
37
+ <groups>
38
+ <repricing_group translate="label">
39
+ <label>Price Optimizer FTP Settings</label>
40
+ <comment>Before you can configure the Mercent Price Optimizer extension for Magento, you need to request a &lt;a href="https://secure.mercent.com/Public/Provision/Repricing/SetupRequest.aspx" target="_blank"&gt;Mercent Price Optimizer account&lt;/a&gt;. For instructions on setting up the extension, see &lt;a href="https://secure.mercent.com/Public/Provision/Repricing/SetUp.pdf" target="_blank"&gt;SettingUp.pdf&lt;/a&gt;. For an introduction on using the Mercent Marketplace Price Optimizer tools in Mercent Retail, see &lt;a href="https://secure.mercent.com/Public/Provision/Repricing/GettingStarted.pdf" target="_blank"&gt;GettingStarted.pdf&lt;/a&gt;. Once you have your credentials, you can login to Mercent Retail at &lt;a href="https://secure.mercent.com" target="_blank"&gt;https://secure.mercent.com&lt;/a&gt;.</comment>
41
+ <sort_order>10</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <fields>
46
+ <repricing_active translate="label">
47
+ <label>Generate Feed</label>
48
+ <comment>To generate feed for a specific store, set "Current Configuration Scope"</comment>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_yesno</source_model>
51
+ <sort_order>10</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </repricing_active>
56
+ <repricing_account translate="label">
57
+ <label>Merchant ID</label>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>20</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </repricing_account>
64
+ <repricing_ftpserver translate="label">
65
+ <label>FTP Server</label>
66
+ <comment>Default is "sfeeds.mercent.com"</comment>
67
+ <frontend_type>text</frontend_type>
68
+ <sort_order>30</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ </repricing_ftpserver>
73
+ <repricing_ftpfolder translate="label">
74
+ <label>FTP Folder</label>
75
+ <comment>Default is "{{merchant_id}}/Feeds/"</comment>
76
+ <frontend_type>text</frontend_type>
77
+ <sort_order>40</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ </repricing_ftpfolder>
82
+ <repricing_ftppassword translate="label">
83
+ <label>FTP Password</label>
84
+ <frontend_type>password</frontend_type>
85
+ <sort_order>50</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ </repricing_ftppassword>
90
+ </fields>
91
+ </repricing_group>
92
+ <repricingschedule_group translate="label">
93
+ <label>Price Optimizer Schedule</label>
94
+ <frontend_type>text</frontend_type>
95
+ <sort_order>20</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>0</show_in_website>
98
+ <show_in_store>0</show_in_store>
99
+ <fields>
100
+ <repricingschedule_active translate="label">
101
+ <label>Enable Automation</label>
102
+ <frontend_type>select</frontend_type>
103
+ <source_model>adminhtml/system_config_source_yesno</source_model>
104
+ <sort_order>10</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>0</show_in_website>
107
+ <show_in_store>0</show_in_store>
108
+ </repricingschedule_active>
109
+ <repricingschedule_time translate="label">
110
+ <label>Start Time</label>
111
+ <frontend_type>time</frontend_type>
112
+ <sort_order>20</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>0</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </repricingschedule_time>
117
+ <repricingschedule_frequency translate="label">
118
+ <label>Frequency</label>
119
+ <frontend_type>select</frontend_type>
120
+ <source_model>mercent_repricing/feedfrequency</source_model>
121
+ <backend_model>mercent_repricing/system_config_backend_export_cron</backend_model>
122
+ <sort_order>30</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>0</show_in_website>
125
+ <show_in_store>0</show_in_store>
126
+ </repricingschedule_frequency>
127
+ </fields>
128
+ </repricingschedule_group>
129
+ </groups>
130
+ </repricingconfig>
131
+ </sections>
132
+ </config>
app/etc/modules/Mercent_Export.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mercent_Export>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Mercent_Export>
8
+ </modules>
9
+ </config>
app/etc/modules/Mercent_Repricing.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mercent_Repricing>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Mercent_Repricing>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Mercent_Priceoptimizer</name>
4
+ <version>1.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>Mercent&#x2019;s Marketplace Price Optimizer helps Magento retailers compete profitably. Our simple yet powerful hosted solution allows you to gain the advantage by strategically pricing flexible, custom product assortments&#x2014;up and down&#x2014;to consistently win the Buy Box and grow top line revenue.</summary>
10
+ <description>Mercent&#x2019;s Marketplace Price Optimizer helps Magento retailers compete profitably. Our simple yet powerful hosted solution allows you to gain the advantage by strategically pricing flexible, custom product assortments&#x2014;up and down&#x2014;to consistently win the Buy Box and grow top line revenue.</description>
11
+ <notes>Mercent Retail Price Optimizer</notes>
12
+ <authors><author><name>Mercent Corporation</name><user>mercent</user><email>magento@mercent.com</email></author></authors>
13
+ <date>2012-04-18</date>
14
+ <time>18:12:32</time>
15
+ <contents><target name="magecommunity"><dir name="Mercent"><dir name="Repricing"><dir name="Helper"><file name="Data.php" hash="562c4007e38564ac376ac39b497a55dd"/></dir><dir name="Model"><file name="Feedfrequency.php" hash="f34b0a1c9192b093b33a52c56a5b2644"/><file name="Observer.php" hash="f56a8d76e4590a47814b071401a3fd8d"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Export"><file name="Cron.php" hash="929dc99bf42c284af53c032ece1447e6"/></dir></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="18ea43180ac8e7cded54943b65ed848e"/><file name="config.xml" hash="4299eafff09aae8a8e237ad759a11d44"/><file name="system.xml" hash="5896f7c270fd427a4a3bdd64afafa180"/></dir></dir><dir name="Export"><dir name="Model"><dir name="Export"><dir name="Adapter"><file name="Tab.php" hash="e0fa7644e9826ec5779ddcbd81f50018"/></dir><dir name="Entity"><file name="Product.php" hash="2798bb89e11f8137b73cb089246978ec"/></dir></dir><file name="Export.php" hash="975c68972fd44d621c1812a3fb7c9997"/></dir><dir name="etc"><file name="config.xml" hash="ea96e5d2148544aa686233ea2b16fd22"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mercent_Repricing.xml" hash="4cb9aa3e2db26b15f949990e0b46cd27"/><file name="Mercent_Export.xml" hash="eb720e7e91b69a44bef28351020fe599"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>