minewhat - Version 1.0.21

Version Notes

MineWhat magento plugin

Download this release

Release Info

Developer MineWhat Inc.
Extension minewhat
Version 1.0.21
Comparing to
See all releases


Code changes from version 1.0.20 to 1.0.21

app/code/community/MineWhat/Insights/Helper/Data.php CHANGED
@@ -6,24 +6,34 @@
6
  * @copyright Copyright (c) MineWhat
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
9
- class MineWhat_Insights_Helper_Data extends Mage_Core_Helper_Data
10
- {
11
 
12
- const CONFIG_ACTIVE = 'minewhat_insights/settings/active';
13
- const CONFIG_BASE_SCRIPT = 'minewhat_insights/settings/base_script';
14
 
15
- public function isModuleEnabled($moduleName = null)
16
- {
17
- if (Mage::getStoreConfig(self::CONFIG_ACTIVE) == '0') {
18
- return false;
19
- }
20
-
21
- return parent::isModuleEnabled($moduleName = null);
22
  }
23
 
24
- public function getBaseScript($store = null)
25
- {
26
- return Mage::getStoreConfig(self::CONFIG_BASE_SCRIPT, $store);
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
 
 
 
 
 
29
  }
6
  * @copyright Copyright (c) MineWhat
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
  */
9
+ class MineWhat_Insights_Helper_Data extends Mage_Core_Helper_Data {
 
10
 
11
+ const CONFIG_ACTIVE = 'minewhat_insights/settings/active';
12
+ const CONFIG_API_KEY = 'minewhat_insights/settings/api_key';
13
 
14
+ public function isModuleEnabled($moduleName = null) {
15
+ if (Mage::getStoreConfig(self::CONFIG_ACTIVE) == '0') {
16
+ return false;
 
 
 
 
17
  }
18
 
19
+ return parent::isModuleEnabled($moduleName = null);
20
+ }
21
+
22
+ public function getBaseScript($store = null) {
23
+
24
+ $base_script = "";
25
+
26
+ try {
27
+
28
+ $base_script = "\n<!-- MineWhat Script begins -->\n<script type='text/javascript'>!function(){function t(){if(!window.MWSDK){var t=document.createElement('script'),n='beaconhttp.minewhat.com';t.type='text/javascript',t.async=!0,'https:'==location.protocol&&(n='d2ft2mgd1hddln.cloudfront.net'),t.src='//'+n+'/site/ethno/ORG_HANDLE/minewhat.js';var e=document.getElementsByTagName('script')[0];e.parentNode.insertBefore(t,e)}}window.MWSDK&&window.MWSDK.reinit&&window.MWSDK.reinit(),window.attachEvent?window.attachEvent('onload',t):window.addEventListener('load',t,!1)}();</script>\n<!-- MineWhat Script ends -->\n";
29
+ $base_script = str_replace("ORG_HANDLE", split("_", Mage::getStoreConfig(self::CONFIG_API_KEY, $store))[0], $base_script);
30
+
31
+ } catch (Exception $e) {
32
+ $base_script = "";
33
  }
34
 
35
+ return $base_script;
36
+
37
+ }
38
+
39
  }
app/code/community/MineWhat/Insights/Model/Observer.php CHANGED
@@ -2,51 +2,66 @@
2
 
3
  class MineWhat_Insights_Model_Observer
4
  {
5
- public function logCartAdd($observer) {
6
 
7
- if (!$observer->getQuoteItem()->getProduct()->getId()) {
8
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
 
10
 
11
- $product = $observer->getProduct();
12
- $id = $observer->getQuoteItem()->getProduct()->getId();
13
- $bundle = array();
14
-
15
- if($product->getTypeId() == 'bundle') {
16
-
17
- $id = $product->getId();
18
- $optionCollection = $product->getTypeInstance()->getOptionsCollection();
19
- $selectionCollection = $product->getTypeInstance()->getSelectionsCollection($product->getTypeInstance()->getOptionsIds());
20
- $options = $optionCollection->appendSelections($selectionCollection);
21
- foreach( $options as $option )
22
- {
23
- $_selections = $option->getSelections();
24
- foreach( $_selections as $selection )
25
- {
26
- $bundleItem = array();
27
- $bundleItem['pid'] = $selection->getId();
28
- $bundleItem['sku'] = $selection->getSku();
29
- $bundleItem['price'] = $selection->getPrice();
30
- $bundle[] = $bundleItem;
31
- }
32
- }
33
-
34
- }
35
-
36
- $parentId = '';
37
- $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($id);
38
- if($parentIds != null && count($parentIds) > 0) {
39
- $parentId = $parentIds[0];
40
- }
41
- Mage::getModel('core/session')->setProductToShoppingCart(
42
- array(
43
- 'id' => $id,
44
- 'sku' => $product->getSku(),
45
- 'parentId' => $parentId,
46
- 'qty' => $product->getQty(),
47
- 'bundle' => $bundle
48
- )
49
- );
50
 
 
 
 
 
51
  }
 
 
 
 
 
 
 
 
 
 
 
52
  }
2
 
3
  class MineWhat_Insights_Model_Observer
4
  {
 
5
 
6
+ const CONFIG_ACTIVE = 'minewhat_insights/settings/active';
7
+ const CONFIG_API_KEY = 'minewhat_insights/settings/api_key';
8
+
9
+ public function onSaveSettings($observer) {
10
+
11
+ $enabled = Mage::getStoreConfig(self::CONFIG_ACTIVE);
12
+ $api_key = Mage::getStoreConfig(self::CONFIG_API_KEY);
13
+ $store_url = Mage::getBaseUrl();
14
+ $magento_version = Mage::getVersion();
15
+
16
+ file_get_contents("https://app.minewhat.com/stats/magentoinstall?enabled=".$enabled."&api_key=".$api_key."&store_url=".$store_url."&magentoversion=".$magento_version);
17
+
18
+ }
19
+
20
+ public function logCartAdd($observer) {
21
+
22
+ if (!$observer->getQuoteItem()->getProduct()->getId()) {
23
+ return;
24
+ }
25
+
26
+ $product = $observer->getProduct();
27
+ $id = $observer->getQuoteItem()->getProduct()->getId();
28
+ $bundle = array();
29
+
30
+ if($product->getTypeId() == 'bundle') {
31
+
32
+ $id = $product->getId();
33
+ $optionCollection = $product->getTypeInstance()->getOptionsCollection();
34
+ $selectionCollection = $product->getTypeInstance()->getSelectionsCollection($product->getTypeInstance()->getOptionsIds());
35
+ $options = $optionCollection->appendSelections($selectionCollection);
36
+ foreach( $options as $option )
37
+ {
38
+ $_selections = $option->getSelections();
39
+ foreach( $_selections as $selection )
40
+ {
41
+ $bundleItem = array();
42
+ $bundleItem['pid'] = $selection->getId();
43
+ $bundleItem['sku'] = $selection->getSku();
44
+ $bundleItem['price'] = $selection->getPrice();
45
+ $bundle[] = $bundleItem;
46
  }
47
+ }
48
 
49
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ $parentId = '';
52
+ $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($id);
53
+ if($parentIds != null && count($parentIds) > 0) {
54
+ $parentId = $parentIds[0];
55
  }
56
+ Mage::getModel('core/session')->setProductToShoppingCart(
57
+ array(
58
+ 'id' => $id,
59
+ 'sku' => $product->getSku(),
60
+ 'parentId' => $parentId,
61
+ 'qty' => $product->getQty(),
62
+ 'bundle' => $bundle
63
+ )
64
+ );
65
+
66
+ }
67
  }
app/code/community/MineWhat/Insights/etc/config.xml CHANGED
@@ -29,6 +29,20 @@
29
  <class>MineWhat_Insights_Helper</class>
30
  </minewhat_insights>
31
  </helpers>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  </global>
33
  <frontend>
34
  <routers>
29
  <class>MineWhat_Insights_Helper</class>
30
  </minewhat_insights>
31
  </helpers>
32
+
33
+
34
+ <events>
35
+ <admin_system_config_changed_section_minewhat_insights>
36
+ <observers>
37
+ <minewhat_insights_save_settings>
38
+ <type>singleton</type>
39
+ <class>minewhat_insights/observer</class>
40
+ <method>onSaveSettings</method>
41
+ </minewhat_insights_save_settings>
42
+ </observers>
43
+ </admin_system_config_changed_section_minewhat_insights>
44
+ </events>
45
+
46
  </global>
47
  <frontend>
48
  <routers>
app/code/community/MineWhat/Insights/etc/system.xml CHANGED
@@ -35,14 +35,6 @@
35
  <show_in_website>1</show_in_website>
36
  <show_in_store>1</show_in_store>
37
  </active>
38
- <base_script translate="label">
39
- <label>Base Script</label>
40
- <frontend_type>textarea</frontend_type>
41
- <sort_order>20</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
- </base_script>
46
  <api_key translate="label">
47
  <label>Domain Key</label>
48
  <frontend_type>text</frontend_type>
35
  <show_in_website>1</show_in_website>
36
  <show_in_store>1</show_in_store>
37
  </active>
 
 
 
 
 
 
 
 
38
  <api_key translate="label">
39
  <label>Domain Key</label>
40
  <frontend_type>text</frontend_type>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>minewhat</name>
4
- <version>1.0.20</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">osl</license>
7
  <channel>community</channel>
@@ -10,8 +10,8 @@
10
  <description>MineWhat Insights</description>
11
  <notes>MineWhat magento plugin</notes>
12
  <authors><author><name>MineWhat Inc.</name><user>MineWhat</user><email>plugins@minewhat.com</email></author></authors>
13
- <date>2015-07-10</date>
14
- <time>12:24:43</time>
15
  <contents><target name="magecommunity"><dir name="MineWhat"><dir name="Insights"><dir name="Block"><dir name="Base"><file name="Script.php" hash="dd44e43a5954e82cfa5cf47921642624"/></dir><dir name="Event"><dir name="Catalog"><dir name="Product"><file name="View.php" hash="41eb512f4f77a8e127253cf246587f0c"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Index.php" hash="fafaf6953262ea2b0bc3092d538c30d1"/></dir><dir name="Onepage"><file name="Success.php" hash="779fa1bb799413b05fc111bdc8bc7023"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="c9284d372a18c6db27dec077c04296ff"/></dir><dir name="Model"><file name="Observer.php" hash="8f8ffe64147205aebc15670bc819ccb5"/></dir><dir name="controllers"><file name="ApiController.php" hash="eaeeb290dc1097a0d93f480f6312fe38"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f1fb655aac4dc7f71cadb6c7a7e816f8"/><file name="config.xml" hash="b4443479201149d5ee72c95ca6ffaae5"/><file name="system.xml" hash="8b5d2901cae5a3f65a06ce7fc65e440d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MineWhat_Insights.xml" hash="8d2f076cbfcc14688ed800f622869d4b"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="minewhat"><dir name="insights"><dir name="base"><file name="script.phtml" hash="fe16e289984308941fb830bc97e7cad2"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="f4a801140203b524d44a23ac83e5873a"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="16cf404c9684e5839270fb0931e8fb3b"/></dir><dir name="onepage"><file name="success.phtml" hash="7868bd6e2b4bfe23972a1d6694a8b719"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="minewhat_insights.xml" hash="bffb825f36d0a76fa1e5a1eee1e91b07"/></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="minewhat"><dir name="insights"><dir name="base"><file name="script.phtml" hash="fe16e289984308941fb830bc97e7cad2"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="f4a801140203b524d44a23ac83e5873a"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="16cf404c9684e5839270fb0931e8fb3b"/></dir><dir name="onepage"><file name="success.phtml" hash="3a1d49f78428e4cfd41e8cdd8cedc863"/></dir></dir></dir><dir name="list"><file name="toolbar.phtml" hash="0d35ba1449c7ed24e040ff3a8242838d"/><file name=".DS_Store" hash="220a7ff2487261d1b60c8b2659878617"/></dir><file name="list.phtml" hash="aedc12d376fd394dea55e6dd7593d573"/><dir name="view"><file name="featured.phtml" hash="5ecd5a962cd7d460d96cf792b2ba8d42"/><file name="list.phtml" hash="045c9f03c610ac296ffc0fe998c9f774"/><file name=".DS_Store" hash="984ca461816e7a9ac20b6ee55374f870"/></dir><file name="view.phtml" hash="25359d701778fd130b5b0bc0af2f223e"/><file name=".DS_Store" hash="b0f57b625503b5c464300f483bbec82e"/></dir><file name=".DS_Store" hash="2edc75db2a6acc90e6fef43665df0ae4"/></dir></dir><dir name="layout"><file name="minewhat_insights.xml" hash="8ed857b2639ce2dcc48e5f0225982650"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.5</min><max>6.0.0</max></php></required></dependencies>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>minewhat</name>
4
+ <version>1.0.21</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">osl</license>
7
  <channel>community</channel>
10
  <description>MineWhat Insights</description>
11
  <notes>MineWhat magento plugin</notes>
12
  <authors><author><name>MineWhat Inc.</name><user>MineWhat</user><email>plugins@minewhat.com</email></author></authors>
13
+ <date>2015-07-29</date>
14
+ <time>20:01:43</time>
15
  <contents><target name="magecommunity"><dir name="MineWhat"><dir name="Insights"><dir name="Block"><dir name="Base"><file name="Script.php" hash="dd44e43a5954e82cfa5cf47921642624"/></dir><dir name="Event"><dir name="Catalog"><dir name="Product"><file name="View.php" hash="41eb512f4f77a8e127253cf246587f0c"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Index.php" hash="fafaf6953262ea2b0bc3092d538c30d1"/></dir><dir name="Onepage"><file name="Success.php" hash="779fa1bb799413b05fc111bdc8bc7023"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="c9284d372a18c6db27dec077c04296ff"/></dir><dir name="Model"><file name="Observer.php" hash="8f8ffe64147205aebc15670bc819ccb5"/></dir><dir name="controllers"><file name="ApiController.php" hash="eaeeb290dc1097a0d93f480f6312fe38"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f1fb655aac4dc7f71cadb6c7a7e816f8"/><file name="config.xml" hash="b4443479201149d5ee72c95ca6ffaae5"/><file name="system.xml" hash="8b5d2901cae5a3f65a06ce7fc65e440d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MineWhat_Insights.xml" hash="8d2f076cbfcc14688ed800f622869d4b"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="minewhat"><dir name="insights"><dir name="base"><file name="script.phtml" hash="fe16e289984308941fb830bc97e7cad2"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="f4a801140203b524d44a23ac83e5873a"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="16cf404c9684e5839270fb0931e8fb3b"/></dir><dir name="onepage"><file name="success.phtml" hash="7868bd6e2b4bfe23972a1d6694a8b719"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="minewhat_insights.xml" hash="bffb825f36d0a76fa1e5a1eee1e91b07"/></dir></dir></dir><dir name="base"><dir name="default"><dir name="template"><dir name="minewhat"><dir name="insights"><dir name="base"><file name="script.phtml" hash="fe16e289984308941fb830bc97e7cad2"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="f4a801140203b524d44a23ac83e5873a"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="16cf404c9684e5839270fb0931e8fb3b"/></dir><dir name="onepage"><file name="success.phtml" hash="3a1d49f78428e4cfd41e8cdd8cedc863"/></dir></dir></dir><dir name="list"><file name="toolbar.phtml" hash="0d35ba1449c7ed24e040ff3a8242838d"/><file name=".DS_Store" hash="220a7ff2487261d1b60c8b2659878617"/></dir><file name="list.phtml" hash="aedc12d376fd394dea55e6dd7593d573"/><dir name="view"><file name="featured.phtml" hash="5ecd5a962cd7d460d96cf792b2ba8d42"/><file name="list.phtml" hash="045c9f03c610ac296ffc0fe998c9f774"/><file name=".DS_Store" hash="984ca461816e7a9ac20b6ee55374f870"/></dir><file name="view.phtml" hash="25359d701778fd130b5b0bc0af2f223e"/><file name=".DS_Store" hash="b0f57b625503b5c464300f483bbec82e"/></dir><file name=".DS_Store" hash="2edc75db2a6acc90e6fef43665df0ae4"/></dir></dir><dir name="layout"><file name="minewhat_insights.xml" hash="8ed857b2639ce2dcc48e5f0225982650"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.5</min><max>6.0.0</max></php></required></dependencies>