Version Notes
Cleaning code
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Beecoder_Beeshopy |
| Version | 2.4.8 |
| Comparing to | |
| See all releases | |
Code changes from version 2.4.7 to 2.4.8
- app/code/community/Beecoder/Beeshopy/Block/Track.php +35 -25
- app/code/community/Beecoder/Beeshopy/Helper/Data.php +8 -0
- app/code/community/Beecoder/Beeshopy/Model/.Api.php.swp +0 -0
- app/code/community/Beecoder/Beeshopy/Model/Api.php +222 -209
- app/code/community/Beecoder/Beeshopy/controllers/AdminController.php +24 -11
- app/code/community/Beecoder/Beeshopy/controllers/IndexController.php +60 -52
- app/code/community/Beecoder/Beeshopy/etc/config.xml +4 -4
- app/design/frontend/default/default/layout/beeshopy.xml +0 -18
- app/design/frontend/default/default/template/beeshopy/track.phtml +0 -4
- package.xml +5 -5
app/code/community/Beecoder/Beeshopy/Block/Track.php
CHANGED
|
@@ -1,39 +1,49 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
public function getOrder()
|
| 5 |
{
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
}
|
| 14 |
}
|
| 15 |
-
|
|
|
|
| 16 |
}
|
| 17 |
|
| 18 |
-
public function trackingCode()
|
| 19 |
-
|
| 20 |
-
$
|
|
|
|
| 21 |
|
| 22 |
-
if($order = $this->getOrder()){
|
| 23 |
$res = '<script type="text/javascript" src=\'//www.beetailer.com/s.js'.
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
-
Mage::getModel('core/cookie')->delete(
|
| 34 |
}
|
| 35 |
return $res;
|
| 36 |
}
|
| 37 |
-
|
| 38 |
}
|
| 39 |
-
?>
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Beetailer checkout tracking code
|
| 4 |
+
*
|
| 5 |
+
* @category Beetailer
|
| 6 |
+
* @package Beecoder_Beeshopy
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class Beecoder_Beeshopy_Block_Track extends Mage_Core_Block_Template
|
| 11 |
+
{
|
| 12 |
+
|
| 13 |
+
private $_order = null;
|
| 14 |
|
| 15 |
public function getOrder()
|
| 16 |
{
|
| 17 |
+
if ($this->_order === null) {
|
| 18 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
| 19 |
+
if ($orderId) {
|
| 20 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
| 21 |
+
if ($order->getId()) {
|
| 22 |
+
$this->_order = $order;
|
| 23 |
+
}
|
|
|
|
| 24 |
}
|
| 25 |
+
}
|
| 26 |
+
return $this->_order;
|
| 27 |
}
|
| 28 |
|
| 29 |
+
public function trackingCode()
|
| 30 |
+
{
|
| 31 |
+
$beetailerRef = Mage::getModel('core/cookie')->get('beetailer_ref');
|
| 32 |
+
$beetailerRefDate = Mage::getModel('core/cookie')->get('beetailer_ref_date');
|
| 33 |
|
| 34 |
+
if ($order = $this->getOrder()) {
|
| 35 |
$res = '<script type="text/javascript" src=\'//www.beetailer.com/s.js'.
|
| 36 |
+
'?p[order_number]='.$order->getIncrementId().
|
| 37 |
+
'&p[amount]='.urlencode(sprintf("%.2f", $order->getSubtotal())).
|
| 38 |
+
'&p[order_date]='.urlencode($order->getCreatedAt()).
|
| 39 |
+
'&p[email]='.urlencode($order->getCustomerEmail()).
|
| 40 |
+
'&p[beetailer_ref]='.urlencode($beetailerRef).
|
| 41 |
+
'&p[beetailer_ref_date]='.urlencode($beetailerRefDate).
|
| 42 |
+
'&p[shop_domain]='.urlencode(Mage::getBaseURL()).
|
| 43 |
+
'\'></script>';
|
| 44 |
|
| 45 |
+
Mage::getModel('core/cookie')->delete('beetailer_ref');
|
| 46 |
}
|
| 47 |
return $res;
|
| 48 |
}
|
|
|
|
| 49 |
}
|
|
|
app/code/community/Beecoder/Beeshopy/Helper/Data.php
CHANGED
|
@@ -1,4 +1,12 @@
|
|
| 1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
class Beecoder_Beeshopy_Helper_Data extends Mage_Core_Helper_Abstract
|
| 3 |
{
|
| 4 |
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Beetailer Data helper
|
| 4 |
+
*
|
| 5 |
+
* @category Beetailer
|
| 6 |
+
* @package Beecoder_Beeshopy
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
|
| 10 |
class Beecoder_Beeshopy_Helper_Data extends Mage_Core_Helper_Abstract
|
| 11 |
{
|
| 12 |
|
app/code/community/Beecoder/Beeshopy/Model/.Api.php.swp
DELETED
|
Binary file
|
app/code/community/Beecoder/Beeshopy/Model/Api.php
CHANGED
|
@@ -1,232 +1,245 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
|
|
|
| 4 |
{
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
$result += $this->children($product, $store);
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
}
|
| 20 |
|
| 21 |
-
|
| 22 |
-
if (is_null($parentId) && !is_null($store)) {
|
| 23 |
-
$parentId = Mage::app()->getStore($this->_getStoreId($store))->getRootCategoryId();
|
| 24 |
-
} elseif (is_null($parentId)) {
|
| 25 |
-
$parentId = 1;
|
| 26 |
-
}
|
| 27 |
|
| 28 |
-
|
| 29 |
-
->load();
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
->setStoreId($this->_getStoreId($store))
|
| 39 |
-
->addAttributeToSelect('name')
|
| 40 |
-
->setLoadProductCount(true)
|
| 41 |
-
->addAttributeToSelect('is_active');
|
| 42 |
|
| 43 |
-
|
|
|
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
$category = Mage::getModel('catalog/category')->load($categoryId);
|
| 51 |
-
|
| 52 |
-
$collection = $category->setStoreId($this->_getStoreId($store))
|
| 53 |
-
->getProductCollection()
|
| 54 |
-
->addAttributeToSelect('name')
|
| 55 |
-
->addAttributeToSelect('visibility')
|
| 56 |
-
->setOrder(Mage::getStoreConfig('catalog/frontend/default_sort_by'), 'asc');
|
| 57 |
-
|
| 58 |
-
$result = array();
|
| 59 |
-
|
| 60 |
-
foreach ($collection as $product) {
|
| 61 |
-
$result[] = array(
|
| 62 |
-
'product_id' => $product->getId(),
|
| 63 |
-
'visibility' => $product->getVisibility(),
|
| 64 |
-
'type' => $product->getTypeId(),
|
| 65 |
-
'sku' => $product->getSku(),
|
| 66 |
-
'title' => $product->getName()
|
| 67 |
-
);
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
return $result;
|
| 71 |
-
}
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
}
|
| 98 |
}
|
| 99 |
-
return array('store_views' => $store_views, 'include_url_code' => Mage::getStoreConfig('web/url/use_store'));
|
| 100 |
}
|
|
|
|
|
|
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
| 105 |
|
| 106 |
-
|
| 107 |
-
/*Auxiliar functions*/
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
| 111 |
{
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
$res['children'] = array();
|
| 115 |
-
$res['related'] = array();
|
| 116 |
-
|
| 117 |
-
/* Related products */
|
| 118 |
-
foreach($parent->getRelatedProductIds() as $product_id){
|
| 119 |
-
$product = $this->_getProduct($product_id, $store, $identifierType);
|
| 120 |
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
}
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
$res["children"] = $this->configurableProducts($parent, $store, $identifierType);
|
| 129 |
-
break;
|
| 130 |
-
case("grouped"):
|
| 131 |
-
$res["children"] = $this->groupedProducts($parent, $store, $identifierType);
|
| 132 |
-
break;
|
| 133 |
}
|
| 134 |
-
|
| 135 |
-
return $res;
|
| 136 |
}
|
| 137 |
-
|
| 138 |
-
{
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
}
|
|
|
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
|
| 180 |
-
/* Get configurable
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
$
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
/*
|
| 191 |
-
$
|
| 192 |
-
|
| 193 |
-
$
|
| 194 |
-
|
| 195 |
-
foreach
|
| 196 |
-
$
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
$
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
$caption .= $product->getResource()->getAttribute($code['attribute_code'])->getFrontend()->getValue($product) . " - ";
|
| 207 |
-
$attr_value = $product->getData($code['attribute_code']);
|
| 208 |
-
/* Calculate price */
|
| 209 |
-
foreach($code['values'] as $value){
|
| 210 |
-
if($value['value_index'] == $attr_value) {
|
| 211 |
-
$configurable_options[$code['attribute_id']] = $attr_value;
|
| 212 |
-
if($value["is_percent"] == 1){
|
| 213 |
-
$difference += ($price * $value['pricing_value']) / 100;
|
| 214 |
-
}else{
|
| 215 |
-
$difference += $value['pricing_value'];
|
| 216 |
-
}
|
| 217 |
}
|
| 218 |
}
|
| 219 |
}
|
| 220 |
-
|
| 221 |
-
if($product->isSalable() != false){
|
| 222 |
-
array_push($res, $this->getProductInfo($product, $store, array('caption_name' => $caption,
|
| 223 |
-
'configurable_price' => $price + $difference, 'configurable_options' => $configurable_options)));
|
| 224 |
}
|
| 225 |
-
|
| 226 |
-
|
|
|
|
|
|
|
|
|
|
| 227 |
}
|
|
|
|
|
|
|
| 228 |
|
| 229 |
-
private function groupedProducts($parent, $store = null, $identifierType = null)
|
|
|
|
| 230 |
$res = array();
|
| 231 |
$children = $parent->getTypeInstance()->getChildrenIds($parent->getId());
|
| 232 |
foreach ($children[3] as $i => $value) {
|
|
@@ -238,7 +251,8 @@ class Beecoder_Beeshopy_Model_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 238 |
return $res;
|
| 239 |
}
|
| 240 |
|
| 241 |
-
private function getCustomOptions($product)
|
|
|
|
| 242 |
$options = array();
|
| 243 |
$customOptions = $product->getOptions();
|
| 244 |
foreach ($customOptions as $customOption) {
|
|
@@ -280,23 +294,22 @@ class Beecoder_Beeshopy_Model_Api extends Mage_Catalog_Model_Api_Resource
|
|
| 280 |
}
|
| 281 |
return $links_res;
|
| 282 |
}
|
|
|
|
| 283 |
protected function _nodeToArray(Varien_Data_Tree_Node $node)
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
}
|
| 298 |
-
return $result;
|
| 299 |
}
|
|
|
|
|
|
|
| 300 |
}
|
| 301 |
-
|
| 302 |
-
?>
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Beetailer Custom API
|
| 4 |
+
*
|
| 5 |
+
* @category Beetailer
|
| 6 |
+
* @package Beecoder_Beeshopy
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
|
| 10 |
+
class Beecoder_Beeshopy_Model_Api extends Mage_Catalog_Model_Api_Resource
|
| 11 |
{
|
| 12 |
+
/** Get beeshopy needed product information */
|
| 13 |
+
public function productInfo($productId, $store = null, $identifierType = null)
|
| 14 |
+
{
|
| 15 |
+
/* Load Product */
|
| 16 |
+
$product = $this->_getProduct($productId, $store, $identifierType);
|
| 17 |
+
|
| 18 |
+
if (!$product->getId()) {
|
| 19 |
+
$this->_fault('not_exists');
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
$result = $this->getProductInfo($product, $store);
|
| 23 |
+
/* Children and related products*/
|
| 24 |
+
$result += $this->children($product, $store);
|
| 25 |
|
| 26 |
+
return $result;
|
| 27 |
+
}
|
|
|
|
| 28 |
|
| 29 |
+
public function categoryTree($parentId, $store = null)
|
| 30 |
+
{
|
| 31 |
+
if (is_null($parentId) && !is_null($store)) {
|
| 32 |
+
$parentId = Mage::app()->getStore($this->_getStoreId($store))->getRootCategoryId();
|
| 33 |
+
} elseif (is_null($parentId)) {
|
| 34 |
+
$parentId = 1;
|
| 35 |
}
|
| 36 |
|
| 37 |
+
$tree = Mage::getResourceSingleton('catalog/category_tree')->load();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
$root = $tree->getNodeById($parentId);
|
|
|
|
| 40 |
|
| 41 |
+
if ($root && $root->getId() == 1) {
|
| 42 |
+
$root->setName(Mage::helper('catalog')->__('Root'));
|
| 43 |
+
}
|
| 44 |
|
| 45 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
| 46 |
+
->setStoreId($this->_getStoreId($store))
|
| 47 |
+
->addAttributeToSelect('name')
|
| 48 |
+
->setLoadProductCount(true)
|
| 49 |
+
->addAttributeToSelect('is_active');
|
| 50 |
|
| 51 |
+
$tree->addCollectionData($collection, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
return $this->_nodeToArray($root);
|
| 54 |
+
}
|
| 55 |
|
| 56 |
+
public function assignedProducts($categoryId, $store = null)
|
| 57 |
+
{
|
| 58 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
| 59 |
+
|
| 60 |
+
$collection = $category->setStoreId($this->_getStoreId($store))
|
| 61 |
+
->getProductCollection()
|
| 62 |
+
->addAttributeToSelect('name')
|
| 63 |
+
->addAttributeToSelect('visibility')
|
| 64 |
+
->setOrder(Mage::getStoreConfig('catalog/frontend/default_sort_by'), 'asc');
|
| 65 |
+
|
| 66 |
+
$result = array();
|
| 67 |
+
|
| 68 |
+
foreach ($collection as $product) {
|
| 69 |
+
$result[] = array(
|
| 70 |
+
'product_id' => $product->getId(),
|
| 71 |
+
'visibility' => $product->getVisibility(),
|
| 72 |
+
'type' => $product->getTypeId(),
|
| 73 |
+
'sku' => $product->getSku(),
|
| 74 |
+
'title' => $product->getName()
|
| 75 |
+
);
|
| 76 |
}
|
| 77 |
|
| 78 |
+
return $result;
|
| 79 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
/** Get system info such as currency, rates, ... */
|
| 82 |
+
public function systemInfo()
|
| 83 |
+
{
|
| 84 |
+
$currencyModel = Mage::getModel('directory/currency');
|
| 85 |
+
$store_views = array();
|
| 86 |
+
$default_store_view = Mage::app()->getDefaultStoreView()->getId();
|
| 87 |
+
/* Store views */
|
| 88 |
+
foreach(Mage::app()->getStores() as $sview){
|
| 89 |
+
if($sview->getIsActive() == 1 || $sview->getId() == $default_store_view){
|
| 90 |
+
$includes_taxes = Mage::helper('tax')->priceIncludesTax($sview);
|
| 91 |
+
$store_views[$sview->getId()] = array('id' => $sview->getId(), 'name' => $sview->getName(), 'code' => $sview->getCode(), 'root_category_id' => $sview->getRootCategoryId(), 'taxes_included' => $includes_taxes);
|
| 92 |
+
/* Currencies */
|
| 93 |
+
$store_views[$sview->getId()]['currencies'] = array();
|
| 94 |
+
$base = $sview->getBaseCurrency()->getCode();
|
| 95 |
+
|
| 96 |
+
foreach($sview->getAvailableCurrencyCodes() as $code){
|
| 97 |
+
$default = $sview->getDefaultCurrencyCode() == $code ? true : false;
|
| 98 |
+
$currency = $currencyModel->load($code);
|
| 99 |
+
/* No ratio defined */
|
| 100 |
+
$ratios = $currencyModel->getCurrencyRates($base, $code);
|
| 101 |
+
if($ratios == NULL){$ratios = array($code => 1);}
|
| 102 |
+
/* EO No ratio*/
|
| 103 |
+
array_push($store_views[$sview->getId()]['currencies'],
|
| 104 |
+
array("default" => $default, 'ratio' => $ratios, 'format' => $currency->getOutputFormat()));
|
| 105 |
}
|
| 106 |
}
|
|
|
|
| 107 |
}
|
| 108 |
+
return array('store_views' => $store_views, 'include_url_code' => Mage::getStoreConfig('web/url/use_store'));
|
| 109 |
+
}
|
| 110 |
|
| 111 |
+
/* Used to know if module is installed*/
|
| 112 |
+
public function checkModule()
|
| 113 |
+
{
|
| 114 |
+
return array("api_version" => '2.4.8', "magento_version" => Mage::getVersion());
|
| 115 |
+
}
|
| 116 |
|
| 117 |
+
/*Auxiliar functions*/
|
|
|
|
| 118 |
|
| 119 |
+
/** Get configurable/grouped and related children information */
|
| 120 |
+
private function children($parent, $store = null, $identifierType = null)
|
| 121 |
+
{
|
| 122 |
+
try
|
| 123 |
{
|
| 124 |
+
$res['children'] = array();
|
| 125 |
+
$res['related'] = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
+
/* Related products */
|
| 128 |
+
foreach($parent->getRelatedProductIds() as $product_id){
|
| 129 |
+
$product = $this->_getProduct($product_id, $store, $identifierType);
|
|
|
|
| 130 |
|
| 131 |
+
if($product->isSalable() != false){
|
| 132 |
+
array_push($res['related'], $this->getProductInfo($product, $store));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
}
|
|
|
|
|
|
|
| 134 |
}
|
| 135 |
+
|
| 136 |
+
switch($parent->getTypeId()){
|
| 137 |
+
case("configurable"):
|
| 138 |
+
$res["children"] = $this->configurableProducts($parent, $store, $identifierType);
|
| 139 |
+
break;
|
| 140 |
+
case("grouped"):
|
| 141 |
+
$res["children"] = $this->groupedProducts($parent, $store, $identifierType);
|
| 142 |
+
break;
|
| 143 |
}
|
| 144 |
+
|
| 145 |
+
return $res;
|
| 146 |
+
}
|
| 147 |
+
catch (Mage_Core_Exception $e)
|
| 148 |
+
{
|
| 149 |
+
$this->_fault('store_not_exists');
|
| 150 |
}
|
| 151 |
+
}
|
| 152 |
|
| 153 |
+
private function getProductInfo($product, $store = null, $extra_params = array())
|
| 154 |
+
{
|
| 155 |
+
/* Images */
|
| 156 |
+
$image_class = Mage::getModel('catalog/product_attribute_media_api');
|
| 157 |
+
$images = $image_class->items($product->getId(), $store);
|
| 158 |
+
|
| 159 |
+
/* Custom Options */
|
| 160 |
+
$options = $this->getCustomOptions($product);
|
| 161 |
+
$links = $this->getDownloadableLinks($product);
|
| 162 |
+
|
| 163 |
+
/* Prepare results */
|
| 164 |
+
$result = array(
|
| 165 |
+
'idx' => $product->getId(),
|
| 166 |
+
'sku' => $product->getSku(),
|
| 167 |
+
'product_type' => $product->getTypeId(),
|
| 168 |
+
'body' => $product->getInDepth(),
|
| 169 |
+
'description' => $product->getDescription(),
|
| 170 |
+
'short_description' => $product->getShortDescription(),
|
| 171 |
+
'title' => $product->getName(),
|
| 172 |
+
'in_stock' => $product->getStockItem()->getIsInStock(),
|
| 173 |
+
'qty' => $product->getStockItem()->getQty(),
|
| 174 |
+
'price' => $product->getPrice(),
|
| 175 |
+
'permalink' => $product->getUrlPath(),
|
| 176 |
+
'url_in_store' => $product->getProductUrl(),
|
| 177 |
+
'images' => $images,
|
| 178 |
+
'visibility' => $product->getVisibility(),
|
| 179 |
+
'special_price' => $product->getSpecialPrice(),
|
| 180 |
+
'special_from_date' => $product->getSpecialFromDate(),
|
| 181 |
+
'special_to_date' => $product->getSpecialToDate(),
|
| 182 |
+
'custom_options' => $options,
|
| 183 |
+
'status' => $product->getStatus(),
|
| 184 |
+
'links' => $links
|
| 185 |
+
);
|
| 186 |
+
|
| 187 |
+
// Optional extra parameters
|
| 188 |
+
return $result + $extra_params;
|
| 189 |
+
}
|
| 190 |
|
| 191 |
+
/** Get configurable products */
|
| 192 |
+
private function configurableProducts($parent, $store = null, $identifierType = null)
|
| 193 |
+
{
|
| 194 |
+
$res = array();
|
| 195 |
+
|
| 196 |
+
/* Check if using magento-configurable-simple module */
|
| 197 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
| 198 |
+
$modulesArray = (array)$modules;
|
| 199 |
+
$use_simple_configurable = (isset($modulesArray['OrganicInternet_SimpleConfigurableProducts']) && $modulesArray['OrganicInternet_SimpleConfigurableProducts']->is('active')) ? true : false;
|
| 200 |
+
/* EO Check */
|
| 201 |
|
| 202 |
+
/* Get configurable attributes */
|
| 203 |
+
$attrs_codes = $parent->getTypeInstance()->getConfigurableAttributesAsArray();
|
| 204 |
+
/* Get all children */
|
| 205 |
+
$children = $parent->getTypeInstance()->getChildrenIds($parent->getId());
|
| 206 |
+
|
| 207 |
+
foreach ($children[0] as $i => $value) {
|
| 208 |
+
$product = $this->_getProduct($value, $store, $identifierType);
|
| 209 |
+
/* Initial Price */
|
| 210 |
+
|
| 211 |
+
$price = $use_simple_configurable ? $product->getFinalPrice() : $parent->getFinalPrice();
|
| 212 |
+
/* Price Difference */
|
| 213 |
+
$difference = 0;
|
| 214 |
+
//Generate caption_name
|
| 215 |
+
$caption = "";
|
| 216 |
+
$configurable_options = array();
|
| 217 |
+
foreach($attrs_codes as $code){
|
| 218 |
+
$caption .= $product->getResource()->getAttribute($code['attribute_code'])->getFrontend()->getValue($product) . " - ";
|
| 219 |
+
$attr_value = $product->getData($code['attribute_code']);
|
| 220 |
+
/* Calculate price */
|
| 221 |
+
foreach($code['values'] as $value){
|
| 222 |
+
if($value['value_index'] == $attr_value) {
|
| 223 |
+
$configurable_options[$code['attribute_id']] = $attr_value;
|
| 224 |
+
if($value["is_percent"] == 1){
|
| 225 |
+
$difference += ($price * $value['pricing_value']) / 100;
|
| 226 |
+
}else{
|
| 227 |
+
$difference += $value['pricing_value'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
}
|
| 229 |
}
|
| 230 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
}
|
| 232 |
+
|
| 233 |
+
if($product->isSalable() != false){
|
| 234 |
+
array_push($res, $this->getProductInfo($product, $store, array('caption_name' => $caption,
|
| 235 |
+
'configurable_price' => $price + $difference, 'configurable_options' => $configurable_options)));
|
| 236 |
+
}
|
| 237 |
}
|
| 238 |
+
return $res;
|
| 239 |
+
}
|
| 240 |
|
| 241 |
+
private function groupedProducts($parent, $store = null, $identifierType = null)
|
| 242 |
+
{
|
| 243 |
$res = array();
|
| 244 |
$children = $parent->getTypeInstance()->getChildrenIds($parent->getId());
|
| 245 |
foreach ($children[3] as $i => $value) {
|
| 251 |
return $res;
|
| 252 |
}
|
| 253 |
|
| 254 |
+
private function getCustomOptions($product)
|
| 255 |
+
{
|
| 256 |
$options = array();
|
| 257 |
$customOptions = $product->getOptions();
|
| 258 |
foreach ($customOptions as $customOption) {
|
| 294 |
}
|
| 295 |
return $links_res;
|
| 296 |
}
|
| 297 |
+
|
| 298 |
protected function _nodeToArray(Varien_Data_Tree_Node $node)
|
| 299 |
+
{
|
| 300 |
+
$result = array();
|
| 301 |
+
$result['category_id'] = $node->getId();
|
| 302 |
+
$result['parent_id'] = $node->getParentId();
|
| 303 |
+
$result['name'] = $node->getName();
|
| 304 |
+
$result['is_active'] = $node->getIsActive();
|
| 305 |
+
$result['position'] = $node->getPosition();
|
| 306 |
+
$result['level'] = $node->getLevel();
|
| 307 |
+
$result['product_count'] = $node->getProductCount();
|
| 308 |
+
$result['children'] = array();
|
| 309 |
+
|
| 310 |
+
foreach ($node->getChildren() as $child) {
|
| 311 |
+
$result['children'][] = $this->_nodeToArray($child);
|
|
|
|
|
|
|
| 312 |
}
|
| 313 |
+
return $result;
|
| 314 |
+
}
|
| 315 |
}
|
|
|
|
|
|
app/code/community/Beecoder/Beeshopy/controllers/AdminController.php
CHANGED
|
@@ -1,16 +1,29 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
{
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
$this->_setActiveMenu('menu1');
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
}
|
| 16 |
-
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Admin menu
|
| 4 |
+
*
|
| 5 |
+
* @category Beetailer
|
| 6 |
+
* @package Beecoder_Beeshopy
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class Beecoder_Beeshopy_AdminController extends Mage_Adminhtml_Controller_Action
|
| 11 |
+
{
|
| 12 |
+
public function indexAction()
|
| 13 |
{
|
| 14 |
+
$this->loadLayout();
|
| 15 |
+
$this->_setActiveMenu('facebook-store');
|
|
|
|
| 16 |
|
| 17 |
+
$block = $this->getLayout()
|
| 18 |
+
->createBlock('core/text', 'beetailer-admin')
|
| 19 |
+
->setText("<iframe src='https://www.beetailer.com?from=iframe' width=1124 height='2350' frameborder='0' scrolling='no' style='margin:0px auto;display:block;'></iframe>");
|
| 20 |
|
| 21 |
+
$this->_addContent($block);
|
| 22 |
+
$this->renderLayout();
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
protected function _isAllowed()
|
| 26 |
+
{
|
| 27 |
+
return Mage::getSingleton('admin/session')->isAllowed('facebook-store');
|
| 28 |
}
|
| 29 |
+
}
|
app/code/community/Beecoder/Beeshopy/controllers/IndexController.php
CHANGED
|
@@ -1,58 +1,66 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
{
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
Mage::getModel('core/cookie')->set("beetailer_ref", $this->getRequest()->getParam('fb_ref'));
|
| 8 |
-
Mage::getModel('core/cookie')->set("beetailer_ref_date", time());
|
| 9 |
-
|
| 10 |
-
/* Fill shopping cart */
|
| 11 |
-
$cart = Mage::getSingleton('checkout/cart');
|
| 12 |
-
$products = $this->getRequest()->getParam('products');
|
| 13 |
-
$sview = $this->getRequest()->getParam('store_view');
|
| 14 |
-
|
| 15 |
-
foreach($products as $attrs){
|
| 16 |
-
$product = Mage::getModel('catalog/product')
|
| 17 |
-
->setStoreId(Mage::app()->getStore($sview)->getId())
|
| 18 |
-
->load($attrs['idx']);
|
| 19 |
-
|
| 20 |
-
$options = isset($attrs['options']) ? $attrs['options'] : array();
|
| 21 |
-
$super_attributes = isset($attrs['super_attributes']) ? $attrs['super_attributes'] : array();
|
| 22 |
-
$links = isset($attrs['links']) ? explode(",", $attrs['links'][0]) : array();
|
| 23 |
-
|
| 24 |
-
try{
|
| 25 |
-
$cart->addProduct($product, array(
|
| 26 |
-
'qty' => $attrs["qty"],
|
| 27 |
-
'super_attribute' => $super_attributes,
|
| 28 |
-
'options' => $options,
|
| 29 |
-
'links' => $links
|
| 30 |
-
));
|
| 31 |
-
}catch (Mage_Core_Exception $e) { }
|
| 32 |
-
}
|
| 33 |
-
$cart->save();
|
| 34 |
-
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
|
| 35 |
-
|
| 36 |
-
$this->_redirect('checkout/cart', $this->gaParams());
|
| 37 |
-
}else{
|
| 38 |
-
$this->_redirect('/');
|
| 39 |
-
}
|
| 40 |
-
}
|
| 41 |
|
| 42 |
-
/*
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
}
|
| 58 |
-
|
| 1 |
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Beetailer Shopping cart class
|
| 4 |
+
*
|
| 5 |
+
* @category Beetailer
|
| 6 |
+
* @package Beecoder_Beeshopy
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class Beecoder_Beeshopy_IndexController extends Mage_Core_Controller_Front_Action
|
| 11 |
+
{
|
| 12 |
+
public function indexAction()
|
| 13 |
{
|
| 14 |
+
if ($this->getRequest()->getParams()) {
|
| 15 |
+
Mage::getModel('core/cookie')->set("beetailer_ref", $this->getRequest()->getParam('fb_ref'));
|
| 16 |
+
Mage::getModel('core/cookie')->set("beetailer_ref_date", time());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
/* Fill shopping cart */
|
| 19 |
+
$cart = Mage::getSingleton('checkout/cart');
|
| 20 |
+
$products = $this->getRequest()->getParam('products');
|
| 21 |
+
$sview = $this->getRequest()->getParam('store_view');
|
| 22 |
+
|
| 23 |
+
foreach($products as $attrs){
|
| 24 |
+
$product = Mage::getModel('catalog/product')
|
| 25 |
+
->setStoreId(Mage::app()->getStore($sview)->getId())
|
| 26 |
+
->load($attrs['idx']);
|
| 27 |
+
|
| 28 |
+
$options = isset($attrs['options']) ? $attrs['options'] : array();
|
| 29 |
+
$super_attributes = isset($attrs['super_attributes']) ? $attrs['super_attributes'] : array();
|
| 30 |
+
$links = isset($attrs['links']) ? explode(",", $attrs['links'][0]) : array();
|
| 31 |
|
| 32 |
+
try{
|
| 33 |
+
$cart->addProduct($product, array(
|
| 34 |
+
'qty' => $attrs["qty"],
|
| 35 |
+
'super_attribute' => $super_attributes,
|
| 36 |
+
'options' => $options,
|
| 37 |
+
'links' => $links
|
| 38 |
+
));
|
| 39 |
+
}catch (Mage_Core_Exception $e) { }
|
| 40 |
}
|
| 41 |
+
$cart->save();
|
| 42 |
+
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
|
| 43 |
+
|
| 44 |
+
$this->_redirect('checkout/cart', $this->gaParams());
|
| 45 |
+
}else{
|
| 46 |
+
$this->_redirect('/');
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/** Add Google analytics parameters */
|
| 51 |
+
public function gaParams()
|
| 52 |
+
{
|
| 53 |
+
$redirect_params = array();
|
| 54 |
+
foreach($this->getRequest()->getParams() as $k => $v){
|
| 55 |
+
if(preg_match('/^utm_/', $k)){
|
| 56 |
+
$redirect_params[$k] = $v;
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
if(count($redirect_params)){
|
| 61 |
+
$redirect_params = array('_query' => $redirect_params);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
return $redirect_params;
|
| 65 |
}
|
| 66 |
+
}
|
app/code/community/Beecoder/Beeshopy/etc/config.xml
CHANGED
|
@@ -60,21 +60,21 @@
|
|
| 60 |
|
| 61 |
<adminhtml>
|
| 62 |
<menu>
|
| 63 |
-
<
|
| 64 |
<title>Facebook Store</title>
|
| 65 |
<action>beetailer-installation/admin/index</action>
|
| 66 |
<sort_order>100</sort_order>
|
| 67 |
-
</
|
| 68 |
</menu>
|
| 69 |
|
| 70 |
<acl>
|
| 71 |
<resources>
|
| 72 |
<admin>
|
| 73 |
<children>
|
| 74 |
-
<
|
| 75 |
<title>Facebook Store</title>
|
| 76 |
<sort_order>100</sort_order>
|
| 77 |
-
</
|
| 78 |
</children>
|
| 79 |
</admin>
|
| 80 |
</resources>
|
| 60 |
|
| 61 |
<adminhtml>
|
| 62 |
<menu>
|
| 63 |
+
<facebook-store translate="title" module="Beeshopy">
|
| 64 |
<title>Facebook Store</title>
|
| 65 |
<action>beetailer-installation/admin/index</action>
|
| 66 |
<sort_order>100</sort_order>
|
| 67 |
+
</facebook-store>
|
| 68 |
</menu>
|
| 69 |
|
| 70 |
<acl>
|
| 71 |
<resources>
|
| 72 |
<admin>
|
| 73 |
<children>
|
| 74 |
+
<facebook-store translate="title" module="Beeshopy">
|
| 75 |
<title>Facebook Store</title>
|
| 76 |
<sort_order>100</sort_order>
|
| 77 |
+
</facebook-store>
|
| 78 |
</children>
|
| 79 |
</admin>
|
| 80 |
</resources>
|
app/design/frontend/default/default/layout/beeshopy.xml
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
<?xml version="1.0"?>
|
| 2 |
-
<layout version="0.1.0">
|
| 3 |
-
<checkout_onepage_success>
|
| 4 |
-
<reference name="before_body_end">
|
| 5 |
-
<block type="beecoder_beeshopy/track" name="beecoderbeeshopy_track" template='beeshopy/track.phtml'/>
|
| 6 |
-
</reference>
|
| 7 |
-
</checkout_onepage_success>
|
| 8 |
-
|
| 9 |
-
<default>
|
| 10 |
-
<reference name="head">
|
| 11 |
-
<block type="core/text" name='beetailer'>
|
| 12 |
-
<action method="setText">
|
| 13 |
-
<text><![CDATA[ <script type='text/javascript' src='//www.beetailer.com/javascripts/beetailer.js'></script> ]]> </text>
|
| 14 |
-
</action>
|
| 15 |
-
</block>
|
| 16 |
-
</reference>
|
| 17 |
-
</default>
|
| 18 |
-
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/default/default/template/beeshopy/track.phtml
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
<!-- Beetailer.com tracking code -->
|
| 2 |
-
<?php
|
| 3 |
-
echo($this->trackingCode());
|
| 4 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Beecoder_Beeshopy</name>
|
| 4 |
-
<version>2.4.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -11,11 +11,11 @@ Beeshopy extension for Magento, it allows you to integrates your magento store w
|
|
| 11 |
<description>Custom Module that allows you to connect with beeshopy service and integrates your magento store with Facebook. 
|
| 12 |

|
| 13 |
It contains a custom API and cart processing.</description>
|
| 14 |
-
<notes>
|
| 15 |
<authors><author><name>Miguel Ángel Martínez Triviño</name><user>auto-converted</user><email>migmartri@gmail.com</email></author></authors>
|
| 16 |
-
<date>2011-09-
|
| 17 |
-
<time>
|
| 18 |
-
<contents><target name="magecommunity"><dir name="Beecoder"><dir name="Beeshopy"><dir name="Block"><file name="Track.php" hash="
|
| 19 |
<compatible/>
|
| 20 |
<dependencies/>
|
| 21 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Beecoder_Beeshopy</name>
|
| 4 |
+
<version>2.4.8</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 11 |
<description>Custom Module that allows you to connect with beeshopy service and integrates your magento store with Facebook. 
|
| 12 |

|
| 13 |
It contains a custom API and cart processing.</description>
|
| 14 |
+
<notes>Cleaning code</notes>
|
| 15 |
<authors><author><name>Miguel Ángel Martínez Triviño</name><user>auto-converted</user><email>migmartri@gmail.com</email></author></authors>
|
| 16 |
+
<date>2011-09-13</date>
|
| 17 |
+
<time>14:59:52</time>
|
| 18 |
+
<contents><target name="magecommunity"><dir name="Beecoder"><dir name="Beeshopy"><dir name="Block"><file name="Track.php" hash="a40d400b02f73d5b4dea35c348ffee00"/></dir><dir name="Helper"><file name="Data.php" hash="ead88c0b629856526d39e7fb6f3a4ca5"/></dir><dir name="Model"><file name="Api.php" hash="8e02acad05b4494025b76a7a1504351c"/></dir><dir name="controllers"><file name="AdminController.php" hash="1b343fe1ef8ae5fafc5d355844e3f508"/><file name="IndexController.php" hash="bad3391bb742a55a2ee62895cb723e87"/></dir><dir name="etc"><file name="api.xml" hash="507ae656ea724a77def33efd8429d674"/><file name="config.xml" hash="2fcfaeccb838771505e12715c9618c3d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Beecoder_Beeshopy.xml" hash="55666ef45f08dab44b138e49532ca3b8"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="beeshopy.xml" hash="d307958edf914638aa5cd57f8d449c46"/></dir><dir name="template"><dir name="beeshopy"><file name="track.phtml" hash="47c95001bb55042c5ae7d8ee4b03cccf"/></dir></dir></dir></dir></dir></target></contents>
|
| 19 |
<compatible/>
|
| 20 |
<dependencies/>
|
| 21 |
</package>
|
