minewhat - Version 1.0

Version Notes

Initial Release

Download this release

Release Info

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


Version 1.0

app/code/community/MineWhat/Insights/Block/Base/Script.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category MineWhat
5
+ * @package MineWhat_Insights
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_Block_Base_Script extends Mage_Core_Block_Template {
10
+
11
+ protected function _construct() {
12
+ parent::_construct();
13
+ $this->setTemplate('minewhat/insights/base/script.phtml');
14
+ }
15
+
16
+ protected function _toHtml() {
17
+ if (!$this->helper('minewhat_insights')->isModuleOutputEnabled()) {
18
+ return '';
19
+ }
20
+ return parent::_toHtml();
21
+ }
22
+
23
+ }
app/code/community/MineWhat/Insights/Block/Event/Catalog/Product/View.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category MineWhat
5
+ * @package MineWhat_Insights
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_Block_Event_Catalog_Product_View extends Mage_Core_Block_Template {
10
+
11
+ protected function _construct() {
12
+ parent::_construct();
13
+ $this->setTemplate('minewhat/insights/event/catalog/product/view.phtml');
14
+ }
15
+
16
+ public function getCurrentProduct() {
17
+ return Mage::registry('current_product');
18
+ }
19
+
20
+ protected function _toHtml() {
21
+ if (!$this->helper('minewhat_insights')->isModuleOutputEnabled()) {
22
+ return '';
23
+ }
24
+ return parent::_toHtml();
25
+ }
26
+
27
+ }
app/code/community/MineWhat/Insights/Block/Event/Checkout/Cart/Index.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category MineWhat
5
+ * @package MineWhat_Insights
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_Block_Event_Checkout_Cart_Index extends Mage_Core_Block_Template {
10
+
11
+ protected function _construct() {
12
+ parent::_construct();
13
+ $this->setTemplate('minewhat/insights/event/checkout/cart/index.phtml');
14
+ }
15
+
16
+ public function getProductToShoppingCart() {
17
+ if (($product = Mage::getModel('core/session')->getProductToShoppingCart())) {
18
+ return $product;
19
+ }
20
+
21
+ return null;
22
+ }
23
+
24
+ protected function _toHtml() {
25
+ if (!$this->helper('minewhat_insights')->isModuleOutputEnabled()) {
26
+ return '';
27
+ }
28
+ return parent::_toHtml();
29
+ }
30
+
31
+ }
app/code/community/MineWhat/Insights/Block/Event/Checkout/Onepage/Success.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category MineWhat
5
+ * @package MineWhat_Insights
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_Block_Event_Checkout_Onepage_Success extends Mage_Core_Block_Template {
10
+
11
+ protected function _construct() {
12
+ parent::_construct();
13
+ $this->setTemplate('minewhat/insights/event/checkout/onepage/success.phtml');
14
+ }
15
+
16
+ public function getOrderInfo() {
17
+ $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
18
+
19
+ $order = Mage::getSingleton('sales/order');
20
+ $order->load($lastOrderId);
21
+
22
+ if ($order && $order->getId()) {
23
+
24
+ $orderInfo['items'] = array();
25
+
26
+ $orderedItems = $order->getAllItems();
27
+
28
+ foreach($orderedItems as $item) {
29
+
30
+ $orderInfo['items'][] = new Varien_Object(array(
31
+ 'id' => $item->getProductId(),
32
+ 'qty' => $item->getQtyOrdered()
33
+ ));
34
+
35
+ }
36
+
37
+ return new Varien_Object($orderInfo);
38
+ }
39
+
40
+ return null;
41
+ }
42
+
43
+ protected function _toHtml() {
44
+ if (!$this->helper('minewhat_insights')->isModuleOutputEnabled()) {
45
+ return '';
46
+ }
47
+ return parent::_toHtml();
48
+ }
49
+
50
+ }
app/code/community/MineWhat/Insights/Helper/Data.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category MineWhat
5
+ * @package MineWhat_Insights
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
+ }
app/code/community/MineWhat/Insights/Model/Observer.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MineWhat_Insights_Model_Observer
4
+ {
5
+ public function logCartAdd() {
6
+
7
+ $product = Mage::getModel('catalog/product')
8
+ ->load(Mage::app()->getRequest()->getParam('product', 0));
9
+
10
+ if (!$product->getId()) {
11
+ return;
12
+ }
13
+
14
+ Mage::getModel('core/session')->setProductToShoppingCart(
15
+ new Varien_Object(array(
16
+ 'id' => $product->getId()
17
+ ))
18
+ );
19
+ }
20
+ }
app/code/community/MineWhat/Insights/etc/adminhtml.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category MineWhat
5
+ * @package MineWhat_Insights
6
+ * @copyright Copyright (c) MineWhat
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <acl>
12
+ <resources>
13
+ <admin>
14
+ <children>
15
+ <system>
16
+ <children>
17
+ <config>
18
+ <children>
19
+ <minewhat_insights translate="title" module="minewhat_insights">
20
+ <title>MineWhat</title>
21
+ </minewhat_insights>
22
+ </children>
23
+ </config>
24
+ </children>
25
+ </system>
26
+ </children>
27
+ </admin>
28
+ </resources>
29
+ </acl>
30
+ </config>
app/code/community/MineWhat/Insights/etc/config.xml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category MineWhat
5
+ * @package MineWhat_Insights
6
+ * @copyright Copyright (c) MineWhat
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <MineWhat_Insights>
13
+ <version>1.0.0.0</version>
14
+ </MineWhat_Insights>
15
+ </modules>
16
+ <global>
17
+ <models>
18
+ <minewhat_insights>
19
+ <class>MineWhat_Insights_Model</class>
20
+ </minewhat_insights>
21
+ </models>
22
+ <blocks>
23
+ <minewhat_insights>
24
+ <class>MineWhat_Insights_Block</class>
25
+ </minewhat_insights>
26
+ </blocks>
27
+ <helpers>
28
+ <minewhat_insights>
29
+ <class>MineWhat_Insights_Helper</class>
30
+ </minewhat_insights>
31
+ </helpers>
32
+ </global>
33
+ <frontend>
34
+ <layout>
35
+ <updates>
36
+ <minewhat_insights>
37
+ <file>minewhat_insights.xml</file>
38
+ </minewhat_insights>
39
+ </updates>
40
+ </layout>
41
+ <events>
42
+ <controller_action_predispatch_checkout_cart_add>
43
+ <observers>
44
+ <minewhat_insights_log_cart_add>
45
+ <class>minewhat_insights/observer</class>
46
+ <method>logCartAdd</method>
47
+ </minewhat_insights_log_cart_add>
48
+ </observers>
49
+ </controller_action_predispatch_checkout_cart_add>
50
+ </events>
51
+ </frontend>
52
+ <default>
53
+ <minewhat_insights>
54
+ <settings>
55
+ <active>0</active>
56
+ <base_script></base_script>
57
+ </settings>
58
+ </minewhat_insights>
59
+ </default>
60
+ </config>
app/code/community/MineWhat/Insights/etc/system.xml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category MineWhat
5
+ * @package MineWhat_Insights
6
+ * @copyright Copyright (c) MineWhat
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <sections>
12
+ <minewhat_insights translate="label" module="minewhat_insights">
13
+ <label>MineWhat</label>
14
+ <tab>service</tab>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>200</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <groups>
21
+ <settings translate="label">
22
+ <label>MineWhat Settings</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>10</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <fields>
29
+ <active translate="label">
30
+ <label>Enabled</label>
31
+ <frontend_type>select</frontend_type>
32
+ <source_model>adminhtml/system_config_source_yesno</source_model>
33
+ <sort_order>10</sort_order>
34
+ <show_in_default>1</show_in_default>
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
+ </fields>
47
+ </settings>
48
+ </groups>
49
+ </minewhat_insights>
50
+ </sections>
51
+ </config>
app/design/frontend/default/default/layout/minewhat_insights.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category MineWhat
5
+ * @package MineWhat_Insights
6
+ * @copyright Copyright (c) MineWhat
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <layout version="0.1.0">
11
+
12
+ <catalog_product_view>
13
+ <reference name="before_body_end">
14
+ <block type="minewhat_insights/event_catalog_product_view" name="minewhat_insights_event_catalog_product_view" />
15
+ </reference>
16
+ </catalog_product_view>
17
+
18
+ <checkout_cart_index>
19
+ <reference name="before_body_end">
20
+ <block type="minewhat_insights/event_checkout_cart_index" name="minewhat_insights_event_checkout_cart_index" />
21
+ </reference>
22
+ </checkout_cart_index>
23
+
24
+ <checkout_onepage_success>
25
+ <reference name="before_body_end">
26
+ <block type="minewhat_insights/event_checkout_onepage_success" name="minewhat_insights_event_checkout_onepage_success" />
27
+ </reference>
28
+ </checkout_onepage_success>
29
+
30
+ <default>
31
+ <reference name="before_body_end">
32
+ <block type="minewhat_insights/base_script" name="minewhat_insights_base_script" />
33
+ </reference>
34
+ </default>
35
+
36
+ </layout>
app/design/frontend/default/default/template/minewhat/insights/base/script.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php echo Mage::helper('minewhat_insights')->getBaseScript() ?>
app/design/frontend/default/default/template/minewhat/insights/event/catalog/product/view.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category MineWhat
4
+ * @package MineWhat_Insights
5
+ * @copyright Copyright (c) MineWhat
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ ?>
9
+ <?php $_product = $this->getCurrentProduct() ?>
10
+ <script type="text/javascript">
11
+ _mwapi.push(['trackEvent', 'product', '<?php echo $_product->getId() ?>']);
12
+ </script>
app/design/frontend/default/default/template/minewhat/insights/event/checkout/cart/index.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category MineWhat
4
+ * @package MineWhat_Insights
5
+ * @copyright Copyright (c) MineWhat
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ ?>
9
+ <?php $_product = $this->getProductToShoppingCart() ?>
10
+ <?php if ($_product && $_product->getId()): ?>
11
+ <script type="text/javascript">
12
+ _mwapi.push(['trackEvent', 'cart', '<?php echo $_product->getId() ?>']);
13
+ </script>
14
+ <?php endif; ?>
app/design/frontend/default/default/template/minewhat/insights/event/checkout/onepage/success.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category MineWhat
4
+ * @package MineWhat_Insights
5
+ * @copyright Copyright (c) MineWhat
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ */
8
+ ?>
9
+ <?php if (($orderInfo = $this->getOrderInfo())): ?>
10
+ <script type="text/javascript">
11
+ <?php foreach ($orderInfo->getItems() as $product): ?>
12
+ _mwapi.push(['trackEvent', 'buy', '<?php echo $product->getId() ?>', '<?php echo intval($product->getQty()) ?>']);
13
+ <?php endforeach; ?>
14
+ </script>
15
+ <?php endif; ?>
app/etc/modules/MineWhat_Insights.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <MineWhat_Insights>
6
+ <active>true</active>
7
+ <codePool>community</codePool>
8
+ </MineWhat_Insights>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>minewhat</name>
4
+ <version>1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">osl</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>MineWhat Insights</summary>
10
+ <description>MineWhat Insights</description>
11
+ <notes>Initial Release</notes>
12
+ <authors><author><name>MineWhat Inc.</name><user>rahulb14</user><email>rahul@minewhat.com</email></author></authors>
13
+ <date>2013-11-08</date>
14
+ <time>11:44:44</time>
15
+ <contents><target name="magecommunity"><dir name="MineWhat"><dir name="Insights"><dir name="Block"><dir name="Base"><file name="Script.php" hash="4af0a2e100d9d33f99125a0a6e64421b"/></dir><dir name="Event"><dir name="Catalog"><dir name="Product"><file name="View.php" hash="278f7fba1faa9aa8c82fb0e18151fcaf"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Index.php" hash="cc23b8bd2838c12603d12e67c5ac44f9"/></dir><dir name="Onepage"><file name="Success.php" hash="966bceb17e578049ffd9ef741f49808f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f55be36b0f6e46f0fccd3a2dee670ec3"/></dir><dir name="Model"><file name="Observer.php" hash="694e05ba360916f7510dabc234bc2a92"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f1fb655aac4dc7f71cadb6c7a7e816f8"/><file name="config.xml" hash="71f8e762ecee6a1545b6223744d8a92f"/><file name="system.xml" hash="75d5165628b2b748a985db0aef1e505d"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="minewhat_insights.xml" hash="cdd30fbb85e90e1d84675f516b8c9c71"/></dir><dir name="template"><dir name="minewhat"><dir name="insights"><dir name="base"><file name="script.phtml" hash="a6b4ecb06d6c40b402ad619425d4493d"/></dir><dir name="event"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="5f5cb6e394bb9de99faeca2a73fe7dee"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="ce82b50115aa664dc20a6e36a4a87261"/></dir><dir name="onepage"><file name="success.phtml" hash="945bdb6f5b12b94d39d0fc3a9f80a12f"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MineWhat_Insights.xml" hash="8d2f076cbfcc14688ed800f622869d4b"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.5</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>