Version Notes
Support of sales tracking Magento
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Beecoder_Beeshopy |
| Version | 2.1.0 |
| Comparing to | |
| See all releases | |
Version 2.1.0
- app/code/community/Beecoder/Beeshopy/Block/.Track.php.swp +0 -0
- app/code/community/Beecoder/Beeshopy/Block/Track.php +40 -0
- app/code/community/Beecoder/Beeshopy/Model/Api.php +301 -0
- app/code/community/Beecoder/Beeshopy/controllers/IndexController.php +43 -0
- app/code/community/Beecoder/Beeshopy/etc/api.xml +44 -0
- app/code/community/Beecoder/Beeshopy/etc/config.xml +43 -0
- app/design/frontend/default/default/layout/beeshopy.xml +18 -0
- app/design/frontend/default/default/template/beeshopy/track.phtml +4 -0
- app/etc/modules/Beecoder_Beeshopy.xml +10 -0
- package.xml +21 -0
app/code/community/Beecoder/Beeshopy/Block/.Track.php.swp
ADDED
|
Binary file
|
app/code/community/Beecoder/Beeshopy/Block/Track.php
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Beecoder_Beeshopy_Block_Track extends Mage_Core_Block_Template {
|
| 3 |
+
|
| 4 |
+
public function getOrder()
|
| 5 |
+
{
|
| 6 |
+
if ($this->_order === null) {
|
| 7 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
| 8 |
+
if ($orderId) {
|
| 9 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
| 10 |
+
if ($order->getId()) {
|
| 11 |
+
$this->_order = $order;
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
return $this->_order;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
public function trackingCode(){
|
| 19 |
+
$shop = Mage::getModel('core/cookie')->get("beetailer_shop");
|
| 20 |
+
$checkout = Mage::getModel('core/cookie')->get("beetailer_checkout");
|
| 21 |
+
|
| 22 |
+
if($order = $this->getOrder()){
|
| 23 |
+
$res = '<script type="text/javascript" src=\'//www.beetailer.com/s.js'.
|
| 24 |
+
'?p[order_number]='.$order->getIncrementId().
|
| 25 |
+
'&p[amount]='.urlencode(sprintf("%.2f", $order->getSubtotal())).
|
| 26 |
+
'&p[order_date]='.urlencode($order->getCreatedAt()).
|
| 27 |
+
'&p[email]='.urlencode($order->getCustomerEmail()).
|
| 28 |
+
'&p[checkout_token]='.urlencode($checkout).
|
| 29 |
+
'&p[shop_token]='.urlencode($shop).
|
| 30 |
+
'&p[shop_domain]='.urlencode(Mage::getBaseURL()).
|
| 31 |
+
'\'></script>';
|
| 32 |
+
|
| 33 |
+
// Mage::getModel('core/cookie')->delete("beetailer_shop");
|
| 34 |
+
Mage::getModel('core/cookie')->delete("beetailer_checkout");
|
| 35 |
+
}
|
| 36 |
+
return $res;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
}
|
| 40 |
+
?>
|
app/code/community/Beecoder/Beeshopy/Model/Api.php
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Beecoder_Beeshopy_Model_Api extends Mage_Catalog_Model_Api_Resource
|
| 3 |
+
|
| 4 |
+
{
|
| 5 |
+
/* Get beeshopy needed product information*/
|
| 6 |
+
public function productInfo($productId, $store = null, $identifierType = null){
|
| 7 |
+
/* Load Product */
|
| 8 |
+
$product = $this->_getProduct($productId, $store, $identifierType);
|
| 9 |
+
|
| 10 |
+
if (!$product->getId()) {
|
| 11 |
+
$this->_fault('not_exists');
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
$result = $this->getProductInfo($product, $store);
|
| 15 |
+
/* Children and related products*/
|
| 16 |
+
$result += $this->children($product, $store);
|
| 17 |
+
|
| 18 |
+
return $result;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
public function categoryTree($parentId, $store = null){
|
| 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 |
+
$tree = Mage::getResourceSingleton('catalog/category_tree')
|
| 29 |
+
->load();
|
| 30 |
+
|
| 31 |
+
$root = $tree->getNodeById($parentId);
|
| 32 |
+
|
| 33 |
+
if($root && $root->getId() == 1) {
|
| 34 |
+
$root->setName(Mage::helper('catalog')->__('Root'));
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
| 38 |
+
->setStoreId($this->_getStoreId($store))
|
| 39 |
+
->addAttributeToSelect('name')
|
| 40 |
+
->setLoadProductCount(true)
|
| 41 |
+
->addAttributeToSelect('is_active');
|
| 42 |
+
|
| 43 |
+
$tree->addCollectionData($collection, true);
|
| 44 |
+
|
| 45 |
+
return $this->_nodeToArray($root);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
public function assignedProducts($categoryId, $store = null)
|
| 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('position', '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 |
+
/* Get system info such as currency, rates, ... */
|
| 74 |
+
public function systemInfo(){
|
| 75 |
+
$currencyModel = Mage::getModel('Mage_Directory_Model_Currency');
|
| 76 |
+
$store_views = array();
|
| 77 |
+
$default_store_view = Mage::app()->getDefaultStoreView()->getId();
|
| 78 |
+
/* Store views */
|
| 79 |
+
foreach(Mage::app()->getStores() as $sview){
|
| 80 |
+
if($sview->getIsActive() == 1 || $sview->getId() == $default_store_view){
|
| 81 |
+
$includes_taxes = Mage::helper('tax')->priceIncludesTax($sview);
|
| 82 |
+
$store_views[$sview->getId()] = array('id' => $sview->getId(), 'name' => $sview->getName(), 'code' => $sview->getCode(), 'root_category_id' => $sview->getRootCategoryId(), 'taxes_included' => $includes_taxes);
|
| 83 |
+
/* Currencies */
|
| 84 |
+
$store_views[$sview->getId()]['currencies'] = array();
|
| 85 |
+
$base = $sview->getBaseCurrency()->getCode();
|
| 86 |
+
|
| 87 |
+
foreach($sview->getAvailableCurrencyCodes() as $code){
|
| 88 |
+
$default = $sview->getDefaultCurrencyCode() == $code ? true : false;
|
| 89 |
+
$currency = $currencyModel->load($code);
|
| 90 |
+
/* No ratio defined */
|
| 91 |
+
$ratios = $currencyModel->getCurrencyRates($base, $code);
|
| 92 |
+
if($ratios == NULL){$ratios = array($code => 1);}
|
| 93 |
+
/* EO No ratio*/
|
| 94 |
+
array_push($store_views[$sview->getId()]['currencies'],
|
| 95 |
+
array("default" => $default, 'ratio' => $ratios, 'format' => $currency->getOutputFormat()));
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
return array('store_views' => $store_views, 'include_url_code' => Mage::getStoreConfig('web/url/use_store'));
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/* Used to know if module is installed*/
|
| 103 |
+
public function checkModule(){
|
| 104 |
+
return array("api_version" => '2.1.0', "magento_version" => Mage::getVersion());
|
| 105 |
+
|
| 106 |
+
}
|
| 107 |
+
/*Auxiliar functions*/
|
| 108 |
+
|
| 109 |
+
/* Get configurable/grouped and related children information */
|
| 110 |
+
private function children($parent, $store = null, $identifierType = null)
|
| 111 |
+
{
|
| 112 |
+
try
|
| 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 |
+
if($product->isSalable() != false){
|
| 122 |
+
array_push($res['related'], $this->getProductInfo($product, $store));
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
switch($parent->getTypeId()){
|
| 127 |
+
case("configurable"):
|
| 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 |
+
catch (Mage_Core_Exception $e)
|
| 138 |
+
{
|
| 139 |
+
$this->_fault('store_not_exists');
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
private function getProductInfo($product, $store = null, $extra_params = array()){
|
| 144 |
+
/* Images */
|
| 145 |
+
$image_class = Mage::getModel('Mage_Catalog_Model_Product_Attribute_Media_Api');
|
| 146 |
+
$images = $image_class->items($product->getId(), $store);
|
| 147 |
+
|
| 148 |
+
/* Custom Options */
|
| 149 |
+
$options = $this->getCustomOptions($product);
|
| 150 |
+
$links = $this->getDownloadableLinks($product);
|
| 151 |
+
|
| 152 |
+
/* Prepare results */
|
| 153 |
+
$result = array(
|
| 154 |
+
'idx' => $product->getId(),
|
| 155 |
+
'sku' => $product->getSku(),
|
| 156 |
+
'product_type' => $product->getTypeId(),
|
| 157 |
+
'body' => $product->getInDepth(),
|
| 158 |
+
'description' => $product->getDescription(),
|
| 159 |
+
'short_description' => $product->getShortDescription(),
|
| 160 |
+
'title' => $product->getName(),
|
| 161 |
+
'in_stock' => $product->getStockItem()->getIsInStock(),
|
| 162 |
+
'qty' => $product->getStockItem()->getQty(),
|
| 163 |
+
'price' => $product->getPrice(),
|
| 164 |
+
'permalink' => $product->getUrlPath(),
|
| 165 |
+
'images' => $images,
|
| 166 |
+
'visibility' => $product->getVisibility(),
|
| 167 |
+
'special_price' => $product->getSpecialPrice(),
|
| 168 |
+
'special_from_date' => $product->getSpecialFromDate(),
|
| 169 |
+
'special_to_date' => $product->getSpecialToDate(),
|
| 170 |
+
'custom_options' => $options,
|
| 171 |
+
'status' => $product->getStatus(),
|
| 172 |
+
'links' => $links
|
| 173 |
+
);
|
| 174 |
+
|
| 175 |
+
// Optional extra parameters
|
| 176 |
+
return $result + $extra_params;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
/* Get configurable products */
|
| 180 |
+
private function configurableProducts($parent, $store = null, $identifierType = null){
|
| 181 |
+
$res = array();
|
| 182 |
+
|
| 183 |
+
/* Check if using magento-configurable-simple module */
|
| 184 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
| 185 |
+
$modulesArray = (array)$modules;
|
| 186 |
+
$use_simple_configurable = (isset($modulesArray['OrganicInternet_SimpleConfigurableProducts']) && $modulesArray['OrganicInternet_SimpleConfigurableProducts']->is('active')) ? true : false;
|
| 187 |
+
/* EO Check */
|
| 188 |
+
|
| 189 |
+
/* Get configurable attributes */
|
| 190 |
+
$attrs_codes = $parent->getTypeInstance()->getConfigurableAttributesAsArray();
|
| 191 |
+
/* Get all children */
|
| 192 |
+
$children = $parent->getTypeInstance()->getChildrenIds($parent->getId());
|
| 193 |
+
|
| 194 |
+
foreach ($children[0] as $i => $value) {
|
| 195 |
+
$product = $this->_getProduct($value, $store, $identifierType);
|
| 196 |
+
/* Initial Price */
|
| 197 |
+
|
| 198 |
+
$price = $use_simple_configurable ? $product->getFinalPrice() : $parent->getFinalPrice();
|
| 199 |
+
/* Price Difference */
|
| 200 |
+
$difference = 0;
|
| 201 |
+
//Generate caption_name
|
| 202 |
+
$caption = "";
|
| 203 |
+
$configurable_options = array();
|
| 204 |
+
foreach($attrs_codes as $code){
|
| 205 |
+
$caption .= $product->getResource()->getAttribute($code['attribute_code'])->getFrontend()->getValue($product) . " - ";
|
| 206 |
+
$attr_value = $product->getData($code['attribute_code']);
|
| 207 |
+
/* Calculate price */
|
| 208 |
+
foreach($code['values'] as $value){
|
| 209 |
+
if($value['value_index'] == $attr_value) {
|
| 210 |
+
$configurable_options[$code['attribute_id']] = $attr_value;
|
| 211 |
+
if($value["is_percent"] == 1){
|
| 212 |
+
$difference += ($price * $value['pricing_value']) / 100;
|
| 213 |
+
}else{
|
| 214 |
+
$difference += $value['pricing_value'];
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
if($product->isSalable() != false){
|
| 221 |
+
array_push($res, $this->getProductInfo($product, $store, array('caption_name' => $caption,
|
| 222 |
+
'configurable_price' => $price + $difference, 'configurable_options' => $configurable_options)));
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
return $res;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
private function groupedProducts($parent, $store = null, $identifierType = null){
|
| 229 |
+
$res = array();
|
| 230 |
+
$children = $parent->getTypeInstance()->getChildrenIds($parent->getId());
|
| 231 |
+
foreach ($children[3] as $i => $value) {
|
| 232 |
+
$product = $this->_getProduct($value, $store, $identifierType);
|
| 233 |
+
if($product->isSalable() != false){
|
| 234 |
+
array_push($res,$this->getProductInfo($product, $store));
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
return $res;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
private function getCustomOptions($product){
|
| 241 |
+
$options = array();
|
| 242 |
+
$customOptions = $product->getOptions();
|
| 243 |
+
foreach ($customOptions as $customOption) {
|
| 244 |
+
$values = $customOption->getValues();
|
| 245 |
+
$option = array(
|
| 246 |
+
'mgnt_id' => $customOption->getId(),
|
| 247 |
+
'title' => $customOption->getTitle(),
|
| 248 |
+
'required' => $customOption->getIsRequire(),
|
| 249 |
+
'input_type' => $customOption->getType(),
|
| 250 |
+
'order' => $customOption->getSortOrder(),
|
| 251 |
+
'price' => $customOption->getPrice(),
|
| 252 |
+
'price_type' => $customOption->getPriceType(),
|
| 253 |
+
'values' => array()
|
| 254 |
+
);
|
| 255 |
+
|
| 256 |
+
foreach ($values as $value) {
|
| 257 |
+
array_push($option['values'],
|
| 258 |
+
array(
|
| 259 |
+
'title' => $value->getTitle(),
|
| 260 |
+
'price' => $value->getPrice(),
|
| 261 |
+
'price_type' => $value->getPriceType(),
|
| 262 |
+
'sku' => $value->getSku(),
|
| 263 |
+
'mgnt_id' => $value->getId()
|
| 264 |
+
)
|
| 265 |
+
);
|
| 266 |
+
}
|
| 267 |
+
array_push($options, $option);
|
| 268 |
+
}
|
| 269 |
+
return $options;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
/* Downloadable products links */
|
| 273 |
+
private function getDownloadableLinks($product){
|
| 274 |
+
if($product->getTypeId() != "downloadable") return array();
|
| 275 |
+
$links = $product->getTypeInstance(true)->getLinks($product);
|
| 276 |
+
$links_res = array();
|
| 277 |
+
foreach($links as $link){
|
| 278 |
+
array_push($links_res, array('price' => $link->getPrice(), 'mgnt_id' => $link->getId(), 'title' => $link->getTitle(), 'price_type' => "fixed"));
|
| 279 |
+
}
|
| 280 |
+
return $links_res;
|
| 281 |
+
}
|
| 282 |
+
protected function _nodeToArray(Varien_Data_Tree_Node $node)
|
| 283 |
+
{
|
| 284 |
+
$result = array();
|
| 285 |
+
$result['category_id'] = $node->getId();
|
| 286 |
+
$result['parent_id'] = $node->getParentId();
|
| 287 |
+
$result['name'] = $node->getName();
|
| 288 |
+
$result['is_active'] = $node->getIsActive();
|
| 289 |
+
$result['position'] = $node->getPosition();
|
| 290 |
+
$result['level'] = $node->getLevel();
|
| 291 |
+
$result['product_count'] = $node->getProductCount();
|
| 292 |
+
$result['children'] = array();
|
| 293 |
+
|
| 294 |
+
foreach ($node->getChildren() as $child) {
|
| 295 |
+
$result['children'][] = $this->_nodeToArray($child);
|
| 296 |
+
}
|
| 297 |
+
return $result;
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
?>
|
app/code/community/Beecoder/Beeshopy/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Beecoder_Beeshopy_IndexController extends Mage_Core_Controller_Front_Action
|
| 3 |
+
{
|
| 4 |
+
public function indexAction()
|
| 5 |
+
{
|
| 6 |
+
if($this->getRequest()->getParams()){
|
| 7 |
+
/* Set Cookies */
|
| 8 |
+
$shop_token = explode("_", $this->getRequest()->getParam('fb_ref'));
|
| 9 |
+
Mage::getModel('core/cookie')->set("beetailer_shop", $shop_token[1]);
|
| 10 |
+
Mage::getModel('core/cookie')->set("beetailer_checkout", $this->getRequest()->getParam('checkout_token'));
|
| 11 |
+
|
| 12 |
+
/* Fill shopping cart */
|
| 13 |
+
$cart = Mage::getSingleton('checkout/cart');
|
| 14 |
+
$products = $this->getRequest()->getParam('products');
|
| 15 |
+
$sview = $this->getRequest()->getParam('store_view');
|
| 16 |
+
|
| 17 |
+
foreach($products as $attrs){
|
| 18 |
+
$product = Mage::getModel('catalog/product')
|
| 19 |
+
->setStoreId(Mage::app()->getStore($sview)->getId())
|
| 20 |
+
->load($attrs['idx']);
|
| 21 |
+
|
| 22 |
+
$options = isset($attrs['options']) ? $attrs['options'] : array();
|
| 23 |
+
$super_attributes = isset($attrs['super_attributes']) ? $attrs['super_attributes'] : array();
|
| 24 |
+
$links = isset($attrs['links']) ? explode(",", $attrs['links'][0]) : array();
|
| 25 |
+
|
| 26 |
+
try{
|
| 27 |
+
$cart->addProduct($product, array(
|
| 28 |
+
'qty' => $attrs["qty"],
|
| 29 |
+
'super_attribute' => $super_attributes,
|
| 30 |
+
'options' => $options,
|
| 31 |
+
'links' => $links
|
| 32 |
+
));
|
| 33 |
+
}catch (Mage_Core_Exception $e) { }
|
| 34 |
+
}
|
| 35 |
+
$cart->save();
|
| 36 |
+
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
|
| 37 |
+
$this->_redirect('checkout/cart');
|
| 38 |
+
}else{
|
| 39 |
+
$this->_redirect('/');
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
?>
|
app/code/community/Beecoder/Beeshopy/etc/api.xml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<api>
|
| 4 |
+
<resources>
|
| 5 |
+
<beeshopyCustomApi translate="title" module="Beecoder_Beeshopy">
|
| 6 |
+
<title>Beeshopy custom API</title>
|
| 7 |
+
<model>Beecoder_Beeshopy/Api</model>
|
| 8 |
+
<methods>
|
| 9 |
+
<!-- Retrieve product information -->
|
| 10 |
+
<productInfo translate="title" module="beecoder_beeshopy">
|
| 11 |
+
<title>Retrieve product information</title>
|
| 12 |
+
<acl>catalog/product</acl>
|
| 13 |
+
</productInfo>
|
| 14 |
+
<!-- Rewrite original category.tree, num products added -->
|
| 15 |
+
<categoryTree translate="title" module="beecoder_beeshopy">
|
| 16 |
+
<title>Rewrite original category.tree, num products added</title>
|
| 17 |
+
<acl>catalog/product</acl>
|
| 18 |
+
</categoryTree>
|
| 19 |
+
<!-- Rewrite original category.assignedProducts, product_name added -->
|
| 20 |
+
<assignedProducts translate="title" module="beecoder_beeshopy">
|
| 21 |
+
<title>Rewrite original category.assignedProducts, product_name added</title>
|
| 22 |
+
<acl>catalog/product</acl>
|
| 23 |
+
</assignedProducts>
|
| 24 |
+
<!-- System information, store views, taxes included, currencies -->
|
| 25 |
+
<systemInfo translate="title" module="beecoder_beeshopy">
|
| 26 |
+
<title>Retrieve usefull system information</title>
|
| 27 |
+
<acl>catalog/product</acl>
|
| 28 |
+
</systemInfo>
|
| 29 |
+
<!-- Check if module is instaled and check correct access permissions-->
|
| 30 |
+
<checkModule translate="title" module="beecoder_beeshopy">
|
| 31 |
+
<title>Check if module installed and return version</title>
|
| 32 |
+
<acl>catalog/product</acl>
|
| 33 |
+
</checkModule>
|
| 34 |
+
</methods>
|
| 35 |
+
</beeshopyCustomApi>
|
| 36 |
+
</resources>
|
| 37 |
+
<acl>
|
| 38 |
+
<resources>
|
| 39 |
+
<all>
|
| 40 |
+
</all>
|
| 41 |
+
</resources>
|
| 42 |
+
</acl>
|
| 43 |
+
</api>
|
| 44 |
+
</config>
|
app/code/community/Beecoder/Beeshopy/etc/config.xml
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
|
| 4 |
+
<modules>
|
| 5 |
+
<Beecoder_Beeshopy>
|
| 6 |
+
<version>0.1.0</version>
|
| 7 |
+
</Beecoder_Beeshopy>
|
| 8 |
+
</modules>
|
| 9 |
+
|
| 10 |
+
<global>
|
| 11 |
+
<blocks>
|
| 12 |
+
<beecoder_beeshopy>
|
| 13 |
+
<class>Beecoder_Beeshopy_Block</class>
|
| 14 |
+
</beecoder_beeshopy>
|
| 15 |
+
</blocks>
|
| 16 |
+
|
| 17 |
+
<models>
|
| 18 |
+
<Beecoder_Beeshopy>
|
| 19 |
+
<class>Beecoder_Beeshopy_Model</class>
|
| 20 |
+
</Beecoder_Beeshopy>
|
| 21 |
+
</models>
|
| 22 |
+
</global>
|
| 23 |
+
|
| 24 |
+
<frontend>
|
| 25 |
+
<routers>
|
| 26 |
+
<process-facebook-cart>
|
| 27 |
+
<use>standard</use>
|
| 28 |
+
<args>
|
| 29 |
+
<module>Beecoder_Beeshopy</module>
|
| 30 |
+
<frontName>process-facebook-cart</frontName>
|
| 31 |
+
</args>
|
| 32 |
+
</process-facebook-cart>
|
| 33 |
+
</routers>
|
| 34 |
+
|
| 35 |
+
<layout>
|
| 36 |
+
<updates>
|
| 37 |
+
<beeshopy>
|
| 38 |
+
<file>beeshopy.xml</file>
|
| 39 |
+
</beeshopy>
|
| 40 |
+
</updates>
|
| 41 |
+
</layout>
|
| 42 |
+
</frontend>
|
| 43 |
+
</config>
|
app/design/frontend/default/default/layout/beeshopy.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- Beetailer.com tracking code -->
|
| 2 |
+
<?php
|
| 3 |
+
echo($this->trackingCode());
|
| 4 |
+
?>
|
app/etc/modules/Beecoder_Beeshopy.xml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Beecoder_Beeshopy>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</Beecoder_Beeshopy>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
| 10 |
+
|
package.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Beecoder_Beeshopy</name>
|
| 4 |
+
<version>2.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>OSL v3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Insert your shop in Facebook!
|
| 10 |
+
Beeshopy extension for Magento, it allows you to integrates your magento store with beeshopy.</summary>
|
| 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>Support of sales tracking Magento</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-04-26</date>
|
| 17 |
+
<time>02:01:04</time>
|
| 18 |
+
<contents><target name="magecommunity"><dir name="Beecoder"><dir name="Beeshopy"><dir name="Block"><file name="Track.php" hash="60f6db76def102712af42e3026b082c7"/><file name=".Track.php.swp" hash="b3112f9630941809a6b867807d32a740"/></dir><dir name="Model"><file name="Api.php" hash="88fe3a57288a2cc3a861f51308e001a0"/></dir><dir name="controllers"><file name="IndexController.php" hash="76a2d269df704fd3e0d43701f60bf76a"/></dir><dir name="etc"><file name="api.xml" hash="507ae656ea724a77def33efd8429d674"/><file name="config.xml" hash="844248ae1243ec3e05ab3447f8165e39"/></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="default"><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>
|
