Version Notes
Melhora na captura de dados
Melhorias de performance
Bugfix de segurança
Download this release
Release Info
| Developer | Chaordic |
| Extension | Chaordic_Base |
| Version | 1.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.4 to 1.1.0
- app/code/community/Chaordic/.gitignore +0 -1
- app/code/community/Chaordic/Base/.DS_Store +0 -0
- app/code/community/Chaordic/Base/Block/Loader.php +0 -27
- app/code/community/Chaordic/Base/Block/Meta.php +0 -69
- app/code/community/Chaordic/Base/Helper/Data.php +0 -224
- app/code/community/Chaordic/Base/Model/.DS_Store +0 -0
- app/code/community/Chaordic/Base/Model/Catalog.php +0 -116
- app/code/community/Chaordic/Base/Model/Checkout.php +0 -289
- app/code/community/Chaordic/Base/Model/Cms.php +0 -28
- app/code/community/Chaordic/Base/Model/Customer.php +0 -39
- app/code/community/Chaordic/Base/Model/Installment.php +0 -20
- app/code/community/Chaordic/Base/Model/Meta.php +0 -39
- app/code/community/Chaordic/Base/Model/Paymentmethods.php +0 -24
- app/code/community/Chaordic/Base/Model/Product.php +0 -375
- app/code/community/Chaordic/Base/Model/Search.php +0 -73
- app/code/community/Chaordic/Base/Model/User.php +0 -200
- app/code/community/Chaordic/Base/controllers/RemoteController.php +0 -116
- app/code/community/Chaordic/Base/etc/config.xml +0 -82
- app/code/community/Chaordic/Base/etc/system.xml +0 -168
- app/design/frontend/base/default/layout/chaordic_base.xml +0 -176
- app/design/frontend/base/default/template/chaordic/loader.phtml +3 -2
- app/design/frontend/base/default/template/chaordic/meta.phtml +18 -7
- app/etc/modules/Chaordic_Base.xml +4 -1
- package.xml +14 -10
app/code/community/Chaordic/.gitignore
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
!*
|
|
|
app/code/community/Chaordic/Base/.DS_Store
DELETED
|
Binary file
|
app/code/community/Chaordic/Base/Block/Loader.php
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Block_Loader extends Mage_Core_Block_Template
|
| 10 |
-
{
|
| 11 |
-
public function _toHtml()
|
| 12 |
-
{
|
| 13 |
-
if (! Mage::helper('chaordic_base')->enabled()) {
|
| 14 |
-
return null;
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
$apiKey = Mage::helper('chaordic_base')->getApiKey();
|
| 18 |
-
|
| 19 |
-
return sprintf(
|
| 20 |
-
'<script async defer src="%1$s" data-apikey="%2$s"></script>',
|
| 21 |
-
'//static.chaordicsystems.com/static/loader.js',
|
| 22 |
-
$apiKey
|
| 23 |
-
);
|
| 24 |
-
}
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Block/Meta.php
DELETED
|
@@ -1,69 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Block_Meta extends Mage_Core_Block_Template
|
| 10 |
-
{
|
| 11 |
-
private $model;
|
| 12 |
-
|
| 13 |
-
public function routeModel()
|
| 14 |
-
{
|
| 15 |
-
if (! Mage::helper('chaordic_base')->enabled()) {
|
| 16 |
-
return null;
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
$context = $this->getData('context');
|
| 20 |
-
$modelProps = null;
|
| 21 |
-
|
| 22 |
-
switch ($context) {
|
| 23 |
-
case 'user':
|
| 24 |
-
$modelProps = Chaordic_Base_Model_User::getRouteProps();
|
| 25 |
-
break;
|
| 26 |
-
|
| 27 |
-
case 'customer':
|
| 28 |
-
$modelProps = Chaordic_Base_Model_Customer::getRouteProps();
|
| 29 |
-
break;
|
| 30 |
-
|
| 31 |
-
case 'cms_page':
|
| 32 |
-
case 'home':
|
| 33 |
-
$modelProps = Chaordic_Base_Model_Cms::getRouteProps();
|
| 34 |
-
break;
|
| 35 |
-
|
| 36 |
-
case 'catalog':
|
| 37 |
-
$modelProps = Chaordic_Base_Model_Catalog::getRouteProps();
|
| 38 |
-
break;
|
| 39 |
-
|
| 40 |
-
case 'product':
|
| 41 |
-
$modelProps = Chaordic_Base_Model_Product::getRouteProps();
|
| 42 |
-
break;
|
| 43 |
-
|
| 44 |
-
case 'cart':
|
| 45 |
-
case 'checkout':
|
| 46 |
-
case 'confirmation':
|
| 47 |
-
$modelProps = Chaordic_Base_Model_Checkout::getRouteProps($context);
|
| 48 |
-
break;
|
| 49 |
-
|
| 50 |
-
case 'search':
|
| 51 |
-
$modelProps = Chaordic_Base_Model_Search::getRouteProps();
|
| 52 |
-
break;
|
| 53 |
-
|
| 54 |
-
case 'customer':
|
| 55 |
-
$modelProps = Chaordic_Base_Model_Customer::getRouteProps();
|
| 56 |
-
break;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
if ( ! empty($modelProps) ) {
|
| 60 |
-
$meta = Mage::getSingleton('chaordic_base/meta');
|
| 61 |
-
foreach ($modelProps as $key => $value) {
|
| 62 |
-
$meta->addProp($key, $value);
|
| 63 |
-
}
|
| 64 |
-
}
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Helper/Data.php
DELETED
|
@@ -1,224 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Helper_Data extends Mage_Core_Helper_Abstract
|
| 10 |
-
{
|
| 11 |
-
|
| 12 |
-
const DEFAULT_INSTALLMENT_COUNT = 6;
|
| 13 |
-
const DEFAULT_INSTALLMENT_PRICE = 20;
|
| 14 |
-
|
| 15 |
-
public function enabled()
|
| 16 |
-
{
|
| 17 |
-
$apiKey = Mage::helper('chaordic_base')->getApiKey();
|
| 18 |
-
if (empty($apiKey)) {
|
| 19 |
-
return false;
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
return true;
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
public function setConfig($path, $value)
|
| 26 |
-
{
|
| 27 |
-
$model = Mage::getModel('core/config');
|
| 28 |
-
return $model->saveConfig($path, $value);
|
| 29 |
-
}
|
| 30 |
-
|
| 31 |
-
public function getApikey()
|
| 32 |
-
{
|
| 33 |
-
$config = Mage::getStoreConfig('chaordic_base/options/api_key');
|
| 34 |
-
|
| 35 |
-
if (empty($config)) {
|
| 36 |
-
return null;
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
return $config;
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
public function getSecretKey()
|
| 43 |
-
{
|
| 44 |
-
$config = Mage::getStoreConfig('chaordic_base/options/secret_key');
|
| 45 |
-
|
| 46 |
-
if (empty($config)) {
|
| 47 |
-
return null;
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
return $config;
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
public function getMaxInstallmentCount()
|
| 54 |
-
{
|
| 55 |
-
$config = Mage::getStoreConfig('chaordic_base/methods/installment_count');
|
| 56 |
-
|
| 57 |
-
if (empty($config)) {
|
| 58 |
-
$config = Mage::helper('chaordic_base')->DEFAULT_INSTALLMENT_COUNT;
|
| 59 |
-
self::setConfig('chaordic_base/methods/installment_count', $config);
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
return $config;
|
| 63 |
-
}
|
| 64 |
-
|
| 65 |
-
public function getMinInstallmentPrice()
|
| 66 |
-
{
|
| 67 |
-
$config = Mage::getStoreConfig('chaordic_base/methods/installment_price');
|
| 68 |
-
|
| 69 |
-
if (empty($config)) {
|
| 70 |
-
$config = Mage::helper('chaordic_base')->DEFAULT_INSTALLMENT_PRICE;
|
| 71 |
-
self::setConfig('chaordic_base/methods/installment_price', $config);
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
return $config;
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
/**
|
| 78 |
-
* Recebe um código de método de pagamento e retorna o nome da forma
|
| 79 |
-
* de pagamento para a integração.
|
| 80 |
-
* @param [type] $method [description]
|
| 81 |
-
* @return [type] [description]
|
| 82 |
-
*/
|
| 83 |
-
public function getPaymentMethodRelation($method)
|
| 84 |
-
{
|
| 85 |
-
$paymentMethods = Mage::getSingleton('payment/config')->getActiveMethods();
|
| 86 |
-
$chaordicMethods = array(
|
| 87 |
-
'bankslip' => 'Bank Slip',
|
| 88 |
-
'creditcard' => 'Credit Card',
|
| 89 |
-
'bankdeposit' => 'Bank Deposit',
|
| 90 |
-
'money' => 'Money',
|
| 91 |
-
'onlinepayment' => 'Online Payment',
|
| 92 |
-
'directdebit' => 'Direct Debit'
|
| 93 |
-
);
|
| 94 |
-
|
| 95 |
-
$methodName = null;
|
| 96 |
-
|
| 97 |
-
foreach ($chaordicMethods as $chaordicMethod => $title) {
|
| 98 |
-
$config = Mage::getStoreConfig('chaordic_base/methods/'.$chaordicMethod);
|
| 99 |
-
|
| 100 |
-
// Config for $method is not set
|
| 101 |
-
if (empty($config)) {
|
| 102 |
-
continue;
|
| 103 |
-
}
|
| 104 |
-
|
| 105 |
-
if (in_array($method, explode(',', $config))) {
|
| 106 |
-
$methodName = $title;
|
| 107 |
-
break;
|
| 108 |
-
}
|
| 109 |
-
}
|
| 110 |
-
|
| 111 |
-
return (!empty($methodName)) ? $methodName : 'Not Set';
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
/**
|
| 115 |
-
* Retorna o ID da página de referência para o produto Search
|
| 116 |
-
* @return [type] [description]
|
| 117 |
-
*/
|
| 118 |
-
public function getSearchPageId()
|
| 119 |
-
{
|
| 120 |
-
$config = Mage::getStoreConfig('chaordic_base/search/pageid');
|
| 121 |
-
return $config;
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
-
public function setSearchPageId($id)
|
| 125 |
-
{
|
| 126 |
-
self::setConfig('chaordic_base/search/pageid', $id);
|
| 127 |
-
return $id;
|
| 128 |
-
}
|
| 129 |
-
|
| 130 |
-
/**
|
| 131 |
-
* Retorna lista de códigos de atributos relacionados a um set de atributos.
|
| 132 |
-
*/
|
| 133 |
-
public function getCustomSetAttributes($attributeSetId)
|
| 134 |
-
{
|
| 135 |
-
// Carrega os atributos do set padrão.
|
| 136 |
-
$defaultSetId = Mage::getModel('catalog/product')->getDefaultAttributeSetId();
|
| 137 |
-
$defaultSetAttributes = array_map(function($at) {
|
| 138 |
-
return $at['code'];
|
| 139 |
-
}, Mage::getModel('catalog/product_attribute_api')->items($defaultSetId));
|
| 140 |
-
|
| 141 |
-
// Retorna os atributos do set, excluindo os atributos padrão.
|
| 142 |
-
return array_map(function($attr) {
|
| 143 |
-
if (!in_array($attr['code'], $defaultSetAttributes)) {
|
| 144 |
-
return $attr['code'];
|
| 145 |
-
}
|
| 146 |
-
}, Mage::getModel('catalog/product_attribute_api')->items($attributeSetId));
|
| 147 |
-
}
|
| 148 |
-
|
| 149 |
-
public function float($number, $decimal=2)
|
| 150 |
-
{
|
| 151 |
-
return (float) number_format($number, $decimal, '.', '');
|
| 152 |
-
}
|
| 153 |
-
|
| 154 |
-
public function protocol($url)
|
| 155 |
-
{
|
| 156 |
-
return str_replace(array('http:', 'https:'), '', $url);
|
| 157 |
-
}
|
| 158 |
-
|
| 159 |
-
public function date($str, $format='d/m/Y')
|
| 160 |
-
{
|
| 161 |
-
return date($format, strtotime($str));
|
| 162 |
-
}
|
| 163 |
-
|
| 164 |
-
public function locale()
|
| 165 |
-
{
|
| 166 |
-
$lang = null;
|
| 167 |
-
$header = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
| 168 |
-
|
| 169 |
-
/**
|
| 170 |
-
* Se o cabeçalho ACCEPT_LANGUAGE não for informado não podemos
|
| 171 |
-
* determinar a língua preferida.
|
| 172 |
-
*/
|
| 173 |
-
if (empty($header)) {
|
| 174 |
-
$lang = null;
|
| 175 |
-
|
| 176 |
-
/**
|
| 177 |
-
* Utiliza a classe Locale do pacote intl para determinar
|
| 178 |
-
* a língua preferida do usuário.
|
| 179 |
-
*/
|
| 180 |
-
} elseif (class_exists('Locale')) {
|
| 181 |
-
$lang = Locale::acceptFromHttp($header);
|
| 182 |
-
|
| 183 |
-
/**
|
| 184 |
-
* Por padrão retorna a primeira representação encontrada no
|
| 185 |
-
* cabeçalho. Não é o procedimento ideal, mas como fallback serve,
|
| 186 |
-
* pois retornará a primeira língua da lista de linguagens aceitas.
|
| 187 |
-
*/
|
| 188 |
-
} else {
|
| 189 |
-
$langs = explode(',', $header);
|
| 190 |
-
$lang = (!empty($langs[0])) ? $langs[0] : null;
|
| 191 |
-
}
|
| 192 |
-
|
| 193 |
-
return $lang;
|
| 194 |
-
}
|
| 195 |
-
|
| 196 |
-
public function remote($remote, $params)
|
| 197 |
-
{
|
| 198 |
-
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
| 199 |
-
$urlFormat = $baseUrl . 'index.php/chaordic/remote/%s/?%s';
|
| 200 |
-
|
| 201 |
-
return self::protocol(sprintf($urlFormat, $remote, http_build_query($params, '', '&')));
|
| 202 |
-
}
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
/**
|
| 206 |
-
* Cria a página de referência para o produto Search.
|
| 207 |
-
* @return [type] [description]
|
| 208 |
-
*/
|
| 209 |
-
public function createSearchPage()
|
| 210 |
-
{
|
| 211 |
-
$data = array(
|
| 212 |
-
'title' => 'Chaordic Systems search page template',
|
| 213 |
-
'root_template' => 'one_column',
|
| 214 |
-
'identifier' => 'chaordic_search_page',
|
| 215 |
-
'stores' => array(0),
|
| 216 |
-
'content' => '<div id="chaordic_search_block"></div>'
|
| 217 |
-
);
|
| 218 |
-
|
| 219 |
-
$page = Mage::getModel('cms/page')->setData($data)->save();
|
| 220 |
-
|
| 221 |
-
return $page->getId();
|
| 222 |
-
}
|
| 223 |
-
|
| 224 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Model/.DS_Store
DELETED
|
Binary file
|
app/code/community/Chaordic/Base/Model/Catalog.php
DELETED
|
@@ -1,116 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Model_Catalog
|
| 10 |
-
{
|
| 11 |
-
public function getRouteProps()
|
| 12 |
-
{
|
| 13 |
-
$helper = Mage::helper('chaordic_base');
|
| 14 |
-
$categories = array();
|
| 15 |
-
|
| 16 |
-
/**
|
| 17 |
-
* Identificamos a categoria atual, para a partir dela coletarmos
|
| 18 |
-
* informações das categorias pai.
|
| 19 |
-
* @var integer
|
| 20 |
-
*/
|
| 21 |
-
$category = Mage::registry('current_category');
|
| 22 |
-
$categories = self::getCategoryTree($category->getEntityId(), 'immediate');
|
| 23 |
-
|
| 24 |
-
/**
|
| 25 |
-
* Matriz de informações da categoria para composição
|
| 26 |
-
* da Chaordic Meta.
|
| 27 |
-
* @var array
|
| 28 |
-
*/
|
| 29 |
-
$catalog = array(
|
| 30 |
-
'name' => 'category'
|
| 31 |
-
, 'timestamp' => $helper->date('now', 'r')
|
| 32 |
-
, 'categories' => $categories
|
| 33 |
-
);
|
| 34 |
-
|
| 35 |
-
return array( 'page'=>$catalog );
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
/**
|
| 39 |
-
* Retorna árvore de categorias de uma determinada categoria
|
| 40 |
-
* @param integer $categoryId ID da categoria
|
| 41 |
-
* @param string $deep all para todas, immediate para os parents imediatos
|
| 42 |
-
* @return array
|
| 43 |
-
*/
|
| 44 |
-
public function getCategoryTree($categoryId, $deep='all')
|
| 45 |
-
{
|
| 46 |
-
$_category = Mage::getModel('catalog/category')->load($categoryId);
|
| 47 |
-
$categories = array();
|
| 48 |
-
|
| 49 |
-
// root category
|
| 50 |
-
$rootCategory = Mage::getModel('catalog/category')->load(
|
| 51 |
-
Mage::app()->getStore()->getRootCategoryId()
|
| 52 |
-
);
|
| 53 |
-
|
| 54 |
-
/**
|
| 55 |
-
* Adiciona a Root Category ao retorno.
|
| 56 |
-
*
|
| 57 |
-
* Até a versão 0.8.1 a Root aparecia no retorno.
|
| 58 |
-
* A partir da versão 0.8.2 omitimos a root category. Omitimos também
|
| 59 |
-
* o parent da categoria que possuir a root category como parent.
|
| 60 |
-
*/
|
| 61 |
-
// if (! empty($rootCategory)) {
|
| 62 |
-
// array_push($categories, array(
|
| 63 |
-
// 'name' => $rootCategory->getName()
|
| 64 |
-
// , 'id' => $rootCategory->getEntityId()
|
| 65 |
-
// ));
|
| 66 |
-
// } else {
|
| 67 |
-
// return;
|
| 68 |
-
// }
|
| 69 |
-
|
| 70 |
-
if (! empty($rootCategory)) {
|
| 71 |
-
$rootCategoryId = $rootCategory->getEntityId();
|
| 72 |
-
} else {
|
| 73 |
-
return null;
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
if ( ! empty($_category) ) {
|
| 77 |
-
$parents = $_category->getParentCategories();
|
| 78 |
-
foreach ($parents as $_parent) {
|
| 79 |
-
$parent = array(
|
| 80 |
-
'name' => $_parent->getName()
|
| 81 |
-
, 'id' => $_parent->getEntityId()
|
| 82 |
-
);
|
| 83 |
-
|
| 84 |
-
/**
|
| 85 |
-
* Informa toda a árvore de parents até a categoria root.
|
| 86 |
-
*/
|
| 87 |
-
if ($deep == 'all') {
|
| 88 |
-
$parentParents = $_parent->getParentCategories();
|
| 89 |
-
if ( ! empty($parentParents) ) {
|
| 90 |
-
foreach ($parentParents as $pp) {
|
| 91 |
-
if ($pp->getEntityId() != $parent['id']) {
|
| 92 |
-
$parent['parents'][] = $pp->getEntityId();
|
| 93 |
-
}
|
| 94 |
-
}
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
-
/**
|
| 98 |
-
* Informa apenas a categoria pai imediata
|
| 99 |
-
*/
|
| 100 |
-
} elseif ($deep == 'immediate') {
|
| 101 |
-
$_parentId = $_parent->getParentId();
|
| 102 |
-
|
| 103 |
-
// Omite o índice parents se este for a Root Category
|
| 104 |
-
if ($_parentId != $rootCategoryId) {
|
| 105 |
-
$parent['parents'] = array($_parentId);
|
| 106 |
-
}
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
array_push($categories, $parent);
|
| 110 |
-
}
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
return $categories;
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Model/Checkout.php
DELETED
|
@@ -1,289 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Model_Checkout
|
| 10 |
-
{
|
| 11 |
-
public function getRouteProps($context=null)
|
| 12 |
-
{
|
| 13 |
-
$helper = Mage::helper('chaordic_base');
|
| 14 |
-
$props = array();
|
| 15 |
-
|
| 16 |
-
/**
|
| 17 |
-
* Chama o método correspondente ao contexto informado na definição
|
| 18 |
-
* dos blocos em chaordic_onsite.xml.
|
| 19 |
-
*/
|
| 20 |
-
switch ($context) {
|
| 21 |
-
case "cart":
|
| 22 |
-
$props['cart'] = self::cartRoute();
|
| 23 |
-
// $props['transaction'] = self::confirmationRoute("100000010");
|
| 24 |
-
break;
|
| 25 |
-
|
| 26 |
-
case "checkout":
|
| 27 |
-
break;
|
| 28 |
-
|
| 29 |
-
case "confirmation":
|
| 30 |
-
$props['transaction'] = self::confirmationRoute();
|
| 31 |
-
break;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
/**
|
| 35 |
-
* Informações padrão da página
|
| 36 |
-
*/
|
| 37 |
-
$props['page'] = array(
|
| 38 |
-
'name' => $context,
|
| 39 |
-
'timestamp' => $helper->date('now', 'r')
|
| 40 |
-
);
|
| 41 |
-
|
| 42 |
-
return $props;
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
-
/**
|
| 46 |
-
* Processa as informações da rota cart.
|
| 47 |
-
* @return void
|
| 48 |
-
*/
|
| 49 |
-
public function cartRoute()
|
| 50 |
-
{
|
| 51 |
-
$helper = Mage::helper('chaordic_base');
|
| 52 |
-
$items = array();
|
| 53 |
-
|
| 54 |
-
// $quote = $this->_getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
| 55 |
-
// $cart = $this->_getModel('comprasecundaria/cart')->setQuote($quote)->getQuote();
|
| 56 |
-
|
| 57 |
-
/**
|
| 58 |
-
* Carrega model do carrinho da sessão.
|
| 59 |
-
*/
|
| 60 |
-
$session = Mage::getSingleton('checkout/session');
|
| 61 |
-
$quote = $session->getQuote();
|
| 62 |
-
$cartId = $session->getQuoteId();
|
| 63 |
-
$cartItems = $quote->getAllVisibleItems();
|
| 64 |
-
|
| 65 |
-
$items = self::getCartItemsList($cartItems);
|
| 66 |
-
|
| 67 |
-
return array(
|
| 68 |
-
'id' => $cartId
|
| 69 |
-
, 'items' => $items
|
| 70 |
-
);
|
| 71 |
-
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
public function confirmationRoute($orderId=null)
|
| 75 |
-
{
|
| 76 |
-
$helper = Mage::helper('chaordic_base');
|
| 77 |
-
$transaction = array();
|
| 78 |
-
|
| 79 |
-
/**
|
| 80 |
-
* Identificamos a compra que acabou de ser feita, para então
|
| 81 |
-
* carregarmos todos os dados relacionados a ela.
|
| 82 |
-
*/
|
| 83 |
-
if ($orderId === null) {
|
| 84 |
-
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
| 88 |
-
$orderData = $order->getData();
|
| 89 |
-
|
| 90 |
-
$payment = $order->getPayment();
|
| 91 |
-
$paymentData = $payment->getData();
|
| 92 |
-
$paymentAdditionalInfo = $payment->getAdditionalInformation();
|
| 93 |
-
|
| 94 |
-
$shipmentCollection = $order->getShipmentsCollection();
|
| 95 |
-
|
| 96 |
-
/**
|
| 97 |
-
* Order items.
|
| 98 |
-
*/
|
| 99 |
-
$orderItems = $order->getAllVisibleItems();
|
| 100 |
-
$items = self::getCartItemsList($orderItems);
|
| 101 |
-
|
| 102 |
-
/**
|
| 103 |
-
* Order payment.
|
| 104 |
-
*/
|
| 105 |
-
$orderCurrencyCode = $orderData['base_currency_code'];
|
| 106 |
-
$orderPaymentType = $helper->getPaymentMethodRelation($paymentData['method']);
|
| 107 |
-
|
| 108 |
-
/**
|
| 109 |
-
* Informações do tipo podem e vão variar conforme o método de pagamento
|
| 110 |
-
* selecionado. Não vejo outra forma senão programar os métodos de captura
|
| 111 |
-
* dessas informações para cada método conhecido. Caso algum cliente utilize
|
| 112 |
-
* um método diferente, teremos que atualizar o módulo para suportar o mesmo.
|
| 113 |
-
*/
|
| 114 |
-
$orderInstallmentCount = 1;
|
| 115 |
-
|
| 116 |
-
/**
|
| 117 |
-
* Order prices.
|
| 118 |
-
*/
|
| 119 |
-
$orderTotalPrice = $helper->float($orderData['grand_total'], 2);
|
| 120 |
-
$orderDiscount = $helper->float($orderData['discount_amount'], 2);
|
| 121 |
-
$orderServices = 0.00; // Como identificar? Quais serviços?
|
| 122 |
-
|
| 123 |
-
/**
|
| 124 |
-
* Order Shipping
|
| 125 |
-
*/
|
| 126 |
-
$orderTrackingNumbers = array();
|
| 127 |
-
foreach ($shipmentCollection as $shipment) {
|
| 128 |
-
foreach ($shipment->getAllTracks() as $track) {
|
| 129 |
-
array_push($orderTrackingNumbers, $track->getNumber());
|
| 130 |
-
}
|
| 131 |
-
}
|
| 132 |
-
|
| 133 |
-
$orderShipping = array(
|
| 134 |
-
'costs' => $helper->float($orderData['shipping_amount'])
|
| 135 |
-
// , 'method' => $orderData['shipping_description']
|
| 136 |
-
// , 'delivery_date' => '' // Informação futura, como informar?
|
| 137 |
-
// , 'tracking' => implode(', ', $orderTrackingNumbers)
|
| 138 |
-
);
|
| 139 |
-
|
| 140 |
-
/**
|
| 141 |
-
* Order Signature
|
| 142 |
-
*/
|
| 143 |
-
$orderSignature = self::transactionSignature($orderId, $items);
|
| 144 |
-
|
| 145 |
-
return array(
|
| 146 |
-
'id' => $orderId
|
| 147 |
-
, 'installment_count' => $orderInstallmentCount
|
| 148 |
-
, 'shipping' => $orderShipping
|
| 149 |
-
, 'services' => $orderServices
|
| 150 |
-
, 'discount' => $orderDiscount
|
| 151 |
-
, 'payment_type' => $orderPaymentType
|
| 152 |
-
// , 'payment_currency' => $orderCurrencyCode
|
| 153 |
-
, 'items' => $items
|
| 154 |
-
, 'signature' => $orderSignature
|
| 155 |
-
);
|
| 156 |
-
|
| 157 |
-
}
|
| 158 |
-
|
| 159 |
-
public function getCartItemsList($cartItems)
|
| 160 |
-
{
|
| 161 |
-
$helper = Mage::helper('chaordic_base');
|
| 162 |
-
$items = array();
|
| 163 |
-
$products = array();
|
| 164 |
-
|
| 165 |
-
/**
|
| 166 |
-
* Iteração pelos itens do carrinho, agrupando todos os ids de produtos
|
| 167 |
-
* para obter dados dos mesmos. Na mesma matriz armazenamos a quantidade
|
| 168 |
-
* do produto no carrinho, assim não precisaremos mais de $carItems.
|
| 169 |
-
*/
|
| 170 |
-
foreach ($cartItems as $item) {
|
| 171 |
-
$entityId = $item->getProductId();
|
| 172 |
-
$qty = ($item->getQty() !== null) ? $item->getQty() : $item->getQtyOrdered();
|
| 173 |
-
$type = $item->getProductType();
|
| 174 |
-
|
| 175 |
-
$itemId = null;
|
| 176 |
-
$itemSku = null;
|
| 177 |
-
$itemPrice = $item->getRowTotalInclTax() / $qty;
|
| 178 |
-
|
| 179 |
-
switch ($type) {
|
| 180 |
-
case 'configurable':
|
| 181 |
-
$itemProduct = $item->getProduct();
|
| 182 |
-
$options = $itemProduct->getTypeInstance(true)->getOrderOptions($itemProduct);
|
| 183 |
-
|
| 184 |
-
if (isset($options['info_buyRequest'])) {
|
| 185 |
-
$itemId = $options['info_buyRequest']['product'];
|
| 186 |
-
$itemSku = $options['simple_sku'];
|
| 187 |
-
} else {
|
| 188 |
-
$itemId = $entityId;
|
| 189 |
-
$itemSku = $item->getSku();
|
| 190 |
-
}
|
| 191 |
-
break;
|
| 192 |
-
|
| 193 |
-
case 'simple':
|
| 194 |
-
case 'grouped':
|
| 195 |
-
default:
|
| 196 |
-
$itemId = $entityId;
|
| 197 |
-
$itemSku = $item->getSku();
|
| 198 |
-
break;
|
| 199 |
-
}
|
| 200 |
-
|
| 201 |
-
$products[] = array(
|
| 202 |
-
'product' => array(
|
| 203 |
-
'id' => $itemId
|
| 204 |
-
, 'sku' => $itemSku
|
| 205 |
-
, 'price' => $helper->float($itemPrice)
|
| 206 |
-
// , 'type' => $type
|
| 207 |
-
),
|
| 208 |
-
'quantity' => $helper->float($qty)
|
| 209 |
-
);
|
| 210 |
-
}
|
| 211 |
-
|
| 212 |
-
// var_dump($products);
|
| 213 |
-
// exit;
|
| 214 |
-
|
| 215 |
-
// gc
|
| 216 |
-
unset($cartItems);
|
| 217 |
-
|
| 218 |
-
return $products;
|
| 219 |
-
|
| 220 |
-
/**
|
| 221 |
-
* Obtém informações dos produtos inseridos no carrinho.
|
| 222 |
-
*/
|
| 223 |
-
// $productCollection = Mage::getModel('catalog/product')
|
| 224 |
-
// ->getCollection()
|
| 225 |
-
// ->addAttributeToSelect('*') // Melhorar - E MUITO - essa seleção
|
| 226 |
-
// ->addAttributeToFilter('entity_id', array('in' => array_keys($products)))
|
| 227 |
-
// ->getItems();
|
| 228 |
-
|
| 229 |
-
// foreach ($productCollection as $product) {
|
| 230 |
-
// $id = $product->getEntityId();
|
| 231 |
-
|
| 232 |
-
// array_push($items, array(
|
| 233 |
-
// 'product' => array(
|
| 234 |
-
// 'id' => $product->getSku() // SKU DO PRODUTO PAI
|
| 235 |
-
// , 'sku' => 'SKU VARIACAO' // SKU DA VARIACAO
|
| 236 |
-
// , 'price' => $helper->float($product->getFinalPrice(), 2)
|
| 237 |
-
// )
|
| 238 |
-
// , 'quantity' => $products[$id]['qty']
|
| 239 |
-
// // , 'tags' => $product->getTags() - Exibe as meta keywords?
|
| 240 |
-
// )
|
| 241 |
-
// );
|
| 242 |
-
// }
|
| 243 |
-
// var_dump($items);
|
| 244 |
-
// exit;
|
| 245 |
-
//
|
| 246 |
-
// return $items;
|
| 247 |
-
}
|
| 248 |
-
|
| 249 |
-
public function transactionSignature($orderId, $items)
|
| 250 |
-
{
|
| 251 |
-
$helper = Mage::helper('chaordic_base');
|
| 252 |
-
$pieces = array();
|
| 253 |
-
|
| 254 |
-
/**
|
| 255 |
-
* OrderId
|
| 256 |
-
*/
|
| 257 |
-
array_push($pieces, $orderId);
|
| 258 |
-
|
| 259 |
-
/**
|
| 260 |
-
* Apikey
|
| 261 |
-
*/
|
| 262 |
-
$secretkey = $helper->getSecretKey();
|
| 263 |
-
array_push($pieces, $secretkey);
|
| 264 |
-
|
| 265 |
-
/**
|
| 266 |
-
* Items
|
| 267 |
-
*/
|
| 268 |
-
foreach ($items as $item) {
|
| 269 |
-
array_push(
|
| 270 |
-
$pieces,
|
| 271 |
-
implode(
|
| 272 |
-
',',
|
| 273 |
-
array(
|
| 274 |
-
$item['product']['id'],
|
| 275 |
-
$item['product']['sku'],
|
| 276 |
-
money_format('%.2n', $item['product']['price']),
|
| 277 |
-
$item['quantity']
|
| 278 |
-
)
|
| 279 |
-
)
|
| 280 |
-
);
|
| 281 |
-
}
|
| 282 |
-
|
| 283 |
-
// var_dump(implode(':', $pieces));
|
| 284 |
-
|
| 285 |
-
return md5(implode(':', $pieces));
|
| 286 |
-
|
| 287 |
-
}
|
| 288 |
-
|
| 289 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Model/Cms.php
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Model_Cms
|
| 10 |
-
{
|
| 11 |
-
public function getRouteProps()
|
| 12 |
-
{
|
| 13 |
-
$helper = Mage::helper('chaordic_base');
|
| 14 |
-
|
| 15 |
-
$cmsPageId = Mage::getSingleton('cms/page')->getIdentifier();
|
| 16 |
-
$homePageId = Mage::getStoreConfig(
|
| 17 |
-
'web/default/cms_home_page'
|
| 18 |
-
, Mage::app()->getStore()->getId()
|
| 19 |
-
);
|
| 20 |
-
|
| 21 |
-
$props['page'] = array(
|
| 22 |
-
'name' => ( $cmsPageId == $homePageId ) ? 'home' : 'other',
|
| 23 |
-
'timestamp' => $helper->date('now', 'r')
|
| 24 |
-
);
|
| 25 |
-
|
| 26 |
-
return $props;
|
| 27 |
-
}
|
| 28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Model/Customer.php
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Model_Customer
|
| 10 |
-
{
|
| 11 |
-
|
| 12 |
-
public function getRouteProps() {
|
| 13 |
-
|
| 14 |
-
$helper = Mage::helper('chaordic_base');
|
| 15 |
-
|
| 16 |
-
/**
|
| 17 |
-
* Rota atual do contexto My Account.
|
| 18 |
-
*
|
| 19 |
-
* No painel My Account várias telas de gestão da conta do usuário
|
| 20 |
-
* são agregadas, mesmo que nem todas sejam tratadas pelo modelo customer.
|
| 21 |
-
* Sales, Review, Tag, Wishlist, OAuth, Newsletter e Downloadable são as
|
| 22 |
-
* rotas possíveis.
|
| 23 |
-
*
|
| 24 |
-
* @todo Diferenciar tabs Account Information e Address Book, ambas identificadas
|
| 25 |
-
* como customer - a rota de fato é customer, podemos diferenciar a aba em si.
|
| 26 |
-
* @var [type]
|
| 27 |
-
*/
|
| 28 |
-
$route = Mage::app()->getFrontController()->getRequest()->getRouteName();
|
| 29 |
-
|
| 30 |
-
$props['page'] = array(
|
| 31 |
-
'name' => 'customer_' . $route,
|
| 32 |
-
'timestamp' => $helper->date('now', 'r')
|
| 33 |
-
);
|
| 34 |
-
|
| 35 |
-
return $props;
|
| 36 |
-
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Model/Installment.php
DELETED
|
@@ -1,20 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Model_Installment
|
| 10 |
-
{
|
| 11 |
-
public function toOptionArray() {
|
| 12 |
-
$installment_count = array();
|
| 13 |
-
for($i=1; $i<=12; $i++) {
|
| 14 |
-
array_push($installment_count, array('value'=>$i, 'label'=>$i.'x'));
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
return $installment_count;
|
| 18 |
-
}
|
| 19 |
-
}
|
| 20 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Model/Meta.php
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Model_Meta
|
| 10 |
-
{
|
| 11 |
-
private $props;
|
| 12 |
-
|
| 13 |
-
public function addProp($prop, $value)
|
| 14 |
-
{
|
| 15 |
-
$this->props[$prop] = $value;
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
public function getProp($prop)
|
| 19 |
-
{
|
| 20 |
-
if ( array_key_exists($prop, $this->props) ) {
|
| 21 |
-
return $this->props[$prop];
|
| 22 |
-
} else {
|
| 23 |
-
return null;
|
| 24 |
-
}
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
public function getProps()
|
| 28 |
-
{
|
| 29 |
-
return $this->props;
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
public function propExists($prop)
|
| 33 |
-
{
|
| 34 |
-
return array_key_exists($prop, $this->props);
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Model/Paymentmethods.php
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Model_Paymentmethods
|
| 10 |
-
{
|
| 11 |
-
public function toOptionArray()
|
| 12 |
-
{
|
| 13 |
-
$methods = array();
|
| 14 |
-
$payments = Mage::getSingleton('payment/config')->getActiveMethods();
|
| 15 |
-
|
| 16 |
-
foreach ($payments as $code => $model) {
|
| 17 |
-
$title = Mage::getStoreConfig('payment/'.$code.'/title');
|
| 18 |
-
array_push($methods, array('value'=>$code, 'label'=>$title));
|
| 19 |
-
}
|
| 20 |
-
|
| 21 |
-
return $methods;
|
| 22 |
-
}
|
| 23 |
-
}
|
| 24 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Model/Product.php
DELETED
|
@@ -1,375 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Model_Product
|
| 10 |
-
{
|
| 11 |
-
public function getRouteProps($productId=null, $remote=false)
|
| 12 |
-
{
|
| 13 |
-
$helper = Mage::helper('chaordic_base');
|
| 14 |
-
$props = array();
|
| 15 |
-
|
| 16 |
-
/**
|
| 17 |
-
* Identificamos o produto acessado.
|
| 18 |
-
*/
|
| 19 |
-
$productId = (is_null($productId)) ? Mage::app()->getRequest()->getParam('id') : $productId;
|
| 20 |
-
$product = Mage::getModel('catalog/product')->load($productId);
|
| 21 |
-
$productType = $product->getTypeId();
|
| 22 |
-
|
| 23 |
-
/**
|
| 24 |
-
* Retorna apenas a URL remota quando o acesso for pela página.
|
| 25 |
-
*/
|
| 26 |
-
if ($remote === false) {
|
| 27 |
-
|
| 28 |
-
/**
|
| 29 |
-
* Carrega a declaração simples para obter as categorias
|
| 30 |
-
* da página.
|
| 31 |
-
*/
|
| 32 |
-
$simple = self::getProductDeclaration($product);
|
| 33 |
-
$pageCategories = $simple['categories'];
|
| 34 |
-
|
| 35 |
-
$props['product'] = self::getProductRemoteDeclaration($productId);
|
| 36 |
-
|
| 37 |
-
} else {
|
| 38 |
-
/**
|
| 39 |
-
* Para todos os produtos, a declaração de produto
|
| 40 |
-
* simples deve ser enviada.
|
| 41 |
-
*/
|
| 42 |
-
$simple = self::getProductDeclaration($product);
|
| 43 |
-
|
| 44 |
-
switch ($productType) {
|
| 45 |
-
case "configurable":
|
| 46 |
-
$configurable = self::getProductSpecsDeclaration($product);
|
| 47 |
-
break;
|
| 48 |
-
|
| 49 |
-
case "grouped":
|
| 50 |
-
$kit = self::getProductGroupedKitDeclaration($product);
|
| 51 |
-
break;
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
$props['product'] = $simple;
|
| 55 |
-
$pageCategories = $props['product']['categories'];
|
| 56 |
-
|
| 57 |
-
if ( ! empty($configurable) ) {
|
| 58 |
-
$props['product'] = array_merge($props['product'], $configurable);
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
if ( ! empty($kit) ) {
|
| 62 |
-
$props['product'] = array_merge($props['product'], $kit);
|
| 63 |
-
}
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
/**
|
| 67 |
-
* Informações da página
|
| 68 |
-
*/
|
| 69 |
-
$props['page'] = array(
|
| 70 |
-
'name' => 'product',
|
| 71 |
-
'categories' => $pageCategories,
|
| 72 |
-
'timestamp' => $helper->date('now', 'r')
|
| 73 |
-
);
|
| 74 |
-
|
| 75 |
-
return $props;
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
/**
|
| 79 |
-
* Retorna o JSON de informações de um produto.
|
| 80 |
-
* O método é reutilizado para composição de packs de informação de produtos
|
| 81 |
-
* agrupados, pois estes são compostos por dois ou mais produtos. Assim, tanto
|
| 82 |
-
* um produto simples, configurável ou agrupado podem ser gerados pelo mesmo
|
| 83 |
-
* método.
|
| 84 |
-
*
|
| 85 |
-
* @param Mage_Catalog_Model_Product $product Modelo de produto.
|
| 86 |
-
* @return array
|
| 87 |
-
*/
|
| 88 |
-
public function getProductDeclaration(Mage_Catalog_Model_Product $product)
|
| 89 |
-
{
|
| 90 |
-
$helper = Mage::helper('chaordic_base');
|
| 91 |
-
$catalog = Mage::getSingleton('chaordic_base/catalog');
|
| 92 |
-
$model = Mage::getSingleton('chaordic_base/product');
|
| 93 |
-
|
| 94 |
-
$declaration = array();
|
| 95 |
-
$data = $product->getData();
|
| 96 |
-
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
| 97 |
-
$mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 98 |
-
|
| 99 |
-
/**
|
| 100 |
-
* Informação básica
|
| 101 |
-
*/
|
| 102 |
-
$declaration = array(
|
| 103 |
-
'id' => $product->getEntityId()
|
| 104 |
-
, 'name' => $data['name']
|
| 105 |
-
, 'description' => $data['description']
|
| 106 |
-
, 'url' => $helper->protocol($baseUrl . $data['url_path'])
|
| 107 |
-
, 'published' => $helper->date($data['created_at'], 'Y-m-d')
|
| 108 |
-
);
|
| 109 |
-
|
| 110 |
-
/**
|
| 111 |
-
* Brand
|
| 112 |
-
*/
|
| 113 |
-
$brand = $product->getAttributeText('manufacturer');
|
| 114 |
-
if (!empty($brand)) {
|
| 115 |
-
$declaration['brand'] = $brand;
|
| 116 |
-
}
|
| 117 |
-
|
| 118 |
-
/**
|
| 119 |
-
* Tags
|
| 120 |
-
*/
|
| 121 |
-
$tags = explode(',', trim($data['meta_keywords'], ','));
|
| 122 |
-
if (!empty($tags) and !empty($tags[0])) {
|
| 123 |
-
$declaration['tags'] = $tags;
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
/**
|
| 127 |
-
* Declaração de preços
|
| 128 |
-
*/
|
| 129 |
-
$prices = $model->getProductPricesDeclaration($product);
|
| 130 |
-
$declaration = array_merge($declaration, $prices);
|
| 131 |
-
|
| 132 |
-
/**
|
| 133 |
-
* Imagens
|
| 134 |
-
* Na documentação de integração não fica claro se devemos informar
|
| 135 |
-
* apenas a imagem principal ou toda a galeria de imagens, então
|
| 136 |
-
* informamos as imagens definidas como image, small_image e thumbnail.
|
| 137 |
-
*
|
| 138 |
-
* A partir da versão 0.8.2 optamos por informar apenas a imagem default.
|
| 139 |
-
*/
|
| 140 |
-
if ( isset($data['image']) ) {
|
| 141 |
-
$declaration['images']['default'] = $helper->protocol($product->getImageUrl());
|
| 142 |
-
}
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
/**
|
| 146 |
-
* Atributos adicionais
|
| 147 |
-
* Exibe os atributos customizados do produto. Carrega os grupos de atributos
|
| 148 |
-
* relacionados ao attribute_set.
|
| 149 |
-
*/
|
| 150 |
-
// Carrega informações do attribute set.
|
| 151 |
-
$attributeSetId = $product->getAttributeSetId();
|
| 152 |
-
$groupAttributesCodes = $helper->getCustomSetAttributes($attributeSetId);
|
| 153 |
-
$productAttributes = $product->getAttributes();
|
| 154 |
-
|
| 155 |
-
$declaration['details'] = array();
|
| 156 |
-
foreach ($productAttributes as $attr) {
|
| 157 |
-
if (
|
| 158 |
-
$attr->getIsVisibleOnFront() and
|
| 159 |
-
in_array($attr->getAttributeCode(), $groupAttributesCodes)
|
| 160 |
-
) {
|
| 161 |
-
$declaration['details'][$attr->getAttributeCode()] = $attr->getFrontend()->getValue($product);
|
| 162 |
-
}
|
| 163 |
-
}
|
| 164 |
-
|
| 165 |
-
if (empty($declaration['details'])) {
|
| 166 |
-
unset($declaration['details']);
|
| 167 |
-
}
|
| 168 |
-
|
| 169 |
-
/**
|
| 170 |
-
* Estoque
|
| 171 |
-
*/
|
| 172 |
-
$declaration['stock'] = $helper->float($product->getStockItem()->getQty());
|
| 173 |
-
$declaration['status'] = ( $product->getIsInStock() and $product->getIsSalable() ) ? 'available' : 'unavailable';
|
| 174 |
-
|
| 175 |
-
/**
|
| 176 |
-
* Categorias
|
| 177 |
-
*/
|
| 178 |
-
$categoryCollection = $product->getCategoryCollection();
|
| 179 |
-
$categories = array();
|
| 180 |
-
$uniqueCategories = array();
|
| 181 |
-
|
| 182 |
-
foreach ($categoryCollection as $category) {
|
| 183 |
-
$categoryTree = $catalog->getCategoryTree($category->getEntityId());
|
| 184 |
-
foreach ($categoryTree as $index) {
|
| 185 |
-
if ( ! in_array($index['id'], $uniqueCategories) ) {
|
| 186 |
-
array_push($uniqueCategories, $index['id']);
|
| 187 |
-
array_push($categories, $index);
|
| 188 |
-
}
|
| 189 |
-
}
|
| 190 |
-
}
|
| 191 |
-
|
| 192 |
-
$declaration['categories'] = $categories;
|
| 193 |
-
|
| 194 |
-
return $declaration;
|
| 195 |
-
}
|
| 196 |
-
|
| 197 |
-
/**
|
| 198 |
-
* Retorna árvore de variações de atributos do produto - cor, tamanho...
|
| 199 |
-
* @param Mage_Catalog_Model_Product $product Modelo do produto
|
| 200 |
-
* @return array
|
| 201 |
-
*/
|
| 202 |
-
public function getProductSpecsDeclaration($product)
|
| 203 |
-
{
|
| 204 |
-
$helper = Mage::helper('chaordic_base');
|
| 205 |
-
$model = Mage::getSingleton('chaordic_base/product');
|
| 206 |
-
|
| 207 |
-
$specs = array();
|
| 208 |
-
$skus = array();
|
| 209 |
-
|
| 210 |
-
if ($product->getTypeId() !== 'configurable') {
|
| 211 |
-
return false;
|
| 212 |
-
}
|
| 213 |
-
|
| 214 |
-
$productPrice = $model->getProductPricesDeclaration($product);
|
| 215 |
-
|
| 216 |
-
/**
|
| 217 |
-
* Identifica atributos utilizados para customização e reduz a matris
|
| 218 |
-
* para um objeto representável dos atributos que compões a customização
|
| 219 |
-
* do produto.
|
| 220 |
-
* Objeto specs.
|
| 221 |
-
*/
|
| 222 |
-
$attributes = $product->getTypeInstance()->getConfigurableAttributesAsArray();
|
| 223 |
-
$usedAttributes = array();
|
| 224 |
-
$usedAttributesLabels = array();
|
| 225 |
-
|
| 226 |
-
foreach ($attributes as $att) {
|
| 227 |
-
$attributeSpecs = array_map(function($e){
|
| 228 |
-
return $e['store_label'];
|
| 229 |
-
}, $att['values']);
|
| 230 |
-
|
| 231 |
-
$specs[$att['label']] = $attributeSpecs;
|
| 232 |
-
array_push($usedAttributes, array(
|
| 233 |
-
'label' => $att['label']
|
| 234 |
-
, 'code' => $att['attribute_code']
|
| 235 |
-
, 'values' => array_map(function($e){
|
| 236 |
-
return array($e['value_index'] => $e['store_label']);
|
| 237 |
-
}, $att['values'])
|
| 238 |
-
));
|
| 239 |
-
}
|
| 240 |
-
|
| 241 |
-
/**
|
| 242 |
-
* Identifica produtos filhos para compor skus.
|
| 243 |
-
*/
|
| 244 |
-
// $childs = $product->getTypeInstance()->getChildrenIds($product->getId());
|
| 245 |
-
|
| 246 |
-
// // Collection de produtos associados ao configurável
|
| 247 |
-
// $childCollection = $product
|
| 248 |
-
// ->getCollection()
|
| 249 |
-
// // ->addAttributeToSelect(implode(',', $attributesToSelect))
|
| 250 |
-
// ->addAttributeToSelect('*')
|
| 251 |
-
// ->addFieldToFilter('entity_id', array('in', $childs))
|
| 252 |
-
// ->load();
|
| 253 |
-
|
| 254 |
-
$configurable = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
|
| 255 |
-
$childCollection = $configurable->getUsedProductCollection()
|
| 256 |
-
->addAttributeToSelect('*')
|
| 257 |
-
->addFilterByRequiredOptions();
|
| 258 |
-
|
| 259 |
-
foreach ($childCollection as $child) {
|
| 260 |
-
$_child = $child->getData();
|
| 261 |
-
$_specs = array();
|
| 262 |
-
|
| 263 |
-
foreach ($usedAttributes as $att) {
|
| 264 |
-
$attValueCode = $_child[$att['code']];
|
| 265 |
-
$attValue = array_reduce($att['values'], function($v, $e) use ($attValueCode) {
|
| 266 |
-
return ( isset($e[$attValueCode]) ) ? $e[$attValueCode] : $v;
|
| 267 |
-
});
|
| 268 |
-
|
| 269 |
-
$_specs[$att['label']] = $attValue;
|
| 270 |
-
}
|
| 271 |
-
|
| 272 |
-
$sku = array(
|
| 273 |
-
'sku' => $_child['sku']
|
| 274 |
-
, 'specs' => $_specs
|
| 275 |
-
, 'status' => (
|
| 276 |
-
$_child['is_salable'] and
|
| 277 |
-
$_child['stock_item']->is_in_stock ) ? 'available' : 'unavailable'
|
| 278 |
-
);
|
| 279 |
-
|
| 280 |
-
/**
|
| 281 |
-
* Se o preço da variação for diferente do preço do produto,
|
| 282 |
-
* adiciona declaração de preços à declaração da variação.
|
| 283 |
-
*/
|
| 284 |
-
$prices = $model->getProductPricesDeclaration($child);
|
| 285 |
-
|
| 286 |
-
array_push($skus, array_merge($sku, $prices));
|
| 287 |
-
|
| 288 |
-
}
|
| 289 |
-
|
| 290 |
-
return array(
|
| 291 |
-
'specs' => $specs,
|
| 292 |
-
'skus' => $skus
|
| 293 |
-
);
|
| 294 |
-
}
|
| 295 |
-
|
| 296 |
-
/**
|
| 297 |
-
* Retorna árvore de produtos que compõe o kit.
|
| 298 |
-
* @param Mage_Catalog_Model_Product $product Modelo do produto
|
| 299 |
-
* @return array
|
| 300 |
-
*/
|
| 301 |
-
public function getProductGroupedKitDeclaration($product)
|
| 302 |
-
{
|
| 303 |
-
$associated = $product->getTypeInstance(true)
|
| 304 |
-
->getAssociatedProducts($product);
|
| 305 |
-
|
| 306 |
-
$kit = array();
|
| 307 |
-
|
| 308 |
-
if (!empty($associated)) foreach ($associated as $assoc) {
|
| 309 |
-
array_push($kit, self::getProductDeclaration($assoc));
|
| 310 |
-
}
|
| 311 |
-
|
| 312 |
-
return array(
|
| 313 |
-
'kit_products' => $kit
|
| 314 |
-
);
|
| 315 |
-
}
|
| 316 |
-
|
| 317 |
-
public function getProductPricesDeclaration(Mage_Catalog_Model_Product $product)
|
| 318 |
-
{
|
| 319 |
-
$helper = Mage::helper('chaordic_base');
|
| 320 |
-
$prices = array();
|
| 321 |
-
$data = $product->getData();
|
| 322 |
-
|
| 323 |
-
/**
|
| 324 |
-
* Preços.
|
| 325 |
-
*
|
| 326 |
-
* O preço promocional é informado como 'price', enquanto o preço original
|
| 327 |
-
* é informado como old_price. Não existindo um preço promocional, o preço
|
| 328 |
-
* original é informado como price.
|
| 329 |
-
*
|
| 330 |
-
* Nota: base_price pode não aparecer em todos os produtos - na verdade
|
| 331 |
-
* é provável que não aparece de modo algum.
|
| 332 |
-
*/
|
| 333 |
-
if ( isset($data['special_price']) ) {
|
| 334 |
-
$prices['price'] = $helper->float($data['special_price']);
|
| 335 |
-
$prices['old_price'] = $helper->float($data['price']);
|
| 336 |
-
} else {
|
| 337 |
-
$prices['price'] = $helper->float($data['price']);
|
| 338 |
-
}
|
| 339 |
-
|
| 340 |
-
$prices['base_price'] = $helper->float($data['cost']);
|
| 341 |
-
|
| 342 |
-
/**
|
| 343 |
-
* Parcelamento do produto, baseado em configurações do módulo
|
| 344 |
-
* (número de parcelas máximas e valor mínimo da parcela)
|
| 345 |
-
*/
|
| 346 |
-
$maxInstallmentCount = $helper->getMaxInstallmentCount();
|
| 347 |
-
$minInstallmentPrice = $helper->getMinInstallmentPrice();
|
| 348 |
-
|
| 349 |
-
$installmentCount = floor($prices['price'] / $minInstallmentPrice);
|
| 350 |
-
$installmentCount = ($installmentCount < 1) ? 1 : $installmentCount;
|
| 351 |
-
$installmentCount = ($installmentCount > $maxInstallmentCount) ? $maxInstallmentCount : $installmentCount;
|
| 352 |
-
|
| 353 |
-
$prices['installment'] = array(
|
| 354 |
-
'count' => (int) $installmentCount,
|
| 355 |
-
'price' => $helper->float($prices['price'] / $installmentCount)
|
| 356 |
-
);
|
| 357 |
-
|
| 358 |
-
return $prices;
|
| 359 |
-
}
|
| 360 |
-
|
| 361 |
-
/**
|
| 362 |
-
* Retorna declaração de product contendo apenas a URL remota.
|
| 363 |
-
* @param [type] $productId [description]
|
| 364 |
-
* @return [type] [description]
|
| 365 |
-
*/
|
| 366 |
-
public function getProductRemoteDeclaration($productId)
|
| 367 |
-
{
|
| 368 |
-
$helper = Mage::helper('chaordic_base');
|
| 369 |
-
|
| 370 |
-
return array(
|
| 371 |
-
'remote_url' => $helper->remote('product', array('product_id' => $productId))
|
| 372 |
-
);
|
| 373 |
-
}
|
| 374 |
-
|
| 375 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Model/Search.php
DELETED
|
@@ -1,73 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Model_Search
|
| 10 |
-
{
|
| 11 |
-
public function getRouteProps()
|
| 12 |
-
{
|
| 13 |
-
$helper = Mage::helper('chaordic_base');
|
| 14 |
-
$items = array();
|
| 15 |
-
|
| 16 |
-
/**
|
| 17 |
-
* Identificamos o termo pesquisado e os items retornados.
|
| 18 |
-
*/
|
| 19 |
-
$searchQuery = Mage::helper('catalogsearch')->getQueryText();
|
| 20 |
-
$searchResults = Mage::getModel('catalogsearch/layer')->getProductCollection();
|
| 21 |
-
|
| 22 |
-
foreach ($searchResults as $item) {
|
| 23 |
-
$productId = $item->getEntityId();
|
| 24 |
-
|
| 25 |
-
/**
|
| 26 |
-
* Consulta a visibilidade do produto, incluindo na matriz $items
|
| 27 |
-
* somente aqueles visíveis nos resultados de busca.
|
| 28 |
-
*
|
| 29 |
-
* Nota: Como resultados de pesquisa são retornados todos os produtos
|
| 30 |
-
* relacionados ao termo, mesmo aqueles que não seriam acessados diretamente
|
| 31 |
-
* (como é o caso de produtos simples associados a produtos configuráveis).
|
| 32 |
-
*
|
| 33 |
-
* Nota: o campo visibility retornado é um inteiro de 1 a 4, cujo definições
|
| 34 |
-
* estão na classe /app/code/core/Mage/Catalog/Model/Product/Visibility.php.
|
| 35 |
-
* O inteiro 1 represente produtos não visíveis, portanto checamos aqui
|
| 36 |
-
* se o valor de visibility é maior que 1 - visível em busca (2), visível
|
| 37 |
-
* em cata'logo (3) ou visível em ambos (4).
|
| 38 |
-
*/
|
| 39 |
-
$_product = Mage::getSingleton('catalog/product')
|
| 40 |
-
->getCollection()
|
| 41 |
-
->addAttributeToSelect('visibility')
|
| 42 |
-
->addFilter('entity_id', array('eq'=>$productId))
|
| 43 |
-
->getItems();
|
| 44 |
-
|
| 45 |
-
if ($_product[$productId]->getVisibility() > 1) {
|
| 46 |
-
array_push($items, array(
|
| 47 |
-
'id' => $productId
|
| 48 |
-
, 'sku' => $item->getSku()
|
| 49 |
-
, 'price' => $helper->float($item->getFinalPrice(), 2)
|
| 50 |
-
));
|
| 51 |
-
}
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
/**
|
| 55 |
-
* Informações padrão da página.
|
| 56 |
-
*/
|
| 57 |
-
$props['page'] = array(
|
| 58 |
-
'name' => 'search',
|
| 59 |
-
'timestamp' => $helper->date('now', 'r')
|
| 60 |
-
);
|
| 61 |
-
|
| 62 |
-
/**
|
| 63 |
-
* Informações de search.
|
| 64 |
-
*/
|
| 65 |
-
$props['search'] = array(
|
| 66 |
-
'query' => $searchQuery,
|
| 67 |
-
'items' => $items
|
| 68 |
-
);
|
| 69 |
-
|
| 70 |
-
return $props;
|
| 71 |
-
}
|
| 72 |
-
|
| 73 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/Model/User.php
DELETED
|
@@ -1,200 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_Model_User
|
| 10 |
-
{
|
| 11 |
-
public static function getRouteProps()
|
| 12 |
-
{
|
| 13 |
-
$session = Mage::getSingleton('customer/session', array('name'=>'frontend'));
|
| 14 |
-
|
| 15 |
-
/**
|
| 16 |
-
* Identificação do cliente presente na sessão.
|
| 17 |
-
* Carregamos o cliente, endereço padrão e subscrições nas newsletters
|
| 18 |
-
* do Magento.
|
| 19 |
-
*/
|
| 20 |
-
$customerId = $session->getId();
|
| 21 |
-
$customer = $session->getCustomer();
|
| 22 |
-
$customerEmail = $customer->getEmail();
|
| 23 |
-
|
| 24 |
-
// Zend_Debug::dump($customer);
|
| 25 |
-
|
| 26 |
-
/**
|
| 27 |
-
* Retorna apenas a URL remota quando estamos exibindo na página.
|
| 28 |
-
* A declaração completa do usuários só é retornada ao acessarmos
|
| 29 |
-
* pela URl remota.
|
| 30 |
-
*/
|
| 31 |
-
|
| 32 |
-
if (! empty($customerEmail)) {
|
| 33 |
-
return self::getUserRemoteDeclaration($customerId);
|
| 34 |
-
// ->getUserDeclaration($customer, $session);
|
| 35 |
-
} else {
|
| 36 |
-
return;
|
| 37 |
-
}
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
public function getUserDeclaration($customer, $session=null)
|
| 41 |
-
{
|
| 42 |
-
$helper = Mage::helper('chaordic_base');
|
| 43 |
-
|
| 44 |
-
/**
|
| 45 |
-
* Se $customer for um ID, carrega o usuário associado.
|
| 46 |
-
* Se não for um ID e também não for um objeto, no caso uma
|
| 47 |
-
* instância do modelo Customer, retorna null.
|
| 48 |
-
*/
|
| 49 |
-
if (is_int($customer)) {
|
| 50 |
-
$customer = Mage::getModel('customer/customer')->load($customer);
|
| 51 |
-
} elseif (! is_object($customer)) {
|
| 52 |
-
return null;
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
$customerId = $customer->getId();
|
| 56 |
-
|
| 57 |
-
$defaultAddress = $customer->getPrimaryBillingAddress();
|
| 58 |
-
$subscriptions = Mage::getModel('newsletter/subscriber')
|
| 59 |
-
->loadByEmail($customer->getEmail());
|
| 60 |
-
|
| 61 |
-
/**
|
| 62 |
-
* Composição do nome completo do usuário.
|
| 63 |
-
* @var [type]
|
| 64 |
-
*/
|
| 65 |
-
$customerName = implode(' ', array(
|
| 66 |
-
$customer->getFirstname(),
|
| 67 |
-
$customer->getLastname()
|
| 68 |
-
));
|
| 69 |
-
|
| 70 |
-
/**
|
| 71 |
-
* Email principal do usuário.
|
| 72 |
-
* @var [type]
|
| 73 |
-
*/
|
| 74 |
-
$customerEmail = $customer->getEmail();
|
| 75 |
-
|
| 76 |
-
/**
|
| 77 |
-
* Informação de subscrição nas newsletters do Magento.
|
| 78 |
-
* @var [type]
|
| 79 |
-
*/
|
| 80 |
-
if ( ! empty($subscriptions) ) {
|
| 81 |
-
$customerSubscription = $subscriptions->isSubscribed();
|
| 82 |
-
} else {
|
| 83 |
-
$customerSubscription = false;
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
if ( ! empty($defaultAddress) ) {
|
| 88 |
-
/**
|
| 89 |
-
* CEP informado no endereço de cobrança padrão.
|
| 90 |
-
* Nota: esse endereço só fica disponível após a primeira compra
|
| 91 |
-
* do cliente ou se o mesmo atualizar seus endereços no dashboard.
|
| 92 |
-
* @var [type]
|
| 93 |
-
*/
|
| 94 |
-
$customerDefaultZipcode = $defaultAddress->getPostcode();
|
| 95 |
-
|
| 96 |
-
/**
|
| 97 |
-
* País informado no endereço de cobrança padrão.
|
| 98 |
-
* Nota: esse endereço só fica disponível após a primeira compra
|
| 99 |
-
* do cliente ou se o mesmo atualizar seus endereços no dashboard.
|
| 100 |
-
* @var [type]
|
| 101 |
-
*/
|
| 102 |
-
$customerDefaultCountry = $defaultAddress->getCountryId();
|
| 103 |
-
|
| 104 |
-
} else {
|
| 105 |
-
$customerDefaultZipcode = null;
|
| 106 |
-
$customerDefaultCountry = null;
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
/**
|
| 110 |
-
* Tax/Vat do cliente (documento utilizado para faturamento).
|
| 111 |
-
* Nota: normalmente lojas brasileiras utilizam esse atributo para
|
| 112 |
-
* armazenar o CPF, pois é a identificação do cliente para cobrança
|
| 113 |
-
* de impostos que lojas americanas utilizam.
|
| 114 |
-
* @var [type]
|
| 115 |
-
*/
|
| 116 |
-
$customerTaxvat = str_replace(
|
| 117 |
-
array(' ', '.', '-', '/'),
|
| 118 |
-
'',
|
| 119 |
-
$customer->getTaxvat()
|
| 120 |
-
);
|
| 121 |
-
|
| 122 |
-
$customerTaxvat = ( empty($customerTaxvat) ) ? null : $customerTaxvat;
|
| 123 |
-
|
| 124 |
-
/**
|
| 125 |
-
* Gênero do cliente.
|
| 126 |
-
* Nota: Essa informação pode não estar disponível antes da primeira
|
| 127 |
-
* compra do cliente.
|
| 128 |
-
* @var [type]
|
| 129 |
-
*/
|
| 130 |
-
$customerGender = $customer->getAttribute('gender')->getSource()->getOptionText($customer->getGender());
|
| 131 |
-
$customerGender = ($customerGender == 'Male') ? 'M'
|
| 132 |
-
: ( ($customerGender == 'Female') ? 'F' : null );
|
| 133 |
-
|
| 134 |
-
/**
|
| 135 |
-
* Data de nascimento do cliente.
|
| 136 |
-
* Nota: Essa informação pode não estar disponível antes da primeira
|
| 137 |
-
* compra do cliente.
|
| 138 |
-
* @var [type]
|
| 139 |
-
*/
|
| 140 |
-
$customerDob = $helper->date($customer->getDob(), 'Y-m-d');
|
| 141 |
-
|
| 142 |
-
/**
|
| 143 |
-
* $authToken - chave pra obtenção de informações do usuário
|
| 144 |
-
* Informa o ID da sessão, pois embora não possamos retornar os dados
|
| 145 |
-
* do usuário a partir desse dado, podemos obter os dados do carrinho
|
| 146 |
-
* associado.
|
| 147 |
-
*/
|
| 148 |
-
$authToken = (! empty($session)) ? $session->getEncryptedSessionId() : null;
|
| 149 |
-
|
| 150 |
-
/**
|
| 151 |
-
* Idioma preferido do usuário.
|
| 152 |
-
* Utilizamos o idioma informado pelo navegador.
|
| 153 |
-
*/
|
| 154 |
-
$language = $helper->locale();
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
/**
|
| 158 |
-
* Matriz de informações do usuário para composição
|
| 159 |
-
* da Chaordic Meta.
|
| 160 |
-
* @var array
|
| 161 |
-
*/
|
| 162 |
-
$user = array(
|
| 163 |
-
'id' => $customerId
|
| 164 |
-
, 'name' => $customerName
|
| 165 |
-
, 'email' => $customerEmail
|
| 166 |
-
, 'allow_mail_marketing' => $customerSubscription
|
| 167 |
-
// , 'username' => $customerEmail
|
| 168 |
-
// , 'username' => $customerId
|
| 169 |
-
, 'nickname' => $customer->getFirstname()
|
| 170 |
-
, 'auth_token' => $authToken
|
| 171 |
-
);
|
| 172 |
-
|
| 173 |
-
// Informações condicionais
|
| 174 |
-
if (!empty($customerDob)) { $user['birthday'] = $customerDob; }
|
| 175 |
-
if (!empty($language)) { $user['language'] = $language; }
|
| 176 |
-
if (!empty($customerDefaultZipcode)) { $user['zipcode'] = $customerDefaultZipcode; }
|
| 177 |
-
if (!empty($customerDefaultCountry)) { $user['country'] = $customerDefaultCountry; }
|
| 178 |
-
if (!empty($customerGender)) { $user['gender'] = $customerGender; }
|
| 179 |
-
if (!empty($customerTaxvat)) { $user['document_id'] = $customerTaxvat; }
|
| 180 |
-
|
| 181 |
-
return array( 'user'=>$user );
|
| 182 |
-
}
|
| 183 |
-
|
| 184 |
-
/**
|
| 185 |
-
* Retorna declaração de user contendo apenas a URL remota.
|
| 186 |
-
* @param [type] $customerId [description]
|
| 187 |
-
* @return [type] [description]
|
| 188 |
-
*/
|
| 189 |
-
public function getUserRemoteDeclaration($customerId)
|
| 190 |
-
{
|
| 191 |
-
$helper = Mage::helper('chaordic_base');
|
| 192 |
-
|
| 193 |
-
return array(
|
| 194 |
-
'user' => array(
|
| 195 |
-
'remote_url' => $helper->remote('user', array('user_id' => $customerId))
|
| 196 |
-
)
|
| 197 |
-
);
|
| 198 |
-
}
|
| 199 |
-
|
| 200 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/controllers/RemoteController.php
DELETED
|
@@ -1,116 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* @category Chaordic
|
| 4 |
-
* @package Chaordic_Base
|
| 5 |
-
* @version 1.0.0
|
| 6 |
-
* @copyright Copyright (c) 2014 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
-
class Chaordic_Base_RemoteController extends Mage_Core_Controller_Front_Action
|
| 10 |
-
{
|
| 11 |
-
public function userAction()
|
| 12 |
-
{
|
| 13 |
-
$model = Mage::getModel('chaordic_base/user');
|
| 14 |
-
|
| 15 |
-
$requestParams = $this->getRequest()->getParams();
|
| 16 |
-
|
| 17 |
-
if (! empty($requestParams) and isset($requestParams['user_id'])) {
|
| 18 |
-
$userId = $requestParams['user_id'];
|
| 19 |
-
|
| 20 |
-
if (! is_numeric($userId)) {
|
| 21 |
-
return null;
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
$userDeclaration = $model->getUserDeclaration((int) $requestParams['user_id']);
|
| 25 |
-
|
| 26 |
-
} else {
|
| 27 |
-
$userDeclaration = $model->getRouteProps();
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
$this->getResponse()->setHeader('Content-type', 'application/json', true);
|
| 31 |
-
echo json_encode($userDeclaration['user']);
|
| 32 |
-
exit;
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
public function productAction()
|
| 36 |
-
{
|
| 37 |
-
$model = Mage::getModel('chaordic_base/product');
|
| 38 |
-
|
| 39 |
-
$requestParams = $this->getRequest()->getParams();
|
| 40 |
-
|
| 41 |
-
if (! empty($requestParams) and isset($requestParams['product_id'])) {
|
| 42 |
-
$userId = $requestParams['product_id'];
|
| 43 |
-
|
| 44 |
-
if (! is_numeric($userId)) {
|
| 45 |
-
return null;
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
$productDeclaration = $model->getRouteProps((int) $requestParams['product_id'], true);
|
| 49 |
-
|
| 50 |
-
} else {
|
| 51 |
-
exit;
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
$this->getResponse()->setHeader('Content-type', 'application/json', true);
|
| 55 |
-
echo json_encode($productDeclaration['product']);
|
| 56 |
-
exit;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
public function cartAction()
|
| 60 |
-
{
|
| 61 |
-
$checkout = Mage::getModel('chaordic_base/checkout');
|
| 62 |
-
|
| 63 |
-
$this->getResponse()->setHeader('Content-type', 'application/json', true);
|
| 64 |
-
echo json_encode($checkout->getRouteProps('cart'));
|
| 65 |
-
exit;
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
public function searchAction()
|
| 69 |
-
{
|
| 70 |
-
$helper = Mage::helper('chaordic_base');
|
| 71 |
-
$pageId = $helper->getSearchPageId();
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
/**
|
| 75 |
-
* Se o Id de página não estiver configurado,
|
| 76 |
-
* cria a página e armazena o ID na option.
|
| 77 |
-
*/
|
| 78 |
-
|
| 79 |
-
if (empty($pageId)) {
|
| 80 |
-
$pageId = $helper->createSearchPage();
|
| 81 |
-
$helper->setSearchPageId($pageId);
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
/**
|
| 86 |
-
* Carrega a URL da página configurada para o redirecionamento.
|
| 87 |
-
*/
|
| 88 |
-
|
| 89 |
-
$pageUrl = Mage::Helper('cms/page')->getPageUrl($pageId);
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
/**
|
| 93 |
-
* Se a URL nào for encontrada, provavelmente a página não existe.
|
| 94 |
-
* Nesse caso a página será criada e a URL carregada.
|
| 95 |
-
*/
|
| 96 |
-
|
| 97 |
-
if (empty($pageUrl)) {
|
| 98 |
-
$pageId = $helper->createSearchPage();
|
| 99 |
-
$helper->setSearchPageId($pageId);
|
| 100 |
-
|
| 101 |
-
$pageUrl = Mage::Helper('cms/page')->getPageUrl($pageId);
|
| 102 |
-
}
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
/**
|
| 106 |
-
* Redireciona para a página
|
| 107 |
-
*/
|
| 108 |
-
|
| 109 |
-
$response = Mage::app()->getResponse();
|
| 110 |
-
$response->setRedirect($pageUrl, 301);
|
| 111 |
-
$response->sendResponse();
|
| 112 |
-
exit;
|
| 113 |
-
}
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/etc/config.xml
DELETED
|
@@ -1,82 +0,0 @@
|
|
| 1 |
-
<?xml version="1.0"?>
|
| 2 |
-
<config>
|
| 3 |
-
<modules>
|
| 4 |
-
<Chaordic_Base>
|
| 5 |
-
<version>1.0.0</version>
|
| 6 |
-
<platform>ce</platform>
|
| 7 |
-
</Chaordic_Base>
|
| 8 |
-
</modules>
|
| 9 |
-
|
| 10 |
-
<global>
|
| 11 |
-
<blocks>
|
| 12 |
-
<chaordic_base>
|
| 13 |
-
<class>Chaordic_Base_Block</class>
|
| 14 |
-
</chaordic_base>
|
| 15 |
-
</blocks>
|
| 16 |
-
<models>
|
| 17 |
-
<chaordic_base>
|
| 18 |
-
<class>Chaordic_Base_Model</class>
|
| 19 |
-
<resourceModel>chaordic_base_mysql4</resourceModel>
|
| 20 |
-
</chaordic_base>
|
| 21 |
-
<chaordic_base_mysql4>
|
| 22 |
-
<class>Chaordic_Base_Model_Mysql4</class>
|
| 23 |
-
</chaordic_base_mysql4>
|
| 24 |
-
</models>
|
| 25 |
-
<helpers>
|
| 26 |
-
<chaordic_base>
|
| 27 |
-
<class>Chaordic_Base_Helper</class>
|
| 28 |
-
</chaordic_base>
|
| 29 |
-
</helpers>
|
| 30 |
-
</global>
|
| 31 |
-
|
| 32 |
-
<frontend>
|
| 33 |
-
<layout>
|
| 34 |
-
<updates>
|
| 35 |
-
<chaordic_base module="Chaordic_Base">
|
| 36 |
-
<file>chaordic_base.xml</file>
|
| 37 |
-
</chaordic_base>
|
| 38 |
-
</updates>
|
| 39 |
-
</layout>
|
| 40 |
-
<routers>
|
| 41 |
-
<chaordic_base>
|
| 42 |
-
<use>standard</use>
|
| 43 |
-
<args>
|
| 44 |
-
<module>Chaordic_Base</module>
|
| 45 |
-
<frontName>chaordic</frontName>
|
| 46 |
-
</args>
|
| 47 |
-
</chaordic_base>
|
| 48 |
-
</routers>
|
| 49 |
-
</frontend>
|
| 50 |
-
|
| 51 |
-
<adminhtml>
|
| 52 |
-
<acl>
|
| 53 |
-
<resources>
|
| 54 |
-
<admin>
|
| 55 |
-
<children>
|
| 56 |
-
<system>
|
| 57 |
-
<children>
|
| 58 |
-
<config>
|
| 59 |
-
<children>
|
| 60 |
-
<chaordic_base>
|
| 61 |
-
<title>Chaordic Systems</title>
|
| 62 |
-
</chaordic_base>
|
| 63 |
-
</children>
|
| 64 |
-
</config>
|
| 65 |
-
</children>
|
| 66 |
-
</system>
|
| 67 |
-
</children>
|
| 68 |
-
</admin>
|
| 69 |
-
</resources>
|
| 70 |
-
</acl>
|
| 71 |
-
</adminhtml>
|
| 72 |
-
|
| 73 |
-
<default>
|
| 74 |
-
<chaordic_base>
|
| 75 |
-
<options>
|
| 76 |
-
<api_key>magento</api_key>
|
| 77 |
-
<installment_count>6</installment_count>
|
| 78 |
-
<installment_price>20</installment_price>
|
| 79 |
-
</options>
|
| 80 |
-
</chaordic_base>
|
| 81 |
-
</default>
|
| 82 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Chaordic/Base/etc/system.xml
DELETED
|
@@ -1,168 +0,0 @@
|
|
| 1 |
-
<?xml version="1.0"?>
|
| 2 |
-
<config>
|
| 3 |
-
<tabs>
|
| 4 |
-
<chaordic translate="label" module="chaordic_base">
|
| 5 |
-
<label>Chaordic Systems</label>
|
| 6 |
-
<sort_order>99999</sort_order>
|
| 7 |
-
</chaordic>
|
| 8 |
-
</tabs>
|
| 9 |
-
|
| 10 |
-
<sections>
|
| 11 |
-
<chaordic_base translate="label" module="chaordic_base">
|
| 12 |
-
<label>Configurar integração</label>
|
| 13 |
-
<tab>chaordic</tab>
|
| 14 |
-
<frontend_type>text</frontend_type>
|
| 15 |
-
<sort_order>1000</sort_order>
|
| 16 |
-
<show_in_default>1</show_in_default>
|
| 17 |
-
<show_in_website>1</show_in_website>
|
| 18 |
-
<show_in_store>1</show_in_store>
|
| 19 |
-
|
| 20 |
-
<groups>
|
| 21 |
-
<options translate="label">
|
| 22 |
-
<label>Chaves de integração</label>
|
| 23 |
-
<frontend_type>text</frontend_type>
|
| 24 |
-
<sort_order>1</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 |
-
<expanded>true</expanded>
|
| 29 |
-
|
| 30 |
-
<fields>
|
| 31 |
-
<api_key>
|
| 32 |
-
<label>API Key</label>
|
| 33 |
-
<comment>Sua chave de integração com a Chaordic</comment>
|
| 34 |
-
<frontend_type>text</frontend_type>
|
| 35 |
-
<sort_order>1</sort_order>
|
| 36 |
-
<show_in_default>1</show_in_default>
|
| 37 |
-
<show_in_website>1</show_in_website>
|
| 38 |
-
<show_in_store>1</show_in_store>
|
| 39 |
-
</api_key>
|
| 40 |
-
<secret_key>
|
| 41 |
-
<label>Secret Key</label>
|
| 42 |
-
<comment>Chave secreta para autenticação da API Key</comment>
|
| 43 |
-
<frontend_type>text</frontend_type>
|
| 44 |
-
<sort_order>2</sort_order>
|
| 45 |
-
<show_in_default>1</show_in_default>
|
| 46 |
-
<show_in_website>1</show_in_website>
|
| 47 |
-
<show_in_store>1</show_in_store>
|
| 48 |
-
</secret_key>
|
| 49 |
-
</fields>
|
| 50 |
-
</options>
|
| 51 |
-
|
| 52 |
-
<methods translate="label">
|
| 53 |
-
<label>Métodos de pagamento</label>
|
| 54 |
-
<frontend_type>text</frontend_type>
|
| 55 |
-
<sort_order>2</sort_order>
|
| 56 |
-
<show_in_default>1</show_in_default>
|
| 57 |
-
<show_in_website>1</show_in_website>
|
| 58 |
-
<show_in_store>1</show_in_store>
|
| 59 |
-
<expanded>true</expanded>
|
| 60 |
-
|
| 61 |
-
<fields>
|
| 62 |
-
<installment_count>
|
| 63 |
-
<label>Número máximo de parcelas</label>
|
| 64 |
-
<comment>Número máximo de parcelas disponíveis para sua loja. Desconsidere formas de pagamento, informe um número global para sua loja.</comment>
|
| 65 |
-
<frontend_type>select</frontend_type>
|
| 66 |
-
<source_model>chaordic_base/installment</source_model>
|
| 67 |
-
<sort_order>0</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 |
-
</installment_count>
|
| 72 |
-
<installment_price>
|
| 73 |
-
<label>Valor mínimo de cada parcela</label>
|
| 74 |
-
<comment>Valor mínimo para cada parcela. Desconsidere formas de pagamento, informe um valor global para sua loja.</comment>
|
| 75 |
-
<frontend_type>text</frontend_type>
|
| 76 |
-
<sort_order>1</sort_order>
|
| 77 |
-
<show_in_default>1</show_in_default>
|
| 78 |
-
<show_in_website>1</show_in_website>
|
| 79 |
-
<show_in_store>1</show_in_store>
|
| 80 |
-
</installment_price>
|
| 81 |
-
|
| 82 |
-
<bankslip>
|
| 83 |
-
<label>Bank Slip</label>
|
| 84 |
-
<comment>Selecione as formas de pagamento que correspondam ao 'Bank Slip'.</comment>
|
| 85 |
-
<frontend_type>multiselect</frontend_type>
|
| 86 |
-
<source_model>chaordic_base/paymentmethods</source_model>
|
| 87 |
-
<sort_order>2</sort_order>
|
| 88 |
-
<show_in_default>1</show_in_default>
|
| 89 |
-
<show_in_website>1</show_in_website>
|
| 90 |
-
<show_in_store>1</show_in_store>
|
| 91 |
-
</bankslip>
|
| 92 |
-
<creditcard>
|
| 93 |
-
<label>Credit Card</label>
|
| 94 |
-
<comment>Selecione as formas de pagamento que correspondam ao 'Credit Card'.</comment>
|
| 95 |
-
<frontend_type>multiselect</frontend_type>
|
| 96 |
-
<source_model>chaordic_base/paymentmethods</source_model>
|
| 97 |
-
<sort_order>3</sort_order>
|
| 98 |
-
<show_in_default>1</show_in_default>
|
| 99 |
-
<show_in_website>1</show_in_website>
|
| 100 |
-
<show_in_store>1</show_in_store>
|
| 101 |
-
</creditcard>
|
| 102 |
-
<bankdeposit>
|
| 103 |
-
<label>Bank Deposit</label>
|
| 104 |
-
<comment>Selecione as formas de pagamento que correspondam ao 'Bank Deposit'.</comment>
|
| 105 |
-
<frontend_type>multiselect</frontend_type>
|
| 106 |
-
<source_model>chaordic_base/paymentmethods</source_model>
|
| 107 |
-
<sort_order>4</sort_order>
|
| 108 |
-
<show_in_default>1</show_in_default>
|
| 109 |
-
<show_in_website>1</show_in_website>
|
| 110 |
-
<show_in_store>1</show_in_store>
|
| 111 |
-
</bankdeposit>
|
| 112 |
-
<money>
|
| 113 |
-
<label>Money</label>
|
| 114 |
-
<comment>Selecione as formas de pagamento que correspondam ao 'Money'.</comment>
|
| 115 |
-
<frontend_type>multiselect</frontend_type>
|
| 116 |
-
<source_model>chaordic_base/paymentmethods</source_model>
|
| 117 |
-
<sort_order>5</sort_order>
|
| 118 |
-
<show_in_default>1</show_in_default>
|
| 119 |
-
<show_in_website>1</show_in_website>
|
| 120 |
-
<show_in_store>1</show_in_store>
|
| 121 |
-
</money>
|
| 122 |
-
<onlinepayment>
|
| 123 |
-
<label>Online Payment</label>
|
| 124 |
-
<comment>Selecione as formas de pagamento que correspondam ao 'Online Payment'.</comment>
|
| 125 |
-
<frontend_type>multiselect</frontend_type>
|
| 126 |
-
<source_model>chaordic_base/paymentmethods</source_model>
|
| 127 |
-
<sort_order>6</sort_order>
|
| 128 |
-
<show_in_default>1</show_in_default>
|
| 129 |
-
<show_in_website>1</show_in_website>
|
| 130 |
-
<show_in_store>1</show_in_store>
|
| 131 |
-
</onlinepayment>
|
| 132 |
-
<directdebit>
|
| 133 |
-
<label>Direct Debit</label>
|
| 134 |
-
<comment>Selecione as formas de pagamento que correspondam ao 'Direct Debit'.</comment>
|
| 135 |
-
<frontend_type>multiselect</frontend_type>
|
| 136 |
-
<source_model>chaordic_base/paymentmethods</source_model>
|
| 137 |
-
<sort_order>7</sort_order>
|
| 138 |
-
<show_in_default>1</show_in_default>
|
| 139 |
-
<show_in_website>1</show_in_website>
|
| 140 |
-
<show_in_store>1</show_in_store>
|
| 141 |
-
</directdebit>
|
| 142 |
-
</fields>
|
| 143 |
-
</methods>
|
| 144 |
-
|
| 145 |
-
<search translate="label">
|
| 146 |
-
<label>Módulo Search</label>
|
| 147 |
-
<sort_order>3</sort_order>
|
| 148 |
-
<show_in_default>1</show_in_default>
|
| 149 |
-
<show_in_website>1</show_in_website>
|
| 150 |
-
<show_in_store>1</show_in_store>
|
| 151 |
-
<expanded>true</expanded>
|
| 152 |
-
|
| 153 |
-
<fields>
|
| 154 |
-
<pageid>
|
| 155 |
-
<label>ID da página Search</label>
|
| 156 |
-
<comment>ID da página de estrutura do search. A página será automaticamente criada no primeiro acesso do crawler. Se a opção estiver em branco a página ainda não foi criada. Se preferir você pode informar o ID de outra página.</comment>
|
| 157 |
-
<frontend_type>text</frontend_type>
|
| 158 |
-
<sort_order>1</sort_order>
|
| 159 |
-
<show_in_default>1</show_in_default>
|
| 160 |
-
<show_in_website>1</show_in_website>
|
| 161 |
-
<show_in_store>1</show_in_store>
|
| 162 |
-
</pageid>
|
| 163 |
-
</fields>
|
| 164 |
-
</search>
|
| 165 |
-
</groups>
|
| 166 |
-
</chaordic_base>
|
| 167 |
-
</sections>
|
| 168 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/layout/chaordic_base.xml
DELETED
|
@@ -1,176 +0,0 @@
|
|
| 1 |
-
<?xml version="1.0"?>
|
| 2 |
-
<layout version="1.0">
|
| 3 |
-
<!-- Loader -->
|
| 4 |
-
<default>
|
| 5 |
-
<reference name="head">
|
| 6 |
-
<block type="chaordic_base/meta" name="chaordic.user">
|
| 7 |
-
<action method="setData">
|
| 8 |
-
<name>context</name>
|
| 9 |
-
<value>user</value>
|
| 10 |
-
</action>
|
| 11 |
-
<action method="routeModel"/>
|
| 12 |
-
</block>
|
| 13 |
-
|
| 14 |
-
<block type="chaordic_base/meta"
|
| 15 |
-
name="chaordic.meta"
|
| 16 |
-
template="chaordic/meta.phtml"
|
| 17 |
-
after="-"/>
|
| 18 |
-
|
| 19 |
-
<block type="chaordic_base/loader"
|
| 20 |
-
name="chaordic.loader"
|
| 21 |
-
template="chaordic/loader.phtml"
|
| 22 |
-
after="-" />
|
| 23 |
-
</reference>
|
| 24 |
-
</default>
|
| 25 |
-
|
| 26 |
-
<!-- Catalog -->
|
| 27 |
-
<catalog_category_default>
|
| 28 |
-
<reference name="head">
|
| 29 |
-
<block type="chaordic_base/meta" name="chaordic.catalog">
|
| 30 |
-
<action method="setData">
|
| 31 |
-
<name>context</name>
|
| 32 |
-
<value>catalog</value>
|
| 33 |
-
</action>
|
| 34 |
-
<action method="routeModel"/>
|
| 35 |
-
</block>
|
| 36 |
-
</reference>
|
| 37 |
-
</catalog_category_default>
|
| 38 |
-
|
| 39 |
-
<catalog_category_layered>
|
| 40 |
-
<reference name="head">
|
| 41 |
-
<block type="chaordic_base/meta" name="chaordic.catalog">
|
| 42 |
-
<action method="setData">
|
| 43 |
-
<name>context</name>
|
| 44 |
-
<value>catalog</value>
|
| 45 |
-
</action>
|
| 46 |
-
<action method="routeModel"/>
|
| 47 |
-
</block>
|
| 48 |
-
</reference>
|
| 49 |
-
</catalog_category_layered>
|
| 50 |
-
|
| 51 |
-
<catalog_product_view>
|
| 52 |
-
<reference name="head">
|
| 53 |
-
<block type="chaordic_base/meta" name="chaordic.product">
|
| 54 |
-
<action method="setData">
|
| 55 |
-
<name>context</name>
|
| 56 |
-
<value>product</value>
|
| 57 |
-
</action>
|
| 58 |
-
<action method="routeModel"/>
|
| 59 |
-
</block>
|
| 60 |
-
</reference>
|
| 61 |
-
</catalog_product_view>
|
| 62 |
-
|
| 63 |
-
<!-- Checkout -->
|
| 64 |
-
<checkout_cart_index>
|
| 65 |
-
<reference name="head">
|
| 66 |
-
<block type="chaordic_base/meta" name="chaordic.cart">
|
| 67 |
-
<action method="setData">
|
| 68 |
-
<name>context</name>
|
| 69 |
-
<value>cart</value>
|
| 70 |
-
</action>
|
| 71 |
-
<action method="routeModel"/>
|
| 72 |
-
</block>
|
| 73 |
-
</reference>
|
| 74 |
-
</checkout_cart_index>
|
| 75 |
-
|
| 76 |
-
<checkout_cart_configure>
|
| 77 |
-
<reference name="head">
|
| 78 |
-
<block type="chaordic_base/meta" name="chaordic.cart.configure">
|
| 79 |
-
<action method="setData">
|
| 80 |
-
<name>context</name>
|
| 81 |
-
<value>cart</value>
|
| 82 |
-
</action>
|
| 83 |
-
<action method="routeModel"/>
|
| 84 |
-
</block>
|
| 85 |
-
</reference>
|
| 86 |
-
</checkout_cart_configure>
|
| 87 |
-
|
| 88 |
-
<checkout_onepage_index>
|
| 89 |
-
<reference name="head">
|
| 90 |
-
<block type="chaordic_base/meta" name="chaordic.checkout">
|
| 91 |
-
<action method="setData">
|
| 92 |
-
<name>context</name>
|
| 93 |
-
<value>checkout</value>
|
| 94 |
-
</action>
|
| 95 |
-
<action method="routeModel"/>
|
| 96 |
-
</block>
|
| 97 |
-
</reference>
|
| 98 |
-
</checkout_onepage_index>
|
| 99 |
-
|
| 100 |
-
<checkout_onepage_success>
|
| 101 |
-
<reference name="head">
|
| 102 |
-
<block type="chaordic_base/meta" name="chaordic.confirmation">
|
| 103 |
-
<action method="setData">
|
| 104 |
-
<name>context</name>
|
| 105 |
-
<value>confirmation</value>
|
| 106 |
-
</action>
|
| 107 |
-
<action method="routeModel"/>
|
| 108 |
-
</block>
|
| 109 |
-
</reference>
|
| 110 |
-
</checkout_onepage_success>
|
| 111 |
-
|
| 112 |
-
<!-- Search -->
|
| 113 |
-
<catalogsearch_result_index>
|
| 114 |
-
<reference name="head">
|
| 115 |
-
<block type="chaordic_base/meta"
|
| 116 |
-
name="chaordic.search.result">
|
| 117 |
-
<action method="setData">
|
| 118 |
-
<name>context</name>
|
| 119 |
-
<value>search</value>
|
| 120 |
-
</action>
|
| 121 |
-
<action method="routeModel"/>
|
| 122 |
-
</block>
|
| 123 |
-
</reference>
|
| 124 |
-
</catalogsearch_result_index>
|
| 125 |
-
|
| 126 |
-
<catalogsearch_advanced_result>
|
| 127 |
-
<reference name="head">
|
| 128 |
-
<block type="chaordic_base/meta" name="chaordic.search.advancedresult">
|
| 129 |
-
<action method="setData">
|
| 130 |
-
<name>context</name>
|
| 131 |
-
<value>search</value>
|
| 132 |
-
</action>
|
| 133 |
-
<action method="routeModel"/>
|
| 134 |
-
</block>
|
| 135 |
-
</reference>
|
| 136 |
-
</catalogsearch_advanced_result>
|
| 137 |
-
|
| 138 |
-
<!-- CMS -->
|
| 139 |
-
<cms_index_index>
|
| 140 |
-
<reference name="head">
|
| 141 |
-
<block type="chaordic_base/meta" name="chaordic.cms.home">
|
| 142 |
-
<action method="setData">
|
| 143 |
-
<name>context</name>
|
| 144 |
-
<value>home</value>
|
| 145 |
-
</action>
|
| 146 |
-
<action method="routeModel"/>
|
| 147 |
-
</block>
|
| 148 |
-
</reference>
|
| 149 |
-
</cms_index_index>
|
| 150 |
-
|
| 151 |
-
<cms_page>
|
| 152 |
-
<reference name="head">
|
| 153 |
-
<block type="chaordic_base/meta" name="chaordic.cms.page">
|
| 154 |
-
<action method="setData">
|
| 155 |
-
<name>context</name>
|
| 156 |
-
<value>cms_page</value>
|
| 157 |
-
</action>
|
| 158 |
-
<action method="routeModel"/>
|
| 159 |
-
</block>
|
| 160 |
-
</reference>
|
| 161 |
-
</cms_page>
|
| 162 |
-
|
| 163 |
-
<!-- Customer -->
|
| 164 |
-
<customer_account>
|
| 165 |
-
<reference name="head">
|
| 166 |
-
<block type="chaordic_base/meta" name="chaordic.customer">
|
| 167 |
-
<action method="setData">
|
| 168 |
-
<name>context</name>
|
| 169 |
-
<value>customer</value>
|
| 170 |
-
</action>
|
| 171 |
-
<action method="routeModel"/>
|
| 172 |
-
</block>
|
| 173 |
-
</reference>
|
| 174 |
-
</customer_account>
|
| 175 |
-
|
| 176 |
-
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/chaordic/loader.phtml
CHANGED
|
@@ -2,8 +2,9 @@
|
|
| 2 |
/**
|
| 3 |
* @category Chaordic
|
| 4 |
* @package Chaordic_Base
|
| 5 |
-
* @version
|
| 6 |
-
* @copyright Copyright (c)
|
|
|
|
| 7 |
*/
|
| 8 |
?>
|
| 9 |
|
| 2 |
/**
|
| 3 |
* @category Chaordic
|
| 4 |
* @package Chaordic_Base
|
| 5 |
+
* @version 3.0.0
|
| 6 |
+
* @copyright Copyright (c) 2016 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
+
* @author DIV64 <suporte@div64.com>
|
| 8 |
*/
|
| 9 |
?>
|
| 10 |
|
app/design/frontend/base/default/template/chaordic/meta.phtml
CHANGED
|
@@ -2,16 +2,27 @@
|
|
| 2 |
/**
|
| 3 |
* @category Chaordic
|
| 4 |
* @package Chaordic_Base
|
| 5 |
-
* @version
|
| 6 |
-
* @copyright Copyright (c)
|
|
|
|
| 7 |
*/
|
| 8 |
|
| 9 |
-
$
|
| 10 |
-
|
| 11 |
?>
|
| 12 |
|
| 13 |
-
<?php if (
|
| 14 |
<script type="text/javascript">
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
</script>
|
| 17 |
-
<?php endif; ?>
|
| 2 |
/**
|
| 3 |
* @category Chaordic
|
| 4 |
* @package Chaordic_Base
|
| 5 |
+
* @version 3.0.0
|
| 6 |
+
* @copyright Copyright (c) 2016 Chaordic Systems (http://www.chaordicsystems.com)
|
| 7 |
+
* @author DIV64 <suporte@div64.com>
|
| 8 |
*/
|
| 9 |
|
| 10 |
+
$_props = $this->getCollection();
|
| 11 |
+
$this->getDebug();
|
| 12 |
?>
|
| 13 |
|
| 14 |
+
<?php if ($_props->count()) : ?>
|
| 15 |
<script type="text/javascript">
|
| 16 |
+
window.chaordic_meta = {};
|
| 17 |
+
<?php foreach ($_props as $_prop): ?>
|
| 18 |
+
<?php $value = $_prop->getValue(); ?>
|
| 19 |
+
<?php if (is_array($value) or is_object($value)) : ?>
|
| 20 |
+
window.chaordic_meta.<?php echo $_prop->getName() ?> = <?php echo json_encode($_prop->getValue()) ?>;
|
| 21 |
+
<?php elseif (is_boolean($value) or is_numeric($value)) : ?>
|
| 22 |
+
window.chaordic_meta.<?php echo $_prop->getName() ?> = <?php echo $value ?>;
|
| 23 |
+
<?php else : ?>
|
| 24 |
+
window.chaordic_meta.<?php echo $_prop->getName() ?> = '<?php echo $value ?>';
|
| 25 |
+
<?php endif; ?>
|
| 26 |
+
<?php endforeach; ?>
|
| 27 |
</script>
|
| 28 |
+
<?php endif; ?>
|
app/etc/modules/Chaordic_Base.xml
CHANGED
|
@@ -4,6 +4,9 @@
|
|
| 4 |
<Chaordic_Base>
|
| 5 |
<active>true</active>
|
| 6 |
<codePool>community</codePool>
|
|
|
|
|
|
|
|
|
|
| 7 |
</Chaordic_Base>
|
| 8 |
</modules>
|
| 9 |
-
</config>
|
| 4 |
<Chaordic_Base>
|
| 5 |
<active>true</active>
|
| 6 |
<codePool>community</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Checkout />
|
| 9 |
+
</depends>
|
| 10 |
</Chaordic_Base>
|
| 11 |
</modules>
|
| 12 |
+
</config>
|
package.xml
CHANGED
|
@@ -1,18 +1,22 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Chaordic_Base</name>
|
| 4 |
-
<version>1.0
|
| 5 |
<stability>stable</stability>
|
| 6 |
-
<license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
-
<summary>
|
| 10 |
-
|
| 11 |
-
<
|
| 12 |
-
|
| 13 |
-
<
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
<compatible/>
|
| 17 |
-
<dependencies><required><php><min>5.
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Chaordic_Base</name>
|
| 4 |
+
<version>1.1.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
+
<license>OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
+
<summary>This module automatically integrates your Store to Chaordic's personalization technology.
|
| 10 |
+
</summary>
|
| 11 |
+
<description>This module automatically integrates your Store to Chaordic's personalization technology.
|
| 12 |
+
</description>
|
| 13 |
+
<notes>Melhora na captura de dados
|
| 14 |
+
Melhorias de performance
|
| 15 |
+
Bugfix de segurança</notes>
|
| 16 |
+
<authors><author><name>Chaordic</name><user>chaordic</user><email>mauricio@chaordic.com.br</email></author></authors>
|
| 17 |
+
<date>2016-08-28</date>
|
| 18 |
+
<time>23:21:58</time>
|
| 19 |
+
<contents><target name="mageweb"><dir name="js"><dir name="chaordic"><file name="chaordic.js" hash=""/></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Chaordic_Base.csv" hash=""/></dir><dir name="es_AR"><file name="Chaordic_Base.csv" hash=""/></dir><dir name="es_ES"><file name="Chaordic_Base.csv" hash=""/></dir><dir name="pt_BR"><file name="Chaordic_Base.csv" hash=""/></dir></target><target name="mageetc"><dir name="modules"><file name="Chaordic_Base.xml" hash="de6a35c557e9afc13163bff0e95f04e7"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="chaordic"><file name="loader.phtml" hash="e570aea9ddd442fa227ac82b15291de2"/><file name="meta.phtml" hash="96e5aa2f05c82cf1e92e41fa3762c235"/></dir></dir></dir></dir></dir></target></contents>
|
| 20 |
<compatible/>
|
| 21 |
+
<dependencies><required><php><min>5.4.0</min><max>5.6.24</max></php></required></dependencies>
|
| 22 |
</package>
|
