Version Notes
MineWhat magento plugin
Download this release
Release Info
Developer | MineWhat Inc. |
Extension | minewhat |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
- app/code/community/MineWhat/Insights/Block/Event/Catalog/Product/View.php +12 -0
- app/code/community/MineWhat/Insights/Block/Event/Checkout/Cart/Index.php +1 -0
- app/code/community/MineWhat/Insights/Block/Event/Checkout/Onepage/Success.php +43 -8
- app/code/community/MineWhat/Insights/Model/Observer.php +34 -8
- app/code/community/MineWhat/Insights/etc/config.xml +3 -2
- app/design/frontend/base/default/layout/minewhat_insights.xml +3 -3
- app/design/frontend/base/default/template/minewhat/insights/event/catalog/product/view.phtml +33 -1
- app/design/frontend/base/default/template/minewhat/insights/event/catalog/product/view.phtml~ +0 -13
- app/design/frontend/base/default/template/minewhat/insights/event/checkout/cart/index.phtml +4 -2
- app/design/frontend/base/default/template/minewhat/insights/event/checkout/cart/index.phtml~ +0 -15
- app/design/frontend/base/default/template/minewhat/insights/event/checkout/onepage/success.phtml +5 -3
- app/design/frontend/base/default/template/minewhat/insights/event/checkout/onepage/success.phtml~ +0 -16
- app/design/frontend/default/default/layout/minewhat_insights.xml +3 -3
- app/design/frontend/default/default/template/minewhat/insights/event/catalog/product/view.phtml +33 -1
- app/design/frontend/default/default/template/minewhat/insights/event/checkout/cart/index.phtml +4 -2
- app/design/frontend/default/default/template/minewhat/insights/event/checkout/onepage/success.phtml +4 -2
- package.xml +4 -4
app/code/community/MineWhat/Insights/Block/Event/Catalog/Product/View.php
CHANGED
@@ -17,6 +17,18 @@ class MineWhat_Insights_Block_Event_Catalog_Product_View extends Mage_Core_Block
|
|
17 |
return Mage::registry('current_product');
|
18 |
}
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
protected function _toHtml() {
|
21 |
if (!$this->helper('minewhat_insights')->isModuleOutputEnabled()) {
|
22 |
return '';
|
17 |
return Mage::registry('current_product');
|
18 |
}
|
19 |
|
20 |
+
public function getAssociatedProducts($_product) {
|
21 |
+
|
22 |
+
if($_product->getTypeId() == "configurable") {
|
23 |
+
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
|
24 |
+
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect(Array('id', 'sku', 'price'))->addFilterByRequiredOptions();
|
25 |
+
return $simple_collection;
|
26 |
+
} else {
|
27 |
+
return null;
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
protected function _toHtml() {
|
33 |
if (!$this->helper('minewhat_insights')->isModuleOutputEnabled()) {
|
34 |
return '';
|
app/code/community/MineWhat/Insights/Block/Event/Checkout/Cart/Index.php
CHANGED
@@ -15,6 +15,7 @@ class MineWhat_Insights_Block_Event_Checkout_Cart_Index extends Mage_Core_Block_
|
|
15 |
|
16 |
public function getProductToShoppingCart() {
|
17 |
if (($product = Mage::getModel('core/session')->getProductToShoppingCart())) {
|
|
|
18 |
return $product;
|
19 |
}
|
20 |
|
15 |
|
16 |
public function getProductToShoppingCart() {
|
17 |
if (($product = Mage::getModel('core/session')->getProductToShoppingCart())) {
|
18 |
+
Mage::getModel('core/session')->unsProductToShoppingCart();
|
19 |
return $product;
|
20 |
}
|
21 |
|
app/code/community/MineWhat/Insights/Block/Event/Checkout/Onepage/Success.php
CHANGED
@@ -19,22 +19,57 @@ class MineWhat_Insights_Block_Event_Checkout_Onepage_Success extends Mage_Core_B
|
|
19 |
$order = Mage::getSingleton('sales/order');
|
20 |
$order->load($lastOrderId);
|
21 |
|
|
|
22 |
if ($order && $order->getId()) {
|
23 |
|
24 |
-
|
25 |
|
26 |
-
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
'id' => $item->getProductId(),
|
32 |
-
'
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
36 |
|
37 |
-
|
38 |
}
|
39 |
|
40 |
return null;
|
19 |
$order = Mage::getSingleton('sales/order');
|
20 |
$order->load($lastOrderId);
|
21 |
|
22 |
+
|
23 |
if ($order && $order->getId()) {
|
24 |
|
25 |
+
$orderInfo['items'] = array();
|
26 |
|
27 |
+
$orderedItems = $order->getAllItems();
|
28 |
|
29 |
+
foreach($orderedItems as $item) {
|
30 |
|
31 |
+
if($item->getProductType() == "bundle") {
|
32 |
+
|
33 |
+
$orderInfo['items'][$item->getItemId()] = array(
|
34 |
+
'id' => $item->getProductId(),
|
35 |
+
'parentId' => [],
|
36 |
+
'sku' => $item->getSku(),
|
37 |
+
'qty' => $item->getQtyOrdered(),
|
38 |
+
'price' => $item->getPrice(),
|
39 |
+
'bundle' => array()
|
40 |
+
);
|
41 |
+
|
42 |
+
} else if($item->getProductType() != "configurable") {
|
43 |
+
|
44 |
+
if($orderInfo['items'][$item->getParentItemId()] != null) {
|
45 |
+
$bundleItems = $orderInfo['items'][$item->getParentItemId()]['bundle'];
|
46 |
+
$bundleItem = array(
|
47 |
+
'id' => $item->getProductId(),
|
48 |
+
'sku' => $item->getSku(),
|
49 |
+
'qty' => $item->getQtyOrdered(),
|
50 |
+
'price' => $item->getPrice()
|
51 |
+
);
|
52 |
+
$bundleItems[] = $bundleItem;
|
53 |
+
$orderInfo['items'][$item->getParentItemId()]['bundle'] = $bundleItems;
|
54 |
+
|
55 |
+
} else {
|
56 |
+
|
57 |
+
$orderInfo['items'][] = array(
|
58 |
'id' => $item->getProductId(),
|
59 |
+
'parentId' => Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($item->getProductId()),
|
60 |
+
'sku' => $item->getSku(),
|
61 |
+
'qty' => $item->getQtyOrdered(),
|
62 |
+
'price' => $item->getPrice(),
|
63 |
+
'bundle' => array()
|
64 |
+
);
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
69 |
|
70 |
+
}
|
71 |
|
72 |
+
return $orderInfo;
|
73 |
}
|
74 |
|
75 |
return null;
|
app/code/community/MineWhat/Insights/Model/Observer.php
CHANGED
@@ -2,19 +2,45 @@
|
|
2 |
|
3 |
class MineWhat_Insights_Model_Observer
|
4 |
{
|
5 |
-
public function logCartAdd() {
|
6 |
|
7 |
-
|
8 |
-
->load(Mage::app()->getRequest()->getParam('product', 0));
|
9 |
-
|
10 |
-
if (!$product->getId()) {
|
11 |
return;
|
12 |
}
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
Mage::getModel('core/session')->setProductToShoppingCart(
|
15 |
-
|
16 |
-
'id' => $
|
17 |
-
|
|
|
|
|
|
|
18 |
);
|
|
|
19 |
}
|
20 |
}
|
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['id'] = $selection->getId();
|
28 |
+
$bundleItem['sku'] = $selection->getSku();
|
29 |
+
$bundleItem['price'] = $selection->getPrice();
|
30 |
+
$bundle[] = $bundleItem;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
Mage::getModel('core/session')->setProductToShoppingCart(
|
37 |
+
array(
|
38 |
+
'id' => $id,
|
39 |
+
'sku' => $product->getSku(),
|
40 |
+
'parentId' => Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($id),
|
41 |
+
'bundle' => $bundle
|
42 |
+
)
|
43 |
);
|
44 |
+
|
45 |
}
|
46 |
}
|
app/code/community/MineWhat/Insights/etc/config.xml
CHANGED
@@ -39,14 +39,15 @@
|
|
39 |
</updates>
|
40 |
</layout>
|
41 |
<events>
|
42 |
-
<
|
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 |
-
</
|
50 |
</events>
|
51 |
</frontend>
|
52 |
<default>
|
39 |
</updates>
|
40 |
</layout>
|
41 |
<events>
|
42 |
+
<checkout_cart_product_add_after>
|
43 |
<observers>
|
44 |
<minewhat_insights_log_cart_add>
|
45 |
+
<type>singleton</type>
|
46 |
<class>minewhat_insights/observer</class>
|
47 |
<method>logCartAdd</method>
|
48 |
</minewhat_insights_log_cart_add>
|
49 |
</observers>
|
50 |
+
</checkout_cart_product_add_after>
|
51 |
</events>
|
52 |
</frontend>
|
53 |
<default>
|
app/design/frontend/base/default/layout/minewhat_insights.xml
CHANGED
@@ -10,19 +10,19 @@
|
|
10 |
<layout version="0.1.0">
|
11 |
|
12 |
<catalog_product_view>
|
13 |
-
<reference name="
|
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="
|
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="
|
26 |
<block type="minewhat_insights/event_checkout_onepage_success" name="minewhat_insights_event_checkout_onepage_success" />
|
27 |
</reference>
|
28 |
</checkout_onepage_success>
|
10 |
<layout version="0.1.0">
|
11 |
|
12 |
<catalog_product_view>
|
13 |
+
<reference name="head">
|
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="head">
|
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="head">
|
26 |
<block type="minewhat_insights/event_checkout_onepage_success" name="minewhat_insights_event_checkout_onepage_success" />
|
27 |
</reference>
|
28 |
</checkout_onepage_success>
|
app/design/frontend/base/default/template/minewhat/insights/event/catalog/product/view.phtml
CHANGED
@@ -7,7 +7,39 @@
|
|
7 |
*/
|
8 |
?>
|
9 |
<?php $_product = $this->getCurrentProduct() ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
<script type="text/javascript">
|
|
|
11 |
var _mwapi = _mwapi || [];
|
12 |
-
_mwapi.push(['trackEvent', 'product', '<?php echo $_product->getId() ?>']);
|
|
|
13 |
</script>
|
7 |
*/
|
8 |
?>
|
9 |
<?php $_product = $this->getCurrentProduct() ?>
|
10 |
+
<?php
|
11 |
+
$_associated_products = $this->getAssociatedProducts($_product);
|
12 |
+
$associated_ids = Array();
|
13 |
+
?>
|
14 |
+
<script type="text/mwdata">
|
15 |
+
//<![CDATA[
|
16 |
+
var _mwdata = _mwdata || {};
|
17 |
+
|
18 |
+
_mwdata['product'] = {};
|
19 |
+
_mwdata['product'].id = '<?php echo $_product->getId() ?>';
|
20 |
+
_mwdata['product'].sku = '<?php echo $_product->getSku() ?>';
|
21 |
+
_mwdata['product'].cat = '<?php echo json_encode($_product->getCategoryIds()) ?>';
|
22 |
+
_mwdata['product'].price = '<?php echo $_product->getPrice() ?>';
|
23 |
+
|
24 |
+
<?php if($_associated_products != null): ?>
|
25 |
+
_mwdata['associated_products'] = [];
|
26 |
+
<?php endif; ?>
|
27 |
+
|
28 |
+
<?php foreach($_associated_products as $simple_product):
|
29 |
+
$product_info = Array();
|
30 |
+
$associated_ids[] = $simple_product->getId();
|
31 |
+
$product_info['id'] = $simple_product->getId();
|
32 |
+
$product_info['sku'] = $simple_product->getSku();
|
33 |
+
$product_info['price'] = $simple_product->getPrice();
|
34 |
+
?>
|
35 |
+
_mwdata['associated_products'].push(<?php echo json_encode($product_info) ?>);
|
36 |
+
<?php endforeach; ?>
|
37 |
+
//]]>
|
38 |
+
</script>
|
39 |
+
|
40 |
<script type="text/javascript">
|
41 |
+
//<![CDATA[
|
42 |
var _mwapi = _mwapi || [];
|
43 |
+
_mwapi.push(['trackEvent', 'product', '<?php echo $_product->getId() ?>', '<?php echo json_encode($associated_ids) ?>']);
|
44 |
+
//]]>
|
45 |
</script>
|
app/design/frontend/base/default/template/minewhat/insights/event/catalog/product/view.phtml~
DELETED
@@ -1,13 +0,0 @@
|
|
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 |
-
var _mwapi = _mwapi || [];
|
12 |
-
_mwapi.push(['trackEvent', 'product', '<?php echo $_product->getId() ?>']);
|
13 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/minewhat/insights/event/checkout/cart/index.phtml
CHANGED
@@ -7,9 +7,11 @@
|
|
7 |
*/
|
8 |
?>
|
9 |
<?php $_product = $this->getProductToShoppingCart() ?>
|
10 |
-
<?php if ($_product && $_product
|
11 |
<script type="text/javascript">
|
|
|
12 |
var _mwapi = _mwapi || [];
|
13 |
-
_mwapi.push(['trackEvent', 'cart', '<?php echo $_product
|
|
|
14 |
</script>
|
15 |
<?php endif; ?>
|
7 |
*/
|
8 |
?>
|
9 |
<?php $_product = $this->getProductToShoppingCart() ?>
|
10 |
+
<?php if ($_product && $_product["id"]): ?>
|
11 |
<script type="text/javascript">
|
12 |
+
//<![CDATA[
|
13 |
var _mwapi = _mwapi || [];
|
14 |
+
_mwapi.push(['trackEvent', 'cart', '<?php echo $_product["id"] ?>', '<?php echo $_product["sku"] ?>', '<?php echo json_encode($_product["parentId"]) ?>', '<?php echo json_encode($_product["bundle"]) ?>']);
|
15 |
+
//]]>
|
16 |
</script>
|
17 |
<?php endif; ?>
|
app/design/frontend/base/default/template/minewhat/insights/event/checkout/cart/index.phtml~
DELETED
@@ -1,15 +0,0 @@
|
|
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 |
-
var _mwapi = _mwapi || [];
|
13 |
-
_mwapi.push(['trackEvent', 'cart', '<?php echo $_product->getId() ?>']);
|
14 |
-
</script>
|
15 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/minewhat/insights/event/checkout/onepage/success.phtml
CHANGED
@@ -8,9 +8,11 @@
|
|
8 |
?>
|
9 |
<?php if (($orderInfo = $this->getOrderInfo())): ?>
|
10 |
<script type="text/javascript">
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
14 |
<?php endforeach; ?>
|
|
|
15 |
</script>
|
16 |
<?php endif; ?>
|
8 |
?>
|
9 |
<?php if (($orderInfo = $this->getOrderInfo())): ?>
|
10 |
<script type="text/javascript">
|
11 |
+
//<![CDATA[
|
12 |
+
var _mwapi = _mwapi || [];.
|
13 |
+
<?php foreach ($orderInfo['items'] as $product): ?>
|
14 |
+
_mwapi.push(['trackEvent', 'buy', '<?php echo $product["id"] ?>', '<?php echo intval($product["qty"]) ?>', '<?php echo $product["sku"] ?>', '<?php echo $product["price"] ?>', '<?php echo json_encode($product["parentId"]) ?>', '<?php echo json_encode($product["bundle"]) ?>']);
|
15 |
<?php endforeach; ?>
|
16 |
+
//]]>
|
17 |
</script>
|
18 |
<?php endif; ?>
|
app/design/frontend/base/default/template/minewhat/insights/event/checkout/onepage/success.phtml~
DELETED
@@ -1,16 +0,0 @@
|
|
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 |
-
var _mwapi = _mwapi || [];
|
12 |
-
<?php foreach ($orderInfo->getItems() as $product): ?>
|
13 |
-
_mwapi.push(['trackEvent', 'buy', '<?php echo $product->getId() ?>', '<?php echo intval($product->getQty()) ?>']);
|
14 |
-
<?php endforeach; ?>
|
15 |
-
</script>
|
16 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/default/default/layout/minewhat_insights.xml
CHANGED
@@ -10,19 +10,19 @@
|
|
10 |
<layout version="0.1.0">
|
11 |
|
12 |
<catalog_product_view>
|
13 |
-
<reference name="
|
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="
|
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="
|
26 |
<block type="minewhat_insights/event_checkout_onepage_success" name="minewhat_insights_event_checkout_onepage_success" />
|
27 |
</reference>
|
28 |
</checkout_onepage_success>
|
10 |
<layout version="0.1.0">
|
11 |
|
12 |
<catalog_product_view>
|
13 |
+
<reference name="head">
|
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="head">
|
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="head">
|
26 |
<block type="minewhat_insights/event_checkout_onepage_success" name="minewhat_insights_event_checkout_onepage_success" />
|
27 |
</reference>
|
28 |
</checkout_onepage_success>
|
app/design/frontend/default/default/template/minewhat/insights/event/catalog/product/view.phtml
CHANGED
@@ -7,7 +7,39 @@
|
|
7 |
*/
|
8 |
?>
|
9 |
<?php $_product = $this->getCurrentProduct() ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
<script type="text/javascript">
|
|
|
11 |
var _mwapi = _mwapi || [];
|
12 |
-
_mwapi.push(['trackEvent', 'product', '<?php echo $_product->getId() ?>']);
|
|
|
13 |
</script>
|
7 |
*/
|
8 |
?>
|
9 |
<?php $_product = $this->getCurrentProduct() ?>
|
10 |
+
<?php
|
11 |
+
$_associated_products = $this->getAssociatedProducts($_product);
|
12 |
+
$associated_ids = Array();
|
13 |
+
?>
|
14 |
+
<script type="text/mwdata">
|
15 |
+
//<![CDATA[
|
16 |
+
var _mwdata = _mwdata || {};
|
17 |
+
|
18 |
+
_mwdata['product'] = {};
|
19 |
+
_mwdata['product'].id = '<?php echo $_product->getId() ?>';
|
20 |
+
_mwdata['product'].sku = '<?php echo $_product->getSku() ?>';
|
21 |
+
_mwdata['product'].cat = '<?php echo json_encode($_product->getCategoryIds()) ?>';
|
22 |
+
_mwdata['product'].price = '<?php echo $_product->getPrice() ?>';
|
23 |
+
|
24 |
+
<?php if($_associated_products != null): ?>
|
25 |
+
_mwdata['associated_products'] = [];
|
26 |
+
<?php endif; ?>
|
27 |
+
|
28 |
+
<?php foreach($_associated_products as $simple_product):
|
29 |
+
$product_info = Array();
|
30 |
+
$associated_ids[] = $simple_product->getId();
|
31 |
+
$product_info['id'] = $simple_product->getId();
|
32 |
+
$product_info['sku'] = $simple_product->getSku();
|
33 |
+
$product_info['price'] = $simple_product->getPrice();
|
34 |
+
?>
|
35 |
+
_mwdata['associated_products'].push(<?php echo json_encode($product_info) ?>);
|
36 |
+
<?php endforeach; ?>
|
37 |
+
//]]>
|
38 |
+
</script>
|
39 |
+
|
40 |
<script type="text/javascript">
|
41 |
+
//<![CDATA[
|
42 |
var _mwapi = _mwapi || [];
|
43 |
+
_mwapi.push(['trackEvent', 'product', '<?php echo $_product->getId() ?>', '<?php echo json_encode($associated_ids) ?>']);
|
44 |
+
//]]>
|
45 |
</script>
|
app/design/frontend/default/default/template/minewhat/insights/event/checkout/cart/index.phtml
CHANGED
@@ -7,9 +7,11 @@
|
|
7 |
*/
|
8 |
?>
|
9 |
<?php $_product = $this->getProductToShoppingCart() ?>
|
10 |
-
<?php if ($_product && $_product
|
11 |
<script type="text/javascript">
|
|
|
12 |
var _mwapi = _mwapi || [];
|
13 |
-
_mwapi.push(['trackEvent', 'cart', '<?php echo $_product
|
|
|
14 |
</script>
|
15 |
<?php endif; ?>
|
7 |
*/
|
8 |
?>
|
9 |
<?php $_product = $this->getProductToShoppingCart() ?>
|
10 |
+
<?php if ($_product && $_product["id"]): ?>
|
11 |
<script type="text/javascript">
|
12 |
+
//<![CDATA[
|
13 |
var _mwapi = _mwapi || [];
|
14 |
+
_mwapi.push(['trackEvent', 'cart', '<?php echo $_product["id"] ?>', '<?php echo $_product["sku"] ?>', '<?php echo json_encode($_product["parentId"]) ?>', '<?php echo json_encode($_product["bundle"]) ?>']);
|
15 |
+
//]]>
|
16 |
</script>
|
17 |
<?php endif; ?>
|
app/design/frontend/default/default/template/minewhat/insights/event/checkout/onepage/success.phtml
CHANGED
@@ -8,9 +8,11 @@
|
|
8 |
?>
|
9 |
<?php if (($orderInfo = $this->getOrderInfo())): ?>
|
10 |
<script type="text/javascript">
|
|
|
11 |
var _mwapi = _mwapi || [];
|
12 |
-
<?php foreach ($orderInfo
|
13 |
-
_mwapi.push(['trackEvent', 'buy', '<?php echo $product
|
14 |
<?php endforeach; ?>
|
|
|
15 |
</script>
|
16 |
<?php endif; ?>
|
8 |
?>
|
9 |
<?php if (($orderInfo = $this->getOrderInfo())): ?>
|
10 |
<script type="text/javascript">
|
11 |
+
//<![CDATA[
|
12 |
var _mwapi = _mwapi || [];
|
13 |
+
<?php foreach ($orderInfo['items'] as $product): ?>
|
14 |
+
_mwapi.push(['trackEvent', 'buy', '<?php echo $product["id"] ?>', '<?php echo intval($product["qty"]) ?>', '<?php echo $product["sku"] ?>', '<?php echo $product["price"] ?>', '<?php echo json_encode($product["parentId"]) ?>', '<?php echo json_encode($product["bundle"]) ?>']);
|
15 |
<?php endforeach; ?>
|
16 |
+
//]]>
|
17 |
</script>
|
18 |
<?php endif; ?>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>minewhat</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">osl</license>
|
7 |
<channel>community</channel>
|
@@ -10,9 +10,9 @@
|
|
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>2014-
|
14 |
-
<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="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.5</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>minewhat</name>
|
4 |
+
<version>1.0.2</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>2014-03-14</date>
|
14 |
+
<time>20:10:38</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="e1f3e3e9172a1c42d520f4dd870b54b2"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Index.php" hash="fafaf6953262ea2b0bc3092d538c30d1"/></dir><dir name="Onepage"><file name="Success.php" hash="0c314455071a35d765f8447ac7df6a44"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f55be36b0f6e46f0fccd3a2dee670ec3"/></dir><dir name="Model"><file name="Observer.php" hash="509eb21a74d2693e0aa24d7acd039aae"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f1fb655aac4dc7f71cadb6c7a7e816f8"/><file name="config.xml" hash="dfb8144831b6cee45bba4167076eb266"/><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="81061e0839af5d4f44ca0e4ae5383ab2"/></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="4f4f45eb87b55cf2de64188fcac7f13b"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="63393e384b3e8b8f76ccc74fc4db5dec"/></dir><dir name="onepage"><file name="success.phtml" hash="4614dfe802afe6e73b8707b536071912"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="layout"><file name="minewhat_insights.xml" hash="81061e0839af5d4f44ca0e4ae5383ab2"/></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="4f4f45eb87b55cf2de64188fcac7f13b"/></dir></dir><dir name="checkout"><dir name="cart"><file name="index.phtml" hash="63393e384b3e8b8f76ccc74fc4db5dec"/></dir><dir name="onepage"><file name="success.phtml" hash="4614dfe802afe6e73b8707b536071912"/></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>
|