Nfusionsolutions_ProductPricing - Version 1.0.0

Version Notes

Product Price Import from nFusion Solutions

Download this release

Release Info

Developer nFusion Solutions
Extension Nfusionsolutions_ProductPricing
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

User_Manual.PDF ADDED
Binary file
app/code/community/Nfusionsolutions/ProductPricing/Helper/Data.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Nfusionsolutions_ProductPricing extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Nfusionsolutions
13
+ * @package Nfusionsolutions_ProductPricing
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * ProductPrice default helper
19
+ *
20
+ * @category Nfusionsolutions
21
+ * @package Nfusionsolutions_ProductPricing
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Nfusionsolutions_ProductPricing_Helper_Data extends Mage_Core_Helper_Abstract
25
+ {
26
+ /**
27
+ * convert array to options
28
+ *
29
+ * @access public
30
+ * @param $options
31
+ * @return array
32
+ * @author Ultimate Module Creator
33
+ */
34
+ public function getBaseCurrency(){
35
+ $baseCurrency = Mage::app()->getStore()->getBaseCurrencyCode();
36
+ return $baseCurrency;
37
+ }
38
+
39
+ public function getToken(){
40
+ $token = Mage::getStoreConfig('nfusionsolutions_productpricing/productprice/api_token');
41
+ return $token;
42
+ }
43
+
44
+ public function getTenantAlias(){
45
+ $tenantAlias = Mage::getStoreConfig('nfusionsolutions_productpricing/productprice/tenant_alias');
46
+ return $tenantAlias;
47
+ }
48
+
49
+ public function getSalesChannel(){
50
+ $salesChannel = Mage::getStoreConfig('nfusionsolutions_productpricing/productprice/sales_channel');
51
+ return $salesChannel;
52
+ }
53
+
54
+ public function getUrl(){
55
+ $baseCurrency = $this->getBaseCurrency();
56
+ $token = $this->getToken();
57
+ $tenantAlias = $this->getTenantAlias();
58
+ $salesChannel = $this->getSalesChannel();
59
+ return $url_call = 'https://'.$tenantAlias.'.nfusioncatalog.com/service/price/PricesByChannel?currency='.$baseCurrency.'&channel='.$salesChannel.'&withretailtiers=true&token='.$token;
60
+ }
61
+
62
+ }
app/code/community/Nfusionsolutions/ProductPricing/controllers/ProductpriceController.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Nfusionsolutions_ProductPricing extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category Nfusionsolutions
13
+ * @package Nfusionsolutions_ProductPricing
14
+ * @copyright Copyright (c) 2016
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * ProductPrice front contrller
19
+ *
20
+ * @category Nfusionsolutions
21
+ * @package Nfusionsolutions_ProductPricing
22
+ * @author Ultimate Module Creator
23
+ */
24
+ class Nfusionsolutions_ProductPricing_ProductpriceController extends Mage_Core_Controller_Front_Action
25
+ {
26
+
27
+ /**
28
+ * default action
29
+ *
30
+ * @access public
31
+ * @return void
32
+ * @author Ultimate Module Creator
33
+ */
34
+ public function indexAction(){
35
+
36
+ //Check if script is run by hosted server itself
37
+ if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
38
+ die("cannot run!");
39
+ }
40
+
41
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
42
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
43
+ $table = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal');
44
+ $time_start = microtime(true);
45
+
46
+ $_helper = Mage::helper('nfusionsolutions_productpricing');
47
+
48
+ $url_call = $_helper->getUrl();
49
+
50
+ $ch = curl_init();
51
+ curl_setopt($ch, CURLOPT_URL, $url_call);
52
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
53
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json','Cache-Control: no-cache','Pragma: no-cache'));
54
+ $result = curl_exec($ch);
55
+ curl_close($ch);
56
+
57
+ //Decode the API response
58
+ $rateData = json_decode($result);
59
+ //echo '<pre>';
60
+ //print_r($rateData);die;
61
+ if(count($rateData) > 0){
62
+ $proCount = array();
63
+ //$action = Mage::getSingleton('catalog/resource_product_action');
64
+ foreach($rateData as $k=>$v){
65
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
66
+ $enitity_id = '';
67
+ if($v->Ask != ''){
68
+ $select = $read->select()->from('catalog_product_entity', array('entity_id'))->where('sku=?', $v->SKU);
69
+ $rowArray = $read->fetchRow($select); //return row
70
+ $enitity_id = $rowArray['entity_id'];
71
+ }
72
+ if($enitity_id != ''){
73
+ $proCount[$enitity_id] = $enitity_id;
74
+ //Update product price
75
+
76
+ //$query = "UPDATE {$table} SET value = $v->Ask WHERE entity_id = {$enitity_id} AND attribute_id in (75,80)";
77
+ //$write->query($query);
78
+ $data = array("value" => $v->Ask);
79
+ $where = "entity_id = {$enitity_id} AND attribute_id in (75,80)";
80
+ $write->update("catalog_product_entity_decimal", $data, $where);
81
+ //Check tier exist or not
82
+ if(isset($v->RetailTiers)){
83
+ //delete all tier price
84
+ $write->delete("catalog_product_entity_tier_price", "entity_id=$enitity_id");
85
+
86
+ //Reset tier price
87
+ foreach($v->RetailTiers as $tier_k => $tier_v){
88
+ //insert tier price
89
+ $write->insert(
90
+ "catalog_product_entity_tier_price",
91
+ array("value_id" => NULL,"entity_id" => $enitity_id,"all_groups" => '1',"customer_group_id" => '0',
92
+ "qty" => $tier_v->Quantity,"value" => $tier_v->Ask,"website_id" => '0')
93
+ );
94
+ }
95
+ }
96
+
97
+ }
98
+
99
+ }
100
+ //if(isset($_GET['reindex']) && $_GET['reindex'] == 'yes'){
101
+ if(1){
102
+ $process = Mage::getModel('index/indexer')->getProcessByCode('catalog_product_price');
103
+ $process->reindexAll();
104
+ }
105
+ }
106
+ $time_end = microtime(true);
107
+ $execution_time = ($time_end - $time_start);
108
+ //echo '<br/><b>Total Execution Time:</b> '.$execution_time.' Sec. for <b>'.count($proCount).'</b> products.';
109
+ }
110
+
111
+ }
app/code/community/Nfusionsolutions/ProductPricing/etc/adminhtml.xml ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Nfusionsolutions_ProductPricing extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Nfusionsolutions
14
+ * @package Nfusionsolutions_ProductPricing
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <acl>
21
+ <resources>
22
+ <admin>
23
+ <children>
24
+ <system>
25
+ <children>
26
+ <config>
27
+ <children>
28
+ <nfusionsolutions_productpricing translate="title" module="nfusionsolutions_productpricing">
29
+ <title>Product Pricing</title>
30
+ </nfusionsolutions_productpricing>
31
+ </children>
32
+ </config>
33
+ </children>
34
+ </system>
35
+ <nfusionsolutions_productpricing translate="title" module="nfusionsolutions_productpricing">
36
+ <title>Product Pricing</title>
37
+ <children>
38
+ <productprice translate="title" module="nfusionsolutions_productpricing">
39
+ <title>ProductPrice</title>
40
+ <sort_order>0</sort_order>
41
+ </productprice>
42
+ </children>
43
+ </nfusionsolutions_productpricing>
44
+ </children>
45
+ </admin>
46
+ </resources>
47
+ </acl>
48
+ <menu>
49
+ <nfusionsolutions_currencyexchangerates translate="title" module="nfusionsolutions_productpricing">
50
+ <title>nFusion Solutions</title>
51
+ <sort_order>100</sort_order>
52
+ <children>
53
+ <productprice translate="title" module="nfusionsolutions_productpricing">
54
+ <title>Product Pricing</title>
55
+ <sort_order>10</sort_order>
56
+ <children>
57
+ <nfusionsolutions_productpricing translate="title" module="nfusionsolutions_productpricing">
58
+ <title>Settings</title>
59
+ <action>adminhtml/system_config/edit/section/nfusionsolutions_productpricing</action>
60
+ <sort_order>2</sort_order>
61
+ </nfusionsolutions_productpricing>
62
+ </children>
63
+ </productprice>
64
+ </children>
65
+ </nfusionsolutions_currencyexchangerates>
66
+ </menu>
67
+ </config>
app/code/community/Nfusionsolutions/ProductPricing/etc/config.xml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Nfusionsolutions_ProductPricing extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Nfusionsolutions
14
+ * @package Nfusionsolutions_ProductPricing
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Nfusionsolutions_ProductPricing>
22
+ <version>1.0.0</version>
23
+ </Nfusionsolutions_ProductPricing>
24
+ </modules>
25
+ <global>
26
+ <helpers>
27
+ <nfusionsolutions_productpricing>
28
+ <class>Nfusionsolutions_ProductPricing_Helper</class>
29
+ </nfusionsolutions_productpricing>
30
+ </helpers>
31
+ </global>
32
+ <admin>
33
+ <routers>
34
+ <adminhtml>
35
+ <args>
36
+ <modules>
37
+ <Nfusionsolutions_ProductPricing before="Mage_Adminhtml">Nfusionsolutions_ProductPricing_Adminhtml</Nfusionsolutions_ProductPricing>
38
+ </modules>
39
+ </args>
40
+ </adminhtml>
41
+ </routers>
42
+ </admin>
43
+ <frontend>
44
+ <routers>
45
+ <nfusionsolutions_productpricing>
46
+ <use>standard</use>
47
+ <args>
48
+ <module>Nfusionsolutions_ProductPricing</module>
49
+ <frontName>nfusionsolutions</frontName>
50
+ </args>
51
+ </nfusionsolutions_productpricing>
52
+ </routers>
53
+ </frontend>
54
+ </config>
app/code/community/Nfusionsolutions/ProductPricing/etc/system.xml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Nfusionsolutions_ProductPricing extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Nfusionsolutions
14
+ * @package Nfusionsolutions_ProductPricing
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <tabs>
21
+ <currencyexchangerates translate="label" module="nfusionsolutions_productpricing">
22
+ <label>nFusion Solutions</label>
23
+ <sort_order>2000</sort_order>
24
+ </currencyexchangerates>
25
+ </tabs>
26
+ <sections>
27
+ <nfusionsolutions_productpricing translate="label" module="nfusionsolutions_productpricing">
28
+ <class>separator-top</class>
29
+ <label>Product Pricing</label>
30
+ <tab>currencyexchangerates</tab>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>100</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
+ <groups>
37
+ <productprice translate="label" module="nfusionsolutions_productpricing">
38
+ <label>Product Pricing Setting</label>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>0</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <fields>
45
+ <tenant_alias translate="label">
46
+ <label>Tenant Alias</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>10</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ </tenant_alias>
53
+ <api_token translate="label">
54
+ <label>Token</label>
55
+ <frontend_type>text</frontend_type>
56
+ <sort_order>20</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </api_token>
61
+ <sales_channel translate="label">
62
+ <label>Sales Channel</label>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>30</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </sales_channel>
69
+ </fields>
70
+ </productprice>
71
+ </groups>
72
+ </nfusionsolutions_productpricing>
73
+ </sections>
74
+ </config>
app/etc/modules/Nfusionsolutions_ProductPricing.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Nfusionsolutions_ProductPricing extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Nfusionsolutions
14
+ * @package Nfusionsolutions_ProductPricing
15
+ * @copyright Copyright (c) 2016
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Nfusionsolutions_ProductPricing>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ <depends>
25
+ <Mage_Core />
26
+ </depends>
27
+ </Nfusionsolutions_ProductPricing>
28
+ </modules>
29
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Nfusionsolutions_ProductPricing</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension adds the capability in Magento to import product prices from nFusion Solutions' reliable, enterprise-class cloud platform for global financial data.</summary>
10
+ <description>This extension adds the capability in Magento to import products prices from nFusion Solutions' reliable, enterprise-class cloud platform for global financial data. All settings are provided in the Magento admin. When you import product prices in Magento this plugin will import prices from the nFusion Solutions cloud platform in the base currency of your Magento store. Through the use of a cron job the plugin can update prices automatically on a scheduled interval.</description>
11
+ <notes>Product Price Import from nFusion Solutions</notes>
12
+ <authors><author><name>nFusion Solutions</name><user>nfusion</user><email>support@nfusionsolutions.com</email></author></authors>
13
+ <date>2016-04-02</date>
14
+ <time>11:11:23</time>
15
+ <contents><target name="magecommunity"><dir name="Nfusionsolutions"><dir name="ProductPricing"><dir name="Helper"><file name="Data.php" hash="755fbe12ed02611b7369669122291770"/></dir><dir name="controllers"><file name="ProductpriceController.php" hash="b7f842507da1531c25e03885c99e2d81"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8f33535f25e40175208841536680b244"/><file name="config.xml" hash="fbbd2bb5ee80953f7b8f21fcea684fa7"/><file name="system.xml" hash="dff7997122aee1b4c35a988ddecd52c2"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Nfusionsolutions_ProductPricing.xml" hash="7d38f1337f5b8c3f3b85531a913fa197"/></dir></target><target name="mage"><dir name="."><file name="User_Manual.PDF" hash="0192e62ce6dafcdb13a4524aba6d5234"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>