Version Notes
Stable release. Has been tested for bugs, compatibility, and performance on Magento Community Edition 1.6+ and Magento Enterprise Edition 1.11+. This extension has been tested in a live environment, but as always please leave feedback if you run into any issues.
Download this release
Release Info
| Developer | Blue Acorn, Inc. |
| Extension | Blue_Acorn_Optimizely |
| Version | 1.0.1 |
| Comparing to | |
| See all releases | |
Version 1.0.1
- app/code/community/BlueAcorn/Optimizely/Block/CustomVariables.php +454 -0
- app/code/community/BlueAcorn/Optimizely/Block/System/Config/Explanation.php +91 -0
- app/code/community/BlueAcorn/Optimizely/Block/System/Config/Loginlink.php +90 -0
- app/code/community/BlueAcorn/Optimizely/Helper/Data.php +128 -0
- app/code/community/BlueAcorn/Optimizely/Model/DisallowDuplicates.php +37 -0
- app/code/community/BlueAcorn/Optimizely/Model/Enabledcheck.php +26 -0
- app/code/community/BlueAcorn/Optimizely/Model/Entity/Attribute.php +48 -0
- app/code/community/BlueAcorn/Optimizely/doc/changelog.txt +2 -0
- app/code/community/BlueAcorn/Optimizely/doc/design.txt +29 -0
- app/code/community/BlueAcorn/Optimizely/doc/makeTar.txt +6 -0
- app/code/community/BlueAcorn/Optimizely/etc/adminhtml.xml +22 -0
- app/code/community/BlueAcorn/Optimizely/etc/config.xml +42 -0
- app/code/community/BlueAcorn/Optimizely/etc/system.xml +131 -0
- app/design/frontend/base/default/layout/blueacorn/optimizely.xml +25 -0
- app/design/frontend/base/default/template/blueacorn/optimizely/customVariables.phtml +13 -0
- app/design/frontend/base/default/template/blueacorn/optimizely/sitewideJs.phtml +15 -0
- app/etc/modules/BlueAcorn_Optimizely.xml +20 -0
- package.xml +18 -0
app/code/community/BlueAcorn/Optimizely/Block/CustomVariables.php
ADDED
|
@@ -0,0 +1,454 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* @package BlueAcorn
|
| 4 |
+
* @subpackage Optimizely
|
| 5 |
+
* @version 1.0.1
|
| 6 |
+
* @author James Bruner
|
| 7 |
+
*/
|
| 8 |
+
class BlueAcorn_Optimizely_Block_CustomVariables extends Mage_Core_Block_Template
|
| 9 |
+
{
|
| 10 |
+
|
| 11 |
+
const NEW_LINE = "\n";
|
| 12 |
+
const TABBED_SPACE = "\t";
|
| 13 |
+
|
| 14 |
+
protected $_helper = null;
|
| 15 |
+
protected $_product = null;
|
| 16 |
+
protected $_customAttrName = null;
|
| 17 |
+
protected $_category = null;
|
| 18 |
+
protected $_cms = null;
|
| 19 |
+
protected $_checkout = null;
|
| 20 |
+
protected $_homepage = null;
|
| 21 |
+
protected $_success = null;
|
| 22 |
+
protected $_cart = null;
|
| 23 |
+
protected $_customer = null;
|
| 24 |
+
protected $_pageType = null;
|
| 25 |
+
protected $_numAttr = array('cost', 'weight', 'inventory');
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Get module helper
|
| 29 |
+
*
|
| 30 |
+
* @return Mage_Core_Helper_Abstract
|
| 31 |
+
*/
|
| 32 |
+
protected function _helper()
|
| 33 |
+
{
|
| 34 |
+
return $this->_helper = Mage::helper('optimizely');
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* Get current product
|
| 39 |
+
*
|
| 40 |
+
* @return mixed
|
| 41 |
+
*/
|
| 42 |
+
protected function _getProduct()
|
| 43 |
+
{
|
| 44 |
+
return $this->_product = Mage::registry('current_product');
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Get current category
|
| 49 |
+
*
|
| 50 |
+
* @return mixed
|
| 51 |
+
*/
|
| 52 |
+
protected function _getCategory()
|
| 53 |
+
{
|
| 54 |
+
return $this->_category = Mage::registry('current_category');
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Check if current page is CMS
|
| 59 |
+
*
|
| 60 |
+
* @return bool
|
| 61 |
+
*/
|
| 62 |
+
protected function _isCms()
|
| 63 |
+
{
|
| 64 |
+
return $this->_cms = $this->getRequest()->getRequestedRouteName() == 'cms';
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* Check if current page is Checkout
|
| 69 |
+
*
|
| 70 |
+
* @return bool
|
| 71 |
+
*/
|
| 72 |
+
protected function _isCheckout()
|
| 73 |
+
{
|
| 74 |
+
return $this->_checkout = $this->getRequest()->getRequestedRouteName() == 'checkout';
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* Check if current page is Homepage
|
| 79 |
+
*
|
| 80 |
+
* @return bool
|
| 81 |
+
*/
|
| 82 |
+
protected function _isHomepage()
|
| 83 |
+
{
|
| 84 |
+
if ($this->_isCms()) {
|
| 85 |
+
return $this->_homepage = $this->getRequest()->getRequestUri() == '/';
|
| 86 |
+
} else {
|
| 87 |
+
return null;
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Check if current page is Cart Page
|
| 93 |
+
*
|
| 94 |
+
* @return bool
|
| 95 |
+
*/
|
| 96 |
+
protected function _isCart()
|
| 97 |
+
{
|
| 98 |
+
if ($this->_isCheckout()) {
|
| 99 |
+
return $this->_cart = $this->getRequest()->getControllerName() == 'cart';
|
| 100 |
+
} else {
|
| 101 |
+
return null;
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
* Check if current page is Success Page
|
| 107 |
+
*
|
| 108 |
+
* @return bool
|
| 109 |
+
*/
|
| 110 |
+
protected function _isSuccessPage()
|
| 111 |
+
{
|
| 112 |
+
if ($this->_isCheckout()) {
|
| 113 |
+
return $this->_cart = $this->getRequest()->getActionName() == 'success';
|
| 114 |
+
} else {
|
| 115 |
+
return null;
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* Check if current page is Customer Page
|
| 121 |
+
*
|
| 122 |
+
* @return bool
|
| 123 |
+
*/
|
| 124 |
+
protected function _isCustomerPage()
|
| 125 |
+
{
|
| 126 |
+
|
| 127 |
+
return $this->_customer = $this->getRequest()->getRequestedRouteName() == 'customer';
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
protected function _getProductVariables()
|
| 132 |
+
{
|
| 133 |
+
$productVariables = "";
|
| 134 |
+
if ($this->_helper()->isEnabled() == 1) {
|
| 135 |
+
$product = $this->_getProduct();
|
| 136 |
+
if ($product) {
|
| 137 |
+
$productSku = $this->_editString($product->getSku());
|
| 138 |
+
$productName = $this->_editString($product->getName());
|
| 139 |
+
$productType = $this->_editString($product->getTypeId());
|
| 140 |
+
$attributeSetModel = Mage::getModel("eav/entity_attribute_set");
|
| 141 |
+
$attributeSetModel->load($product->getAttributeSetId());
|
| 142 |
+
$productPrice = round($product->getMinimalPrice(), 2);
|
| 143 |
+
if ($productType == "grouped") {
|
| 144 |
+
$aProductIds = $product->getTypeInstance()->getChildrenIds($product->getId());
|
| 145 |
+
$prices = array();
|
| 146 |
+
foreach ($aProductIds as $ids) {
|
| 147 |
+
foreach ($ids as $id) {
|
| 148 |
+
$aProduct = Mage::getSingleton('catalog/product')->load($id);
|
| 149 |
+
array_push($prices, $aProduct->getData('minimal_price'));
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
sort($prices, SORT_NUMERIC);
|
| 153 |
+
$productPrice = round($prices[0], 2);
|
| 154 |
+
} elseif ($productType == "bundle") {
|
| 155 |
+
$priceModel = $product->getPriceModel();
|
| 156 |
+
$productPrice = $priceModel->getTotalPrices($product, null, null, false);
|
| 157 |
+
$productPrice = $productPrice[0];
|
| 158 |
+
}
|
| 159 |
+
$this->_editString($productPrice);
|
| 160 |
+
|
| 161 |
+
//add the category to product data
|
| 162 |
+
$category = null;
|
| 163 |
+
if ($this->_product->getCategory()) {
|
| 164 |
+
$category = strtolower($this->_product->getCategory()->getName());
|
| 165 |
+
$productVariables .= "'category': '$category'," . self::NEW_LINE;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
//add the standard product variables (product type, sku, name, and price)
|
| 169 |
+
$productVariables .= self::TABBED_SPACE . "'product_type':'$productType'," . self::NEW_LINE;
|
| 170 |
+
$productVariables .= self::TABBED_SPACE . "'product_sku':'$productSku'," . self::NEW_LINE;
|
| 171 |
+
$productVariables .= self::TABBED_SPACE . "'product_name':'$productName'," . self::NEW_LINE;
|
| 172 |
+
$productVariables .= self::TABBED_SPACE . "'product_price':'$productPrice'," . self::NEW_LINE;
|
| 173 |
+
|
| 174 |
+
//Get the value from the custom attributes defined if they exist for current
|
| 175 |
+
//product
|
| 176 |
+
$customAttrOne = $this->_helper()->getCustomAttrOne();
|
| 177 |
+
$customAttrTwo = $this->_helper()->getCustomAttrTwo();
|
| 178 |
+
$customAttrThree = $this->_helper()->getCustomAttrThree();
|
| 179 |
+
$customAttrFour = $this->_helper()->getCustomAttrFour();
|
| 180 |
+
|
| 181 |
+
$attrOneOptionId = $product->getData($customAttrOne);
|
| 182 |
+
$attrTwoOptionId = $product->getData($customAttrTwo);
|
| 183 |
+
$attrThreeOptionId = $product->getData($customAttrThree);
|
| 184 |
+
$attrFourOptionId = $product->getData($customAttrFour);
|
| 185 |
+
|
| 186 |
+
if ($attrOneOptionId) {
|
| 187 |
+
if (in_array($customAttrOne, $this->_numAttr)) {
|
| 188 |
+
if ($attrOneOptionId != 0) {
|
| 189 |
+
$productVariables .= self::TABBED_SPACE . "'$customAttrOne': '" . $this->_calcNumberAttr($customAttrOne) . "'," . self::NEW_LINE;
|
| 190 |
+
}
|
| 191 |
+
} else {
|
| 192 |
+
$productVariables .= self::TABBED_SPACE . "'$customAttrOne': '" . $this->_editString($this->_getCustomAttributeValue($customAttrOne)) . "'," . self::NEW_LINE;
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
if ($attrTwoOptionId) {
|
| 197 |
+
if (in_array($customAttrTwo, $this->_numAttr)) {
|
| 198 |
+
if ($attrTwoOptionId != 0) {
|
| 199 |
+
$productVariables .= self::TABBED_SPACE . "'$customAttrTwo': '" . $this->_calcNumberAttr($customAttrTwo) . "'," . self::NEW_LINE;
|
| 200 |
+
}
|
| 201 |
+
} else {
|
| 202 |
+
$productVariables .= self::TABBED_SPACE . "'$customAttrTwo': '" . $this->_editString($this->_getCustomAttributeValue($customAttrTwo)) . "'," . self::NEW_LINE;
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
if ($attrThreeOptionId) {
|
| 207 |
+
if (in_array($customAttrThree, $this->_numAttr)) {
|
| 208 |
+
if ($attrThreeOptionId != 0) {
|
| 209 |
+
$productVariables .= self::TABBED_SPACE . "'$customAttrThree': '" . $this->_calcNumberAttr($customAttrThree) . "'," . self::NEW_LINE;
|
| 210 |
+
}
|
| 211 |
+
} else {
|
| 212 |
+
$productVariables .= self::TABBED_SPACE . "'$customAttrThree': '" . $this->_editString($this->_getCustomAttributeValue($customAttrThree)) . "'," . self::NEW_LINE;
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
if ($attrFourOptionId) {
|
| 217 |
+
if (in_array($customAttrFour, $this->_numAttr)) {
|
| 218 |
+
if ($attrFourOptionId != 0) {
|
| 219 |
+
$productVariables .= self::TABBED_SPACE . "'$customAttrFour': '" . $this->_calcNumberAttr($customAttrFour) . "'," . self::NEW_LINE;
|
| 220 |
+
}
|
| 221 |
+
} else {
|
| 222 |
+
$productVariables .= self::TABBED_SPACE . "'$customAttrFour': '" . $this->_editString($this->_getCustomAttributeValue($customAttrFour)) . "'," . self::NEW_LINE;
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
return $productVariables;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
* Returns the integer and string description of the number attributes selected on product pages
|
| 233 |
+
*
|
| 234 |
+
* @param string $numberAttr
|
| 235 |
+
* @return string
|
| 236 |
+
*/
|
| 237 |
+
protected function _calcNumberAttr($numberAttr)
|
| 238 |
+
{
|
| 239 |
+
$product = $this->_getProduct();
|
| 240 |
+
//If Age is the attribute chosen
|
| 241 |
+
if ($numberAttr && $numberAttr == 'news_from_date') {
|
| 242 |
+
$numberAttr = null;
|
| 243 |
+
$newFromDate = $product->getData('created_at');
|
| 244 |
+
$newFromDate = str_replace("-", "", substr($newFromDate, 0, strpos($newFromDate, " ")));
|
| 245 |
+
$today = date('Ymd');
|
| 246 |
+
if (is_numeric($newFromDate)) {
|
| 247 |
+
$numberAttr = $this->_editString(($today - $newFromDate));
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
//If Cost is the attribute chosen
|
| 251 |
+
if ($numberAttr && $numberAttr == 'cost') {
|
| 252 |
+
$numberAttr = null;
|
| 253 |
+
$cost = round($product->getData('cost'), 2);
|
| 254 |
+
if (is_numeric($cost)) {
|
| 255 |
+
$numberAttr = $this->_editString($cost);
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
//If Stock Remaining is the Attribute chosen
|
| 259 |
+
if ($numberAttr && $numberAttr == 'inventory') {
|
| 260 |
+
$numberAttr = null;
|
| 261 |
+
$qty = round(Mage::getSingleton('cataloginventory/stock_item')->loadByProduct($product)->getQty(), 0);
|
| 262 |
+
if (is_numeric($qty)) {
|
| 263 |
+
$numberAttr = $this->_editString($qty);
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
+
//If Weight is the attribute chosen
|
| 267 |
+
if ($numberAttr && $numberAttr == 'weight') {
|
| 268 |
+
$numberAttr = null;
|
| 269 |
+
$weight = round($product->getData('weight'), 2);
|
| 270 |
+
if (is_numeric($weight)) {
|
| 271 |
+
$numberAttr = $this->_editString($weight);
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
return $numberAttr;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
/**
|
| 278 |
+
* Find the value of the custom product attributes selected in system config
|
| 279 |
+
* if that are stored as int values
|
| 280 |
+
*
|
| 281 |
+
* @param $attribute
|
| 282 |
+
* @return string
|
| 283 |
+
*/
|
| 284 |
+
protected function _getCustomAttributeValue($attribute)
|
| 285 |
+
{
|
| 286 |
+
$product = $this->_getProduct();
|
| 287 |
+
if (is_numeric($product->getData($attribute))) {
|
| 288 |
+
$attributeText = $product->getAttributeText($attribute);
|
| 289 |
+
if ($attributeText) {
|
| 290 |
+
return $attributeText;
|
| 291 |
+
} else {
|
| 292 |
+
return round($product->getData($attribute), 2);
|
| 293 |
+
}
|
| 294 |
+
} else {
|
| 295 |
+
return $product->getData($attribute);
|
| 296 |
+
}
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
/**
|
| 300 |
+
* Trims each string within the variable definitions to 50 characters or less
|
| 301 |
+
* if the string is more than 50 characters. Also gets rid of characters that
|
| 302 |
+
* may cause JS errors like ", ', and ;
|
| 303 |
+
*
|
| 304 |
+
* @param $string
|
| 305 |
+
* @return string
|
| 306 |
+
*/
|
| 307 |
+
protected function _editString($string)
|
| 308 |
+
{
|
| 309 |
+
if (strlen($string) > 50) {
|
| 310 |
+
$newString = substr($string, 0, 50);
|
| 311 |
+
} else {
|
| 312 |
+
$newString = $string;
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
$badChars = array("\"", "'", ";", "\n");
|
| 316 |
+
foreach ($badChars as $char) {
|
| 317 |
+
if (strstr($newString, $char) !== FALSE) {
|
| 318 |
+
$newString = str_replace($badChars, '', $newString);
|
| 319 |
+
}
|
| 320 |
+
}
|
| 321 |
+
return $newString;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
/**
|
| 325 |
+
* Gets the frontend name of the custom attribute code being used
|
| 326 |
+
*
|
| 327 |
+
* @param string|integer|Mage_Core_Model_Config_Element $customAttr
|
| 328 |
+
* @return mixed
|
| 329 |
+
*/
|
| 330 |
+
protected function _customAttrName($customAttr)
|
| 331 |
+
{
|
| 332 |
+
return $this->_customAttrName = $this->_getProduct()->getResource()->getAttribute($customAttr)->getStoreLabel();
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
/**
|
| 336 |
+
* Gets the current category we're on and finds out category name, ID, and
|
| 337 |
+
* immediate parent if one exists.
|
| 338 |
+
*
|
| 339 |
+
* @return string
|
| 340 |
+
*/
|
| 341 |
+
protected function _getCategoryVariables()
|
| 342 |
+
{
|
| 343 |
+
$category = $this->_getCategory();
|
| 344 |
+
$categoryVariables = "";
|
| 345 |
+
if ($this->_helper()->isEnabled() == 1) {
|
| 346 |
+
if ($category && !$this->_getProduct()) {
|
| 347 |
+
$categoryName = $category->getName();
|
| 348 |
+
$categoryId = $category->getId();
|
| 349 |
+
|
| 350 |
+
//Retrieve Stores where isset category Path, returns comma separated list
|
| 351 |
+
$pathInStore = $category->getPathInStore();
|
| 352 |
+
//Reverse the list so the current category is at the bottom
|
| 353 |
+
$pathIds = array_reverse(explode(',', $pathInStore));
|
| 354 |
+
|
| 355 |
+
$categories = $category->getParentCategories();
|
| 356 |
+
$categoryTree = array();
|
| 357 |
+
foreach ($pathIds as $categoryId) {
|
| 358 |
+
//Push all category names into $categoryTree array
|
| 359 |
+
if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
|
| 360 |
+
array_push($categoryTree, $categories[$categoryId]->getName());
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
//See if there are any parent categories by seeing how many keys are stored
|
| 364 |
+
//in the $categoryTree array
|
| 365 |
+
$categoryTreeCount = count(array_keys($categoryTree));
|
| 366 |
+
//If the $categoryTree array does have more than 1 key, then pass the value
|
| 367 |
+
//of the second to last key into $parentCategory
|
| 368 |
+
if ($categoryTreeCount > 1) {
|
| 369 |
+
end($categoryTree);
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
$categoryVariables['name'] = strtolower($categoryName);
|
| 373 |
+
$categoryVariables['id'] = $categoryId;
|
| 374 |
+
}
|
| 375 |
+
}
|
| 376 |
+
return $categoryVariables;
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
protected function _getCustomVariables($html = null)
|
| 380 |
+
{
|
| 381 |
+
|
| 382 |
+
$this->_getPageType();
|
| 383 |
+
$html .= "<script type='text/javascript'>" . self::NEW_LINE;
|
| 384 |
+
$html .= "var optimizely_custom = {" . self::NEW_LINE . self::TABBED_SPACE;
|
| 385 |
+
$html .= "'page_type': '$this->_pageType'," . self::NEW_LINE . self::TABBED_SPACE;
|
| 386 |
+
//return custom targeting parameters here based on module config
|
| 387 |
+
|
| 388 |
+
//if category
|
| 389 |
+
if ($this->_category) {
|
| 390 |
+
$categoryVars = $this->_getCategoryVariables();
|
| 391 |
+
$html .= "'category': '$categoryVars[name]'," . self::NEW_LINE . self::TABBED_SPACE;
|
| 392 |
+
}
|
| 393 |
+
//if product
|
| 394 |
+
if ($this->_product) {
|
| 395 |
+
$html .= $this->_getProductVariables();
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
$html .= "}" . self::NEW_LINE;
|
| 399 |
+
$html .= "</script>" . self::NEW_LINE;
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
//if is success page, add the revenue tracking script
|
| 403 |
+
if ($this->_success == true && $this->_helper()->isRevenueTrackingEnabled()) {
|
| 404 |
+
$orderId = $_SESSION['checkout']['last_order_id'];
|
| 405 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
| 406 |
+
$revenueInCents = ($order->getGrandTotal() * 100);
|
| 407 |
+
$html .= sprintf("<script>%swindow.optimizely = window.optimizely || [];%swindow.optimizely.push(['trackEvent', 'success_page', %s]);%s</script>", self::NEW_LINE . self::TABBED_SPACE, self::NEW_LINE . self::TABBED_SPACE, $revenueInCents, self::NEW_LINE);
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
return $html;
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
protected function _getPageType()
|
| 414 |
+
{
|
| 415 |
+
|
| 416 |
+
// if on product page
|
| 417 |
+
if ($this->_getProduct()) {
|
| 418 |
+
$this->_pageType = 'product';
|
| 419 |
+
return true;
|
| 420 |
+
} //if category page
|
| 421 |
+
elseif ($this->_getCategory()) {
|
| 422 |
+
$this->_pageType = 'category';
|
| 423 |
+
return true;
|
| 424 |
+
} //if home page
|
| 425 |
+
elseif ($this->_isHomepage()) {
|
| 426 |
+
$this->_pageType = 'homepage';
|
| 427 |
+
return true;
|
| 428 |
+
} //if cms page
|
| 429 |
+
elseif ($this->_isCMS()) {
|
| 430 |
+
$this->_pageType = 'cms';
|
| 431 |
+
return true;
|
| 432 |
+
} //if checkout page
|
| 433 |
+
elseif ($this->_isCart()) {
|
| 434 |
+
$this->_pageType = 'cart';
|
| 435 |
+
return true;
|
| 436 |
+
} //if checkout page
|
| 437 |
+
elseif ($this->_isSuccessPage()) {
|
| 438 |
+
$this->_pageType = 'success';
|
| 439 |
+
$this->_success = true;
|
| 440 |
+
return true;
|
| 441 |
+
} //if checkout page
|
| 442 |
+
elseif ($this->_isCheckout()) {
|
| 443 |
+
$this->_pageType = 'checkout';
|
| 444 |
+
return true;
|
| 445 |
+
} //if checkout page
|
| 446 |
+
elseif ($this->_isCustomerPage()) {
|
| 447 |
+
$this->_pageType = 'customer';
|
| 448 |
+
return true;
|
| 449 |
+
} else {
|
| 450 |
+
return false;
|
| 451 |
+
}
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
}
|
app/code/community/BlueAcorn/Optimizely/Block/System/Config/Explanation.php
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* @package BlueAcorn
|
| 4 |
+
* @subpackage
|
| 5 |
+
* @version 1.0.1
|
| 6 |
+
* @author James Bruner
|
| 7 |
+
*/
|
| 8 |
+
class BlueAcorn_Optimizely_Block_System_Config_Explanation extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 9 |
+
{
|
| 10 |
+
|
| 11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 12 |
+
{
|
| 13 |
+
return 'These are for additional attributes you can set for product pages. These attributes will be included in your optimizely custom variable and be available for page targeting. Price, Product Type, Name, and SKU are not available to select as these attributes will automatically be added for every product.';
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Enter description here...
|
| 18 |
+
*
|
| 19 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 20 |
+
* @return string
|
| 21 |
+
*/
|
| 22 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 23 |
+
{
|
| 24 |
+
$id = $element->getHtmlId();
|
| 25 |
+
|
| 26 |
+
$useContainerId = $element->getData('use_container_id');
|
| 27 |
+
$html = '<tr id="row_' . $id . '">'
|
| 28 |
+
. '<td class="label"><label for="' . $id . '">' . $element->getLabel() . '</label></td>';
|
| 29 |
+
|
| 30 |
+
//$isDefault = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
|
| 31 |
+
$isMultiple = $element->getExtType() === 'multiple';
|
| 32 |
+
|
| 33 |
+
// replace [value] with [inherit]
|
| 34 |
+
$namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName());
|
| 35 |
+
|
| 36 |
+
$options = $element->getValues();
|
| 37 |
+
|
| 38 |
+
$addInheritCheckbox = false;
|
| 39 |
+
if ($element->getCanUseWebsiteValue()) {
|
| 40 |
+
$addInheritCheckbox = true;
|
| 41 |
+
$checkboxLabel = Mage::helper('adminhtml')->__('Use Website');
|
| 42 |
+
} elseif ($element->getCanUseDefaultValue()) {
|
| 43 |
+
$addInheritCheckbox = true;
|
| 44 |
+
$checkboxLabel = Mage::helper('adminhtml')->__('Use Default');
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
if ($addInheritCheckbox) {
|
| 48 |
+
$inherit = $element->getInherit() == 1 ? 'checked="checked"' : '';
|
| 49 |
+
if ($inherit) {
|
| 50 |
+
$element->setDisabled(true);
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
$html .= '<td class="value">';
|
| 55 |
+
$html .= $this->_getElementHtml($element);
|
| 56 |
+
if ($element->getComment()) {
|
| 57 |
+
$html .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
|
| 58 |
+
}
|
| 59 |
+
$html .= '</td>';
|
| 60 |
+
|
| 61 |
+
if ($addInheritCheckbox) {
|
| 62 |
+
|
| 63 |
+
$defText = $element->getDefaultValue();
|
| 64 |
+
if ($options) {
|
| 65 |
+
$defTextArr = array();
|
| 66 |
+
foreach ($options as $k => $v) {
|
| 67 |
+
if ($isMultiple) {
|
| 68 |
+
if (is_array($v['value']) && in_array($k, $v['value'])) {
|
| 69 |
+
$defTextArr[] = $v['label'];
|
| 70 |
+
}
|
| 71 |
+
} elseif ($v['value'] == $defText) {
|
| 72 |
+
$defTextArr[] = $v['label'];
|
| 73 |
+
break;
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
$defText = join(', ', $defTextArr);
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
$html .= '<td class="">';
|
| 81 |
+
if ($element->getHint()) {
|
| 82 |
+
$html .= '<div class="hint" >';
|
| 83 |
+
$html .= '<div style="display: none;">' . $element->getHint() . '</div>';
|
| 84 |
+
$html .= '</div>';
|
| 85 |
+
}
|
| 86 |
+
$html .= '</td>';
|
| 87 |
+
|
| 88 |
+
$html .= '</tr>';
|
| 89 |
+
return $html;
|
| 90 |
+
}
|
| 91 |
+
}
|
app/code/community/BlueAcorn/Optimizely/Block/System/Config/Loginlink.php
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* @package BlueAcorn
|
| 4 |
+
* @subpackage
|
| 5 |
+
* @version 1.0.1
|
| 6 |
+
* @author James Bruner
|
| 7 |
+
*/
|
| 8 |
+
class BlueAcorn_Optimizely_Block_System_Config_Loginlink extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 9 |
+
{
|
| 10 |
+
|
| 11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 12 |
+
{
|
| 13 |
+
return '<a href="http://optimizely.com" target="_blank">Optimizely Login/Signup</a>';
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Enter description here...
|
| 18 |
+
*
|
| 19 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 20 |
+
* @return string
|
| 21 |
+
*/
|
| 22 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 23 |
+
{
|
| 24 |
+
$id = $element->getHtmlId();
|
| 25 |
+
|
| 26 |
+
$useContainerId = $element->getData('use_container_id');
|
| 27 |
+
$html = '<tr id="row_' . $id . '">'
|
| 28 |
+
. '<td class="label"><label for="' . $id . '">' . $element->getLabel() . '</label></td>';
|
| 29 |
+
|
| 30 |
+
$isMultiple = $element->getExtType() === 'multiple';
|
| 31 |
+
|
| 32 |
+
// replace [value] with [inherit]
|
| 33 |
+
$namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName());
|
| 34 |
+
|
| 35 |
+
$options = $element->getValues();
|
| 36 |
+
|
| 37 |
+
$addInheritCheckbox = false;
|
| 38 |
+
if ($element->getCanUseWebsiteValue()) {
|
| 39 |
+
$addInheritCheckbox = true;
|
| 40 |
+
$checkboxLabel = Mage::helper('adminhtml')->__('Use Website');
|
| 41 |
+
} elseif ($element->getCanUseDefaultValue()) {
|
| 42 |
+
$addInheritCheckbox = true;
|
| 43 |
+
$checkboxLabel = Mage::helper('adminhtml')->__('Use Default');
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
if ($addInheritCheckbox) {
|
| 47 |
+
$inherit = $element->getInherit() == 1 ? 'checked="checked"' : '';
|
| 48 |
+
if ($inherit) {
|
| 49 |
+
$element->setDisabled(true);
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
$html .= '<td class="value">';
|
| 54 |
+
$html .= $this->_getElementHtml($element);
|
| 55 |
+
if ($element->getComment()) {
|
| 56 |
+
$html .= '<p class="note"><span>' . $element->getComment() . '</span></p>';
|
| 57 |
+
}
|
| 58 |
+
$html .= '</td>';
|
| 59 |
+
|
| 60 |
+
if ($addInheritCheckbox) {
|
| 61 |
+
|
| 62 |
+
$defText = $element->getDefaultValue();
|
| 63 |
+
if ($options) {
|
| 64 |
+
$defTextArr = array();
|
| 65 |
+
foreach ($options as $k => $v) {
|
| 66 |
+
if ($isMultiple) {
|
| 67 |
+
if (is_array($v['value']) && in_array($k, $v['value'])) {
|
| 68 |
+
$defTextArr[] = $v['label'];
|
| 69 |
+
}
|
| 70 |
+
} elseif ($v['value'] == $defText) {
|
| 71 |
+
$defTextArr[] = $v['label'];
|
| 72 |
+
break;
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
$defText = join(', ', $defTextArr);
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
$html .= '<td class="">';
|
| 80 |
+
if ($element->getHint()) {
|
| 81 |
+
$html .= '<div class="hint" >';
|
| 82 |
+
$html .= '<div style="display: none;">' . $element->getHint() . '</div>';
|
| 83 |
+
$html .= '</div>';
|
| 84 |
+
}
|
| 85 |
+
$html .= '</td>';
|
| 86 |
+
|
| 87 |
+
$html .= '</tr>';
|
| 88 |
+
return $html;
|
| 89 |
+
}
|
| 90 |
+
}
|
app/code/community/BlueAcorn/Optimizely/Helper/Data.php
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Methods that retrieve saved data in the module's system configuration
|
| 4 |
+
*
|
| 5 |
+
* @package BlueAcorn
|
| 6 |
+
* @subpackage Optimizely
|
| 7 |
+
* @version 1.0.1
|
| 8 |
+
* @author James Bruner
|
| 9 |
+
*/
|
| 10 |
+
class BlueAcorn_Optimizely_Helper_Data extends Mage_Core_Helper_Abstract
|
| 11 |
+
{
|
| 12 |
+
const CONFIG_PATH = 'optimizely/';
|
| 13 |
+
protected $config = null;
|
| 14 |
+
protected $defaultGroup = "settings";
|
| 15 |
+
protected $storedConfigs = array();
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Config meta method for getting gts config
|
| 19 |
+
*
|
| 20 |
+
* @param string $code
|
| 21 |
+
* @param string $group
|
| 22 |
+
* @return mixed
|
| 23 |
+
*/
|
| 24 |
+
public function getConfig($code = null, $group = null)
|
| 25 |
+
{
|
| 26 |
+
if ($code !== null) {
|
| 27 |
+
if ($group == null) {
|
| 28 |
+
$group = $this->defaultGroup;
|
| 29 |
+
}
|
| 30 |
+
if (!isset($this->storedConfigs[$code])) {
|
| 31 |
+
$this->config = Mage::getStoreConfig(self::CONFIG_PATH . "$group/$code");
|
| 32 |
+
} else {
|
| 33 |
+
$this->config = $this->storedConfigs[$code];
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
return $this->config;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Is Optimizely enabled
|
| 41 |
+
*
|
| 42 |
+
* @return boolean
|
| 43 |
+
*/
|
| 44 |
+
public function isEnabled()
|
| 45 |
+
{
|
| 46 |
+
return $this->getConfig('enabled', 'settings');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Is Revenue Tracking Enabled
|
| 51 |
+
*
|
| 52 |
+
* @return boolean
|
| 53 |
+
*/
|
| 54 |
+
public function isRevenueTrackingEnabled()
|
| 55 |
+
{
|
| 56 |
+
return $this->getConfig('revenue_tracking', 'settings');
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Sitewide JS from system config
|
| 61 |
+
*
|
| 62 |
+
* @return string
|
| 63 |
+
*/
|
| 64 |
+
public function getOptimizelyProjectCode()
|
| 65 |
+
{
|
| 66 |
+
if ($this->isEnabled() == 1) {
|
| 67 |
+
return $this->getConfig('optimizely_project_code', 'settings');
|
| 68 |
+
} else {
|
| 69 |
+
return null;
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Get first custom product attribute from config
|
| 75 |
+
*
|
| 76 |
+
* @return int
|
| 77 |
+
*/
|
| 78 |
+
public function getCustomAttrOne()
|
| 79 |
+
{
|
| 80 |
+
if ($this->isEnabled() == 1) {
|
| 81 |
+
return $this->getConfig('optimizely_custom_one', 'project_settings');
|
| 82 |
+
} else {
|
| 83 |
+
return null;
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Get second custom product attribute from config
|
| 89 |
+
*
|
| 90 |
+
* @return int
|
| 91 |
+
*/
|
| 92 |
+
public function getCustomAttrTwo()
|
| 93 |
+
{
|
| 94 |
+
if ($this->isEnabled() == 1) {
|
| 95 |
+
return $this->getConfig('optimizely_custom_two', 'project_settings');
|
| 96 |
+
} else {
|
| 97 |
+
return null;
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Get third custom product attribute from config
|
| 103 |
+
*
|
| 104 |
+
* @return int
|
| 105 |
+
*/
|
| 106 |
+
public function getCustomAttrThree()
|
| 107 |
+
{
|
| 108 |
+
if ($this->isEnabled() == 1) {
|
| 109 |
+
return $this->getConfig('optimizely_custom_three', 'project_settings');
|
| 110 |
+
} else {
|
| 111 |
+
return null;
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* Get fourth custom product attribute from config
|
| 117 |
+
*
|
| 118 |
+
* @return int
|
| 119 |
+
*/
|
| 120 |
+
public function getCustomAttrFour()
|
| 121 |
+
{
|
| 122 |
+
if ($this->isEnabled() == 1) {
|
| 123 |
+
return $this->getConfig('optimizely_custom_four', 'project_settings');
|
| 124 |
+
} else {
|
| 125 |
+
return null;
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
}
|
app/code/community/BlueAcorn/Optimizely/Model/DisallowDuplicates.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* TODO: Fix undefined index: value on line 23 when changing the value of an attribute on the store scope after default values are set.
|
| 4 |
+
* Makes sure the user doesn't select the same attribute twice.
|
| 5 |
+
*
|
| 6 |
+
* @package BlueAcorn
|
| 7 |
+
* @subpackage Optimizely
|
| 8 |
+
* @author James Bruner
|
| 9 |
+
*/
|
| 10 |
+
class BlueAcorn_Optimizely_Model_DisallowDuplicates extends Mage_Core_Model_Config_Data
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* @return Mage_Core_Model_Abstract
|
| 14 |
+
*/
|
| 15 |
+
protected function _beforeSave()
|
| 16 |
+
{
|
| 17 |
+
$groups = $this->getData('groups');
|
| 18 |
+
if (isset($groups['product_settings']['fields'])) {
|
| 19 |
+
$fields = $groups['product_settings']['fields'];
|
| 20 |
+
unset($fields['explanation']);
|
| 21 |
+
|
| 22 |
+
foreach ($fields as $searchKey => $searchField) {
|
| 23 |
+
$searchField = $searchField['value'];
|
| 24 |
+
foreach ($fields as $key => $field) {
|
| 25 |
+
$field = $field['value'];
|
| 26 |
+
if ($field && $field !== "" && $searchField && $searchField !== "") {
|
| 27 |
+
if ($searchKey != $key && $field == $searchField) {
|
| 28 |
+
Mage::throwException("Settings have not been saved. An attribute has been chosen twice. Please select only unique attributes.");
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
return parent::_beforeSave();
|
| 36 |
+
}
|
| 37 |
+
}
|
app/code/community/BlueAcorn/Optimizely/Model/Enabledcheck.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Sending a warning after save to tell the user they have not actually enabled
|
| 4 |
+
* the module so no settings will appear on the frontend.
|
| 5 |
+
*
|
| 6 |
+
* @package BlueAcorn
|
| 7 |
+
* @subpackage Optimizely
|
| 8 |
+
* @version 1.0.1
|
| 9 |
+
* @author James Bruner
|
| 10 |
+
*/
|
| 11 |
+
class BlueAcorn_Optimizely_Model_Enabledcheck extends Mage_Core_Model_Config_Data
|
| 12 |
+
{
|
| 13 |
+
/**
|
| 14 |
+
* Check to see if user has enabled the configuration, if not, warn them they have not
|
| 15 |
+
*
|
| 16 |
+
* @return Mage_Core_Model_Abstract|void
|
| 17 |
+
*/
|
| 18 |
+
protected function _afterSave()
|
| 19 |
+
{
|
| 20 |
+
$enabled = $this->getValue();
|
| 21 |
+
if ($enabled == null || $enabled == 0) {
|
| 22 |
+
return Mage::getSingleton('core/session')->addNotice(Mage::helper('adminhtml')->__('You have not enabled the Optimizely Extension. No data will appear on the frontend. Please enable to activate frontend Javascript output.'));
|
| 23 |
+
}
|
| 24 |
+
return parent::_afterSave();
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/community/BlueAcorn/Optimizely/Model/Entity/Attribute.php
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Creates the select values in the configuration by pulling all catalog product
|
| 4 |
+
* attributes from the Magento DB.
|
| 5 |
+
*
|
| 6 |
+
* @package BlueAcorn
|
| 7 |
+
* @subpackage Optimizely
|
| 8 |
+
* @version 1.0.1
|
| 9 |
+
* @author James Bruner
|
| 10 |
+
*/
|
| 11 |
+
class BlueAcorn_Optimizely_Model_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute
|
| 12 |
+
{
|
| 13 |
+
/**
|
| 14 |
+
* Options select for different types of custom text attributes
|
| 15 |
+
*
|
| 16 |
+
* @return array
|
| 17 |
+
*/
|
| 18 |
+
public function toOptionArray()
|
| 19 |
+
{
|
| 20 |
+
$eavEntityType = Mage::getModel('eav/entity_type')->loadByCode('catalog_product');
|
| 21 |
+
$attributes = $this->getCollection()->setEntityTypeFilter($eavEntityType->getId());
|
| 22 |
+
$excluded = array('sku', 'price', 'name');
|
| 23 |
+
$attributeOptions = array(
|
| 24 |
+
array('value' => 0, 'label' => Mage::helper('optimizely')->__('')),
|
| 25 |
+
);
|
| 26 |
+
$i = 1;
|
| 27 |
+
foreach ($attributes as $attribute) {
|
| 28 |
+
$code = $attribute['attribute_code'];
|
| 29 |
+
$label = $attribute['frontend_label'];
|
| 30 |
+
if (!in_array($code, $excluded)) {
|
| 31 |
+
if ($label !== null && $label !== "") {
|
| 32 |
+
array_push($attributeOptions, array('value' => $code, 'label' => Mage::helper('optimizely')->__($label)));
|
| 33 |
+
$i++;
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
uasort($attributeOptions, 'blueAcornOptimizelyModelEntityAttributeCompareFunction');
|
| 38 |
+
return $attributeOptions;
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
function blueAcornOptimizelyModelEntityAttributeCompareFunction($a, $b)
|
| 43 |
+
{
|
| 44 |
+
if ($a['label'] == $b['label']) {
|
| 45 |
+
return 0;
|
| 46 |
+
}
|
| 47 |
+
return ($a['label'] < $b['label']) ? -1 : 1;
|
| 48 |
+
}
|
app/code/community/BlueAcorn/Optimizely/doc/changelog.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
| 1 |
+
1.0.1
|
| 2 |
+
Initial development of module. Added system configuration Javascript variables for products, categories, and page types. Integration of sitewide script, revenue tracking, and page targeting (via optimizely_custom variable).
|
app/code/community/BlueAcorn/Optimizely/doc/design.txt
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* BlueAcorn Optimizely Magento Module
|
| 3 |
+
*
|
| 4 |
+
* @package BlueAcorn
|
| 5 |
+
* @subpackage Optimizely
|
| 6 |
+
* @version 1.0.1
|
| 7 |
+
* @author James Bruner
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
BlueAcorn Optimizely allows for an easy way to add necessary Optimizely.com
|
| 11 |
+
Javascript scripts and custom variables to pages of your Magento web store.
|
| 12 |
+
|
| 13 |
+
System Configuration:
|
| 14 |
+
The System Config is store scope specific so that you can enable the module on
|
| 15 |
+
one store of a multi-store Magento setup.
|
| 16 |
+
|
| 17 |
+
All that needs to be configured is your project code and your custom product attributes (if needed).
|
| 18 |
+
|
| 19 |
+
If the module is disabled, nothing will output on the frontend of your website.
|
| 20 |
+
|
| 21 |
+
The Sitewide Javascript is placed directly in the <head> tag,
|
| 22 |
+
and before the Google Analytics script. The optimizely custom variable is placed
|
| 23 |
+
above the sitewide Javascript code, and encapsulates all custom attributes.
|
| 24 |
+
Custom attribute variables defined in the system config will only appear on product
|
| 25 |
+
pages that have a value defined for that attribute.
|
| 26 |
+
|
| 27 |
+
If an admin user selects two of the same attribute, the configuration will not
|
| 28 |
+
be saved, and an error will be thrown telling the user to select unique
|
| 29 |
+
attributes for each custom value.
|
app/code/community/BlueAcorn/Optimizely/doc/makeTar.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
tar -czvf
|
| 2 |
+
BlueAcorn_Optimizely-1.0.5.tar.gz
|
| 3 |
+
app/code/community/BlueAcorn/Optimizely
|
| 4 |
+
app/etc/modules/BlueAcorn_Optimizely.xml
|
| 5 |
+
app/design/frontend/base/default/layout/blueacorn/optimizely.xml
|
| 6 |
+
app/design/frontend/base/default/template/blueacorn/optimizely
|
app/code/community/BlueAcorn/Optimizely/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<acl>
|
| 4 |
+
<resources>
|
| 5 |
+
<admin>
|
| 6 |
+
<children>
|
| 7 |
+
<system>
|
| 8 |
+
<children>
|
| 9 |
+
<config>
|
| 10 |
+
<children>
|
| 11 |
+
<optimizely module="optimizely">
|
| 12 |
+
<title>Optimizely</title>
|
| 13 |
+
</optimizely>
|
| 14 |
+
</children>
|
| 15 |
+
</config>
|
| 16 |
+
</children>
|
| 17 |
+
</system>
|
| 18 |
+
</children>
|
| 19 |
+
</admin>
|
| 20 |
+
</resources>
|
| 21 |
+
</acl>
|
| 22 |
+
</config>
|
app/code/community/BlueAcorn/Optimizely/etc/config.xml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<BlueAcorn_Optimizely>
|
| 5 |
+
<version>1.0.1</version>
|
| 6 |
+
</BlueAcorn_Optimizely>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<blocks>
|
| 10 |
+
<optimizely>
|
| 11 |
+
<class>BlueAcorn_Optimizely_Block</class>
|
| 12 |
+
</optimizely>
|
| 13 |
+
</blocks>
|
| 14 |
+
<helpers>
|
| 15 |
+
<optimizely>
|
| 16 |
+
<class>BlueAcorn_Optimizely_Helper</class>
|
| 17 |
+
</optimizely>
|
| 18 |
+
</helpers>
|
| 19 |
+
<models>
|
| 20 |
+
<optimizely>
|
| 21 |
+
<class>BlueAcorn_Optimizely_Model</class>
|
| 22 |
+
</optimizely>
|
| 23 |
+
</models>
|
| 24 |
+
</global>
|
| 25 |
+
<frontend>
|
| 26 |
+
<layout>
|
| 27 |
+
<updates>
|
| 28 |
+
<optimizely module="BlueAcorn_Optimizely">
|
| 29 |
+
<file>blueacorn/optimizely.xml</file>
|
| 30 |
+
</optimizely>
|
| 31 |
+
</updates>
|
| 32 |
+
</layout>
|
| 33 |
+
</frontend>
|
| 34 |
+
<default>
|
| 35 |
+
<optimizely>
|
| 36 |
+
<settings>
|
| 37 |
+
<enabled>0</enabled>
|
| 38 |
+
<optimizely_sitewide_script>Enter Javascript provided to you in your Optimizely account here.</optimizely_sitewide_script>
|
| 39 |
+
</settings>
|
| 40 |
+
</optimizely>
|
| 41 |
+
</default>
|
| 42 |
+
</config>
|
app/code/community/BlueAcorn/Optimizely/etc/system.xml
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<optimizely translate="label" module="optimizely">
|
| 5 |
+
<class>optimizely</class>
|
| 6 |
+
<label>Optimizely</label>
|
| 7 |
+
<tab>general</tab>
|
| 8 |
+
<frontend_type>text</frontend_type>
|
| 9 |
+
<sort_order>2000</sort_order>
|
| 10 |
+
<show_in_default>1</show_in_default>
|
| 11 |
+
<show_in_website>1</show_in_website>
|
| 12 |
+
<show_in_store>1</show_in_store>
|
| 13 |
+
<groups>
|
| 14 |
+
<settings translate="label">
|
| 15 |
+
<label>General Settings</label>
|
| 16 |
+
<frontend_type>text</frontend_type>
|
| 17 |
+
<sort_order>0</sort_order>
|
| 18 |
+
<show_in_default>1</show_in_default>
|
| 19 |
+
<show_in_website>1</show_in_website>
|
| 20 |
+
<show_in_store>1</show_in_store>
|
| 21 |
+
<expanded>1</expanded>
|
| 22 |
+
<fields>
|
| 23 |
+
<signup translate="label">
|
| 24 |
+
<label>Login or Signup</label>
|
| 25 |
+
<frontend_model>optimizely/system_config_loginlink</frontend_model>
|
| 26 |
+
<frontend_type>text</frontend_type>
|
| 27 |
+
<sort_order>0</sort_order>
|
| 28 |
+
<show_in_default>1</show_in_default>
|
| 29 |
+
<show_in_website>1</show_in_website>
|
| 30 |
+
<show_in_store>1</show_in_store>
|
| 31 |
+
</signup>
|
| 32 |
+
<enabled translate="label">
|
| 33 |
+
<backend_model>optimizely/enabledcheck</backend_model>
|
| 34 |
+
<label>Enabled</label>
|
| 35 |
+
<frontend_type>select</frontend_type>
|
| 36 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 37 |
+
<sort_order>10</sort_order>
|
| 38 |
+
<show_in_default>1</show_in_default>
|
| 39 |
+
<show_in_website>1</show_in_website>
|
| 40 |
+
<show_in_store>1</show_in_store>
|
| 41 |
+
</enabled>
|
| 42 |
+
<optimizely_project_code translate="label">
|
| 43 |
+
<label>Optimizely Project Code</label>
|
| 44 |
+
<frontend_type>textarea</frontend_type>
|
| 45 |
+
<sort_order>20</sort_order>
|
| 46 |
+
<comment><![CDATA[Please enter your Optimizely script here. Your Project Code is located on the Dashboard in your <a href="http://www.optimizely.com" target="_blank">Optimizely.com</a> account.]]></comment>
|
| 47 |
+
<show_in_default>1</show_in_default>
|
| 48 |
+
<show_in_website>1</show_in_website>
|
| 49 |
+
<show_in_store>1</show_in_store>
|
| 50 |
+
</optimizely_project_code>
|
| 51 |
+
<revenue_tracking translate="label">
|
| 52 |
+
<backend_model>optimizely/enabledcheck</backend_model>
|
| 53 |
+
<label>Enable Revenue Tracking</label>
|
| 54 |
+
<frontend_type>select</frontend_type>
|
| 55 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 56 |
+
<sort_order>30</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 |
+
</revenue_tracking>
|
| 61 |
+
</fields>
|
| 62 |
+
</settings>
|
| 63 |
+
|
| 64 |
+
<project_settings translate="label">
|
| 65 |
+
<label>Custom Variables</label>
|
| 66 |
+
<frontend_type>text</frontend_type>
|
| 67 |
+
<sort_order>10</sort_order>
|
| 68 |
+
<show_in_default>1</show_in_default>
|
| 69 |
+
<show_in_website>1</show_in_website>
|
| 70 |
+
<show_in_store>1</show_in_store>
|
| 71 |
+
<expanded>1</expanded>
|
| 72 |
+
<fields>
|
| 73 |
+
<explanation translate="label">
|
| 74 |
+
<label>What are Product Settings?</label>
|
| 75 |
+
<frontend_model>optimizely/system_config_explanation</frontend_model>
|
| 76 |
+
<frontend_type>text</frontend_type>
|
| 77 |
+
<sort_order>0</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 |
+
</explanation>
|
| 82 |
+
<optimizely_custom_one translate="label">
|
| 83 |
+
<label>Custom Variable</label>
|
| 84 |
+
<!--<backend_model>optimizely/disallowDuplicates</backend_model>-->
|
| 85 |
+
<source_model>optimizely/entity_attribute</source_model>
|
| 86 |
+
<frontend_type>select</frontend_type>
|
| 87 |
+
<sort_order>10</sort_order>
|
| 88 |
+
<comment>Please do not select the same attribute twice.</comment>
|
| 89 |
+
<show_in_default>1</show_in_default>
|
| 90 |
+
<show_in_website>1</show_in_website>
|
| 91 |
+
<show_in_store>1</show_in_store>
|
| 92 |
+
</optimizely_custom_one>
|
| 93 |
+
<optimizely_custom_two translate="label">
|
| 94 |
+
<label>Custom Variable</label>
|
| 95 |
+
<!--<backend_model>optimizely/disallowDuplicates</backend_model>-->
|
| 96 |
+
<source_model>optimizely/entity_attribute</source_model>
|
| 97 |
+
<frontend_type>select</frontend_type>
|
| 98 |
+
<sort_order>20</sort_order>
|
| 99 |
+
<comment>Please do not select the same attribute twice.</comment>
|
| 100 |
+
<show_in_default>1</show_in_default>
|
| 101 |
+
<show_in_website>1</show_in_website>
|
| 102 |
+
<show_in_store>1</show_in_store>
|
| 103 |
+
</optimizely_custom_two>
|
| 104 |
+
<optimizely_custom_three translate="label">
|
| 105 |
+
<label>Custom Variable</label>
|
| 106 |
+
<!--<backend_model>optimizely/disallowDuplicates</backend_model>-->
|
| 107 |
+
<source_model>optimizely/entity_attribute</source_model>
|
| 108 |
+
<frontend_type>select</frontend_type>
|
| 109 |
+
<sort_order>30</sort_order>
|
| 110 |
+
<comment>Please do not select the same attribute twice.</comment>
|
| 111 |
+
<show_in_default>1</show_in_default>
|
| 112 |
+
<show_in_website>1</show_in_website>
|
| 113 |
+
<show_in_store>1</show_in_store>
|
| 114 |
+
</optimizely_custom_three>
|
| 115 |
+
<optimizely_custom_four translate="label">
|
| 116 |
+
<label>Custom Variable</label>
|
| 117 |
+
<!--<backend_model>optimizely/disallowDuplicates</backend_model>-->
|
| 118 |
+
<source_model>optimizely/entity_attribute</source_model>
|
| 119 |
+
<frontend_type>select</frontend_type>
|
| 120 |
+
<sort_order>40</sort_order>
|
| 121 |
+
<comment>Please do not select the same attribute twice.</comment>
|
| 122 |
+
<show_in_default>1</show_in_default>
|
| 123 |
+
<show_in_website>1</show_in_website>
|
| 124 |
+
<show_in_store>1</show_in_store>
|
| 125 |
+
</optimizely_custom_four>
|
| 126 |
+
</fields>
|
| 127 |
+
</project_settings>
|
| 128 |
+
</groups>
|
| 129 |
+
</optimizely>
|
| 130 |
+
</sections>
|
| 131 |
+
</config>
|
app/design/frontend/base/default/layout/blueacorn/optimizely.xml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* This is the layout xml file for BlueAcorn Optimizely. It creates two
|
| 5 |
+
* blocks within a text_list block that output the sitewide optimizely script,
|
| 6 |
+
* and the page specific targeting variables.
|
| 7 |
+
*
|
| 8 |
+
* Author: James Bruner, Blue Acorn
|
| 9 |
+
* Version: 1.0.1
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
-->
|
| 13 |
+
<layout version="0.1.0">
|
| 14 |
+
<default>
|
| 15 |
+
<reference name="head">
|
| 16 |
+
<block type="core/text_list" name="optimizely" as="optimizely" before="-">
|
| 17 |
+
<block type="optimizely/customVariables" name="optimizely_customer_type"
|
| 18 |
+
as="optimizely_customer_type"
|
| 19 |
+
template="blueacorn/optimizely/customVariables.phtml"/>
|
| 20 |
+
<block type="core/template" name="optimizely_sidewide" as="optimizely_sidewide"
|
| 21 |
+
template="blueacorn/optimizely/sitewideJs.phtml"/>
|
| 22 |
+
</block>
|
| 23 |
+
</reference>
|
| 24 |
+
</default>
|
| 25 |
+
</layout>
|
app/design/frontend/base/default/template/blueacorn/optimizely/customVariables.phtml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* @package BlueAcorn
|
| 4 |
+
* @subpackage Optimizely
|
| 5 |
+
* @version 1.0.1
|
| 6 |
+
* @author James Bruner
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
$helper = Mage::helper('optimizely');
|
| 10 |
+
|
| 11 |
+
if($helper->isEnabled() == 1) {
|
| 12 |
+
echo $this->_getCustomVariables();
|
| 13 |
+
}
|
app/design/frontend/base/default/template/blueacorn/optimizely/sitewideJs.phtml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Displays the necessary sitewide Optimizely script in head
|
| 4 |
+
*
|
| 5 |
+
* @package BlueAcorn
|
| 6 |
+
* @subpackage Optimizely
|
| 7 |
+
* @version 1.0.1
|
| 8 |
+
* @author James Bruner
|
| 9 |
+
*/
|
| 10 |
+
?>
|
| 11 |
+
<?php
|
| 12 |
+
$helper = Mage::helper('optimizely');
|
| 13 |
+
if($helper->isEnabled() == 1) {
|
| 14 |
+
echo $helper->getOptimizelyProjectCode();
|
| 15 |
+
}
|
app/etc/modules/BlueAcorn_Optimizely.xml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Company: Blue Acorn
|
| 5 |
+
* Developer: James Bruner
|
| 6 |
+
* Version: 1.0.5
|
| 7 |
+
* Description: Blue Acorn Convert Experiments is an integration module that
|
| 8 |
+
* outputs necessary frontend JavaScript variables (automatic and user selected)
|
| 9 |
+
* based on Magento attributes. These variables are used in the user's
|
| 10 |
+
* Convert.com account to set up conversion testing.
|
| 11 |
+
*/
|
| 12 |
+
-->
|
| 13 |
+
<config>
|
| 14 |
+
<modules>
|
| 15 |
+
<BlueAcorn_Optimizely>
|
| 16 |
+
<active>true</active>
|
| 17 |
+
<codePool>community</codePool>
|
| 18 |
+
</BlueAcorn_Optimizely>
|
| 19 |
+
</modules>
|
| 20 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Blue_Acorn_Optimizely</name>
|
| 4 |
+
<version>1.0.1</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Optimizely by Blue Acorn is an easy-integration module that outputs the necessary frontend JavaScript used by Optimizely to perform conversion tests. Track engagement, clicks, conversions, sign ups, or anything else that matter to you and your business.</summary>
|
| 10 |
+
<description>Optimizely by Blue Acorn is an easy-integration module that outputs the necessary frontend JavaScript used by Optimizely to perform conversion tests. Track engagement, clicks, conversions, sign ups, or anything else that matter to you and your business. Optimizely's custom goal tracking provides an endless range of measurable actions that you can define. Just tell Optimizely what to measure, and we will do the rest. With the Optimizely by Blue Acorn module, tracking your revenue, conversion testing, and custom targeting is just a click away. Say goodbye ot technical bottlenecks and hello to actionable data! </description>
|
| 11 |
+
<notes>Stable release. Has been tested for bugs, compatibility, and performance on Magento Community Edition 1.6+ and Magento Enterprise Edition 1.11+. This extension has been tested in a live environment, but as always please leave feedback if you run into any issues.</notes>
|
| 12 |
+
<authors><author><name>Kevin Eichelberger</name><user>blueacorn</user><email>kevin@blueacorn.com</email></author><author><name>Robert Henderson</name><user>roberthenderson</user><email>robert@blueacorn.com</email></author><author><name>James Bruner</name><user>jamesbruner</user><email>james@blueacorn.com</email></author><author><name>Amanda Graham</name><user>amanda_graham</user><email>amanda@blueacorn.com</email></author></authors>
|
| 13 |
+
<date>2013-06-06</date>
|
| 14 |
+
<time>19:05:51</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="BlueAcorn"><dir name="Optimizely"><dir name="Block"><file name="CustomVariables.php" hash="71d1843ef0955cb07b43e9b24657b954"/><dir name="System"><dir name="Config"><file name="Explanation.php" hash="9cf3eaa26c1144286acab41e98b6df88"/><file name="Loginlink.php" hash="b3186284ad2e60ae0e584b2c805142d3"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a21cb3b648110d962462240f05babe4e"/></dir><dir name="Model"><file name="DisallowDuplicates.php" hash="f91ee33dd75e8233141a64b54931c498"/><file name="Enabledcheck.php" hash="51b9ee9ee7a1b404e54ea9940170534f"/><dir name="Entity"><file name="Attribute.php" hash="0ebee2094c6185994d74727f083549d7"/></dir></dir><dir name="doc"><file name="changelog.txt" hash="ecd075974660a151635624225c082432"/><file name="design.txt" hash="a2ce6f92d3f07021ebf134509878d892"/><file name="makeTar.txt" hash="ebaa691f85440a473d45e031f89f5166"/></dir><dir name="etc"><file name="adminhtml.xml" hash="22ed1e4e197ebe48499751260389af2a"/><file name="config.xml" hash="e33b3f474fe93fa2743949f81c22fc25"/><file name="system.xml" hash="69e63e3852e03818a80883fe9b57244d"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="blueacorn"><file name="optimizely.xml" hash="c4d61984f69f6c08643f599e750cd41d"/></dir></dir><dir name="template"><dir name="blueacorn"><dir name="optimizely"><file name="customVariables.phtml" hash="701a4e6c7ae0028c08dfe4afeee66ec5"/><file name="sitewideJs.phtml" hash="edb59d3a27bf88d30c1ff1adb138d898"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="BlueAcorn_Optimizely.xml" hash="006a9d4662ba063257eb368d6eb10621"/></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.1.0</min><max>5.4.13</max></php></required></dependencies>
|
| 18 |
+
</package>
|
