Version Notes
GOtags service is currently under beta, as such this process may change and the terms of the module may change in later versions.
Download this release
Release Info
| Developer | Ashley White |
| Extension | GOtags_GOtags |
| Version | 0.0.1 |
| Comparing to | |
| See all releases | |
Version 0.0.1
- app/code/community/Gotags/Gotags/Block/Adminhtml/Gotagsbackend.php +5 -0
- app/code/community/Gotags/Gotags/Helper/Data.php +5 -0
- app/code/community/Gotags/Gotags/Model/Api.php +305 -0
- app/code/community/Gotags/Gotags/controllers/Adminhtml/GotagsbackendController.php +10 -0
- app/code/community/Gotags/Gotags/etc/api.xml +58 -0
- app/code/community/Gotags/Gotags/etc/config.xml +66 -0
- app/design/adminhtml/default/default/layout/gotags.xml +8 -0
- app/design/adminhtml/default/default/template/gotags/gotagsbackend.phtml +88 -0
- package.xml +22 -0
app/code/community/Gotags/Gotags/Block/Adminhtml/Gotagsbackend.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Gotags_Gotags_Block_Adminhtml_Gotagsbackend extends Mage_Adminhtml_Block_Template {
|
| 4 |
+
|
| 5 |
+
}
|
app/code/community/Gotags/Gotags/Helper/Data.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Gotags_Gotags_Helper_Data extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
}
|
| 5 |
+
|
app/code/community/Gotags/Gotags/Model/Api.php
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Gotags_Gotags_Model_Api extends Mage_Api_Model_Resource_Abstract {
|
| 4 |
+
|
| 5 |
+
protected $_storeId;
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Find a product by it's rewrite
|
| 9 |
+
*
|
| 10 |
+
* @param array $filters
|
| 11 |
+
*
|
| 12 |
+
* @return array
|
| 13 |
+
*/
|
| 14 |
+
public function search($filters) {
|
| 15 |
+
|
| 16 |
+
if (!array_key_exists('sku', $filters) || !trim($filters['sku']))
|
| 17 |
+
$this->_fault('filters_invalid', 'sku missing from filter array');
|
| 18 |
+
|
| 19 |
+
$product = $this->_findProductBySku($filters['sku']);
|
| 20 |
+
|
| 21 |
+
if (!$product)
|
| 22 |
+
$this->_fault('product_not_found', "no product found for ({$filters['sku']}");
|
| 23 |
+
|
| 24 |
+
return array(
|
| 25 |
+
'filters' => $filters,
|
| 26 |
+
'product' => $product->getData(),
|
| 27 |
+
);
|
| 28 |
+
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Use the rewrite index to find a product
|
| 33 |
+
*
|
| 34 |
+
* @param $sku
|
| 35 |
+
*
|
| 36 |
+
* @return Mage_Catalog_Model_Product
|
| 37 |
+
*/
|
| 38 |
+
protected function _findProductBySku($sku) {
|
| 39 |
+
|
| 40 |
+
$productid = Mage::getModel('catalog/product')->getIdBySku(trim($sku));
|
| 41 |
+
if(!$productid)
|
| 42 |
+
return null;
|
| 43 |
+
|
| 44 |
+
$product = new Mage_Catalog_Model_Product();
|
| 45 |
+
$product->load($productid);
|
| 46 |
+
|
| 47 |
+
return $product->getId() ? $product : null;
|
| 48 |
+
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Check the database and return valid users by their email address
|
| 53 |
+
*
|
| 54 |
+
* @param array $users
|
| 55 |
+
*
|
| 56 |
+
* @return array
|
| 57 |
+
*/
|
| 58 |
+
protected function _getValidUsers(array $users) {
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* get the default store id
|
| 62 |
+
* @todo there should be a better way of doing this
|
| 63 |
+
*/
|
| 64 |
+
$websites = Mage::app()->getWebsites();
|
| 65 |
+
$defaultId = array_shift($websites)->getId();
|
| 66 |
+
|
| 67 |
+
$valid = array();
|
| 68 |
+
|
| 69 |
+
foreach ($users as $_email) {
|
| 70 |
+
|
| 71 |
+
if (!filter_var($_email, FILTER_VALIDATE_EMAIL))
|
| 72 |
+
continue;
|
| 73 |
+
|
| 74 |
+
/** @var Mage_Customer_Model_Customer $customer */
|
| 75 |
+
$customer = Mage::getModel("customer/customer");
|
| 76 |
+
$customer->setWebsiteId($defaultId);
|
| 77 |
+
$customer->loadByEmail($_email);
|
| 78 |
+
|
| 79 |
+
if ($customer && $customer->getId())
|
| 80 |
+
$valid[] = $customer;
|
| 81 |
+
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
return $valid;
|
| 85 |
+
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Returns the first store id
|
| 90 |
+
* @todo there should be a better way of doing this
|
| 91 |
+
* @return int
|
| 92 |
+
*/
|
| 93 |
+
protected function _getStoreId() {
|
| 94 |
+
|
| 95 |
+
if (!$this->_storeId) {
|
| 96 |
+
|
| 97 |
+
$stores = Mage::app()->getStores();
|
| 98 |
+
$this->_storeId = array_shift($stores)->getId();
|
| 99 |
+
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
return $this->_storeId;
|
| 103 |
+
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/**
|
| 107 |
+
* Lookup product and add it to the customer cart
|
| 108 |
+
*
|
| 109 |
+
* @param array $filters
|
| 110 |
+
*
|
| 111 |
+
* @return array
|
| 112 |
+
*/
|
| 113 |
+
public function addProduct($filters) {
|
| 114 |
+
|
| 115 |
+
if (!array_key_exists('sku', $filters) || !trim($filters['sku']))
|
| 116 |
+
$this->_fault('filters_invalid', 'sku missing from filter array');
|
| 117 |
+
|
| 118 |
+
if (!array_key_exists('customers', $filters) || !trim($filters['customers']))
|
| 119 |
+
$this->_fault('filters_invalid', 'customers missing from filter array');
|
| 120 |
+
|
| 121 |
+
$filters['customers'] = explode(',', trim($filters['customers']));
|
| 122 |
+
if (!count($filters['customers']))
|
| 123 |
+
$this->_fault('filters_invalid', 'customers key passed but empty');
|
| 124 |
+
|
| 125 |
+
$filters['customers'] = $this->_getValidUsers($filters['customers']);
|
| 126 |
+
|
| 127 |
+
if (!count($filters['customers']))
|
| 128 |
+
$this->_fault('filters_invalid', 'customers key passed but no valid customers found');
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
* find the product by sku
|
| 133 |
+
*/
|
| 134 |
+
|
| 135 |
+
/** @var Mage_Catalog_Model_Product $product */
|
| 136 |
+
$product = $this->_findProductBySku($filters['sku']);
|
| 137 |
+
if (!$product)
|
| 138 |
+
$this->_fault('product_not_found', "Product with given sku ({$filters['sku']}) not found");
|
| 139 |
+
|
| 140 |
+
if ($product->getTypeId() == 'bundle')
|
| 141 |
+
$this->_fault('not_supported', "Bundled products are not supported");
|
| 142 |
+
|
| 143 |
+
if ($product->getTypeId() == 'grouped')
|
| 144 |
+
$this->_fault('not_supported', "Grouped products are not supported");
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* If we have options, try to find the closest product attributes
|
| 148 |
+
*/
|
| 149 |
+
$optionsToUse = array();
|
| 150 |
+
|
| 151 |
+
if (array_key_exists('options', $filters) && is_array($filters['options'])) {
|
| 152 |
+
|
| 153 |
+
$filters['options'] = array_map('strtolower', $filters['options']);
|
| 154 |
+
|
| 155 |
+
/**
|
| 156 |
+
* For the options to work, we need the configurable product
|
| 157 |
+
*/
|
| 158 |
+
if (!$product->isConfigurable()) {
|
| 159 |
+
|
| 160 |
+
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* try to find a configurable parent
|
| 164 |
+
*/
|
| 165 |
+
if (count($parentIds)) {
|
| 166 |
+
|
| 167 |
+
$_parentLookup = new Mage_Catalog_Model_Product();
|
| 168 |
+
$_parentLookup->load($parentIds[0]);
|
| 169 |
+
$product = $_parentLookup->getId() ? $_parentLookup : null;
|
| 170 |
+
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* With the configurable product, try to find the best suited options
|
| 177 |
+
*/
|
| 178 |
+
if($product->isConfigurable()) {
|
| 179 |
+
|
| 180 |
+
$_bestSuitedAttributes = [];
|
| 181 |
+
$_tmpOptions = $filters['options'];
|
| 182 |
+
|
| 183 |
+
/** @var Mage_Catalog_Model_Product_Type_Configurable_Attribute $_attr */
|
| 184 |
+
foreach ($product->getTypeInstance(true)->getConfigurableAttributes($product) as $_attr) {
|
| 185 |
+
|
| 186 |
+
$_prices = $_attr->getPrices();
|
| 187 |
+
if (is_array($_prices))
|
| 188 |
+
foreach ($_prices as $_item) {
|
| 189 |
+
|
| 190 |
+
foreach ($_tmpOptions as $_opt) {
|
| 191 |
+
|
| 192 |
+
if ($_opt == strtolower($_item['label'])) {
|
| 193 |
+
|
| 194 |
+
$_bestSuitedAttributes[$_opt] = array(
|
| 195 |
+
'attribute_id' => $_attr->getAttributeId(),
|
| 196 |
+
'attribute_code' => $_attr->getAttributeCode(),
|
| 197 |
+
'attribute_label' => $_attr->getLabel(),
|
| 198 |
+
'option_id' => $_item['value_index'],
|
| 199 |
+
);
|
| 200 |
+
|
| 201 |
+
unset($_tmpOptions[$_opt]);
|
| 202 |
+
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
/**
|
| 212 |
+
* If these two are equal, we found the correct product!
|
| 213 |
+
* convert the attributes to the array required later
|
| 214 |
+
*/
|
| 215 |
+
$optionsToUse = array('super_attribute' => array());
|
| 216 |
+
if (count($_bestSuitedAttributes) == count($filters['options'])) {
|
| 217 |
+
|
| 218 |
+
foreach ($_bestSuitedAttributes as $_attr)
|
| 219 |
+
$optionsToUse['super_attribute'][(int) $_attr['attribute_id']] = (int) $_attr['option_id'];
|
| 220 |
+
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
if (empty($optionsToUse['super_attribute']))
|
| 224 |
+
$this->_fault('product_not_found', "Configurable product found, but options didn't match");
|
| 225 |
+
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
if (!$product)
|
| 231 |
+
$this->_fault('product_not_found', "no product found for ({$filters['sku']}");
|
| 232 |
+
|
| 233 |
+
if ($product->isConfigurable() && empty($optionsToUse))
|
| 234 |
+
$this->_fault('product_not_found', "Configurable product given, but options were not provided");
|
| 235 |
+
|
| 236 |
+
/**
|
| 237 |
+
* get the product and add it to the customer carts
|
| 238 |
+
*/
|
| 239 |
+
$_varien = new Varien_Object(array_merge(array(
|
| 240 |
+
'product' => $product->getId(),
|
| 241 |
+
'qty' => 1,
|
| 242 |
+
), $optionsToUse));
|
| 243 |
+
|
| 244 |
+
/** @var Mage_Customer_Model_Customer $_customer */
|
| 245 |
+
foreach ($filters['customers'] as $_customer) {
|
| 246 |
+
|
| 247 |
+
try {
|
| 248 |
+
|
| 249 |
+
/**
|
| 250 |
+
* try to find a cart for the customer
|
| 251 |
+
*/
|
| 252 |
+
/** @var Mage_Sales_Model_Resource_Quote_Collection $_quoteLookup */
|
| 253 |
+
$_quoteLookup = Mage::getModel('sales/quote')->getCollection();
|
| 254 |
+
$_quoteLookup->addFieldToSelect('entity_id');
|
| 255 |
+
$_quoteLookup->addFieldToFilter('customer_id', $_customer->getId());
|
| 256 |
+
$_quoteLookup->addFieldToFilter('is_active', 1);
|
| 257 |
+
$_quoteLookup->addOrder('entity_id', 'DESC');
|
| 258 |
+
$_customerQuoteId = $_quoteLookup->load()->getFirstItem()->getId();
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
/**
|
| 262 |
+
* no cart found so create one
|
| 263 |
+
*/
|
| 264 |
+
if (!$_customerQuoteId) {
|
| 265 |
+
|
| 266 |
+
/** @var Mage_Checkout_Model_Cart_Api $cart_api */
|
| 267 |
+
$cart_api = Mage::getModel('checkout/cart_api');
|
| 268 |
+
$_customerQuoteId = $cart_api->create($this->_getStoreId());
|
| 269 |
+
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
$_currentCart = Mage::getModel('sales/quote')->loadByIdWithoutStore($_customerQuoteId);
|
| 273 |
+
$_currentCart->setIsActive(true);
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
* Cloning the product is required as it gets modified somewhere down the code pile
|
| 277 |
+
*/
|
| 278 |
+
$_temp = clone $product;
|
| 279 |
+
$res = $_currentCart->addProduct($_temp, $_varien);
|
| 280 |
+
|
| 281 |
+
if(is_string($res)) // a string thrown is an error
|
| 282 |
+
$this->_fault('cart_error', $res);
|
| 283 |
+
|
| 284 |
+
$_currentCart->setCustomer($_customer);
|
| 285 |
+
$_currentCart->assignCustomer($_customer);
|
| 286 |
+
$_currentCart->collectTotals();
|
| 287 |
+
$_currentCart->save();
|
| 288 |
+
|
| 289 |
+
} catch(Exception $e) {
|
| 290 |
+
$this->_fault('cart_error', $e->getMessage());
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
return array(
|
| 296 |
+
'sku' => $filters['sku'],
|
| 297 |
+
'customers' => array_map(function ($item) {
|
| 298 |
+
return $item->getData();
|
| 299 |
+
}, $filters['customers']),
|
| 300 |
+
'product' => $product->getData(),
|
| 301 |
+
'options' => $_varien->getData(),
|
| 302 |
+
);
|
| 303 |
+
|
| 304 |
+
}
|
| 305 |
+
}
|
app/code/community/Gotags/Gotags/controllers/Adminhtml/GotagsbackendController.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Gotags_Gotags_Adminhtml_GotagsbackendController extends Mage_Adminhtml_Controller_Action
|
| 3 |
+
{
|
| 4 |
+
public function indexAction()
|
| 5 |
+
{
|
| 6 |
+
$this->loadLayout();
|
| 7 |
+
$this->_title($this->__("GOtags"));
|
| 8 |
+
$this->renderLayout();
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/community/Gotags/Gotags/etc/api.xml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<api>
|
| 4 |
+
<resources>
|
| 5 |
+
<gotags_api translate="title" module="gotags">
|
| 6 |
+
<title>Gotags</title>
|
| 7 |
+
<acl>gotags_api</acl>
|
| 8 |
+
<model>gotags/api</model>
|
| 9 |
+
<methods>
|
| 10 |
+
<search translate="title" module="gotags">
|
| 11 |
+
<title>Search items</title>
|
| 12 |
+
<acl>gotags_api/search</acl>
|
| 13 |
+
</search>
|
| 14 |
+
<addproduct translate="title" module="gotags">
|
| 15 |
+
<title>Add product to basket</title>
|
| 16 |
+
<acl>gotags_api/addproduct</acl>
|
| 17 |
+
</addproduct>
|
| 18 |
+
</methods>
|
| 19 |
+
<faults module="gotags">
|
| 20 |
+
<filters_invalid>
|
| 21 |
+
<code>100</code>
|
| 22 |
+
<message>Invalid filters specified. Details in error message.</message>
|
| 23 |
+
</filters_invalid>
|
| 24 |
+
<product_not_found>
|
| 25 |
+
<code>102</code>
|
| 26 |
+
<message>Product doesn't exist.</message>
|
| 27 |
+
</product_not_found>
|
| 28 |
+
<customer_not_found>
|
| 29 |
+
<code>103</code>
|
| 30 |
+
<message>Customer not found.</message>
|
| 31 |
+
</customer_not_found>
|
| 32 |
+
<cart_error>
|
| 33 |
+
<code>104</code>
|
| 34 |
+
<message>Add to cart error.</message>
|
| 35 |
+
</cart_error>
|
| 36 |
+
<not_supported>
|
| 37 |
+
<code>105</code>
|
| 38 |
+
<message>Bundle items are not supported.</message>
|
| 39 |
+
</not_supported>
|
| 40 |
+
</faults>
|
| 41 |
+
</gotags_api>
|
| 42 |
+
</resources>
|
| 43 |
+
<acl>
|
| 44 |
+
<resources>
|
| 45 |
+
<gotags_api translate="title" module="gotags">
|
| 46 |
+
<title>Gotags</title>
|
| 47 |
+
<sort_order>2000</sort_order>
|
| 48 |
+
<search translate="title" module="gotags">
|
| 49 |
+
<title>Search items</title>
|
| 50 |
+
</search>
|
| 51 |
+
<addproduct translate="title" module="gotags">
|
| 52 |
+
<title>Add product to basket</title>
|
| 53 |
+
</addproduct>
|
| 54 |
+
</gotags_api>
|
| 55 |
+
</resources>
|
| 56 |
+
</acl>
|
| 57 |
+
</api>
|
| 58 |
+
</config>
|
app/code/community/Gotags/Gotags/etc/config.xml
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Gotags_Gotags>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</Gotags_Gotags>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<helpers>
|
| 10 |
+
<gotags>
|
| 11 |
+
<class>Gotags_Gotags_Helper</class>
|
| 12 |
+
</gotags>
|
| 13 |
+
</helpers>
|
| 14 |
+
<blocks>
|
| 15 |
+
<gotags>
|
| 16 |
+
<class>Gotags_Gotags_Block</class>
|
| 17 |
+
</gotags>
|
| 18 |
+
</blocks>
|
| 19 |
+
</global>
|
| 20 |
+
<admin>
|
| 21 |
+
<routers>
|
| 22 |
+
<gotags>
|
| 23 |
+
<use>admin</use>
|
| 24 |
+
<args>
|
| 25 |
+
<module>Gotags_Gotags</module>
|
| 26 |
+
<frontName>gotags</frontName>
|
| 27 |
+
</args>
|
| 28 |
+
</gotags>
|
| 29 |
+
</routers>
|
| 30 |
+
</admin>
|
| 31 |
+
<adminhtml>
|
| 32 |
+
<menu>
|
| 33 |
+
<system>
|
| 34 |
+
<children>
|
| 35 |
+
<gotagsbackend module="gotags">
|
| 36 |
+
<title>GOtags</title>
|
| 37 |
+
<sort_order>0</sort_order>
|
| 38 |
+
<action>gotags/adminhtml_gotagsbackend</action>
|
| 39 |
+
</gotagsbackend>
|
| 40 |
+
</children>
|
| 41 |
+
</system>
|
| 42 |
+
</menu>
|
| 43 |
+
<acl>
|
| 44 |
+
<resources>
|
| 45 |
+
<all>
|
| 46 |
+
<title>Allow Everything</title>
|
| 47 |
+
</all>
|
| 48 |
+
<admin>
|
| 49 |
+
<children>
|
| 50 |
+
<gotags translate="title" module="gotags">
|
| 51 |
+
<title>Gotags</title>
|
| 52 |
+
<sort_order>1000</sort_order>
|
| 53 |
+
</gotags>
|
| 54 |
+
</children>
|
| 55 |
+
</admin>
|
| 56 |
+
</resources>
|
| 57 |
+
</acl>
|
| 58 |
+
<layout>
|
| 59 |
+
<updates>
|
| 60 |
+
<gotags>
|
| 61 |
+
<file>gotags.xml</file>
|
| 62 |
+
</gotags>
|
| 63 |
+
</updates>
|
| 64 |
+
</layout>
|
| 65 |
+
</adminhtml>
|
| 66 |
+
</config>
|
app/design/adminhtml/default/default/layout/gotags.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<gotags_adminhtml_gotagsbackend_index>
|
| 4 |
+
<reference name="content">
|
| 5 |
+
<block type="gotags/adminhtml_gotagsbackend" name="gotagsbackend" template="gotags/gotagsbackend.phtml"/>
|
| 6 |
+
</reference>
|
| 7 |
+
</gotags_adminhtml_gotagsbackend_index>
|
| 8 |
+
</layout>
|
app/design/adminhtml/default/default/template/gotags/gotagsbackend.phtml
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div class="content-header">
|
| 2 |
+
<h3>GOtags</h3>
|
| 3 |
+
</div>
|
| 4 |
+
<div>
|
| 5 |
+
<table>
|
| 6 |
+
<tr>
|
| 7 |
+
<td style="width:60%">
|
| 8 |
+
<h4>Step 1 - Enabling the SOAP API</h4>
|
| 9 |
+
<p>For GOtags to be able to communicate with your store, we need to be able to communicate via the SOAP API. To enable the SOAP API you must first create a user and role for GOtags, and then add this information to your GOtags account via the GOtags website. The video below shows the steps described below.</p>
|
| 10 |
+
<ol style="list-style-type: decimal-leading-zero; margin-left:50px;">
|
| 11 |
+
<li>In your store admin area, go to System -> Web Services -> <a href="<?php echo Mage::helper("adminhtml")->getUrl("adminhtml/api_role") ?>" target="_blank">SOAP/XML-RPC - Roles</a></li>
|
| 12 |
+
<li>
|
| 13 |
+
Click <em>Add New Role</em>
|
| 14 |
+
<ul style="list-style-type: disc; margin-left:50px;">
|
| 15 |
+
<li>Enter the Role Name, the example uses Gotags</li>
|
| 16 |
+
<li>Under Role Resources, ensure that the select entry is set to Custom</li>
|
| 17 |
+
<li>Find the Gotags checkbox and ensure both checkboxes are selected</li>
|
| 18 |
+
<li>Save the role</li>
|
| 19 |
+
</ul>
|
| 20 |
+
</li>
|
| 21 |
+
<li>Goto System -> Web Services -> <a href="<?php echo Mage::helper("adminhtml")->getUrl("adminhtml/api_user") ?>" target="_blank">SOAP/XML-RPC - Users</a></li>
|
| 22 |
+
<li>
|
| 23 |
+
Click <em>Add New User</em>
|
| 24 |
+
<ul style="list-style-type: disc; margin-left:50px;">
|
| 25 |
+
<li>Enter the require details in the form.</li>
|
| 26 |
+
<li>Ensure you use a secure username and API Key, and make a note of it - you'll need to give these details to GOtags later.</li>
|
| 27 |
+
<li>Here's a random string if you need one: <?php echo sha1('gotags_is_awesome_'.microtime()) ?></li>
|
| 28 |
+
<li>Save the user</li>
|
| 29 |
+
</ul>
|
| 30 |
+
</li>
|
| 31 |
+
</ol>
|
| 32 |
+
<h4 style="margin-top:50px">Step 2 - Connecting with GOtags</h4>
|
| 33 |
+
<p>For GOtags to be able to interact with your store, we need to know the details previously entered.</p>
|
| 34 |
+
<ol style="list-style-type: decimal-leading-zero; margin-left:50px;">
|
| 35 |
+
<li>Visit <a href="https://gotags.co.uk" target="_blank">the GOtags website</a></li>
|
| 36 |
+
<li>If you are not logged in, first connect with GOtags using your Instagram account</li>
|
| 37 |
+
<li>When logged in, go to <a href="https://gotags.co.uk/accounts" target="_blank">your accounts page</a> by clicking the link of following the link in the navigation</li>
|
| 38 |
+
<li>Click the edit icon on the account you wish to enter, it's name will be the same as your Instagram account by default</li>
|
| 39 |
+
<li>
|
| 40 |
+
In the details form, find the section "Magento Connect"
|
| 41 |
+
<ul style="list-style-type: disc; margin-left:50px;">
|
| 42 |
+
<li>Enter your domain name without any additional text (no "index.php")</li>
|
| 43 |
+
<li>Enter the username and API key previously created in Step 1</li>
|
| 44 |
+
<li>Save the form</li>
|
| 45 |
+
</ul>
|
| 46 |
+
</li>
|
| 47 |
+
</ol>
|
| 48 |
+
<h4 style="margin-top:50px">Step 3 - Check setup</h4>
|
| 49 |
+
<p>Click the below button to check your setup was successful:</p>
|
| 50 |
+
<p id="check-setup-messages"></p>
|
| 51 |
+
<a href="#" id="gotags-check" style="color: #fff; background-color: #d6443e; border-color: #cf322c; padding: 5px 10px; font-size: 16px; border-radius: 3px; margin:10px; display:inline-block">Check setup</a>
|
| 52 |
+
<script>
|
| 53 |
+
document.getElementById('gotags-check').onclick = function(event) {
|
| 54 |
+
event.preventDefault();
|
| 55 |
+
new Ajax.Request('https://gotags.co.uk/api/checkMagentoStatus', {
|
| 56 |
+
parameters: {
|
| 57 |
+
domain: location.protocol+'://'+location.host
|
| 58 |
+
},
|
| 59 |
+
method:'get',
|
| 60 |
+
requestHeaders: {Accept: 'application/json'},
|
| 61 |
+
onSuccess: function(response) {
|
| 62 |
+
if (response && response.responseJSON && response.responseJSON.code == 200) {
|
| 63 |
+
document.getElementById('check-setup-messages').innerHTML = 'All good! Setup successful';
|
| 64 |
+
document.getElementById('check-setup-messages').style.color = 'green';
|
| 65 |
+
} else {
|
| 66 |
+
document.getElementById('check-setup-messages').style.color = 'red';
|
| 67 |
+
document.getElementById('check-setup-messages').innerHTML = 'Unknown error';
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
onFailure: function(response) {
|
| 71 |
+
response.message = response.responseJSON.message ? response.responseJSON.message : 'None given [this is double bad]';
|
| 72 |
+
document.getElementById('check-setup-messages').style.color = 'red';
|
| 73 |
+
document.getElementById('check-setup-messages').innerHTML = 'Error! We couldn\'t verify your setup (error: '+response.message+')';
|
| 74 |
+
}
|
| 75 |
+
});
|
| 76 |
+
}
|
| 77 |
+
</script>
|
| 78 |
+
<h4 style="margin-top:50px">Using GOtags</h4>
|
| 79 |
+
<p>Your store should now be successfully connected with GOtags, and you can start to use GOtags within your Instagram photos. It's really simple: when uploading a picture to Instagram, simply enter the SKU code of the product into the location field, and tag @Gotags in the comment.</p>
|
| 80 |
+
<p>The rest is GOtag magic - when a user comments on your photo with "#buy" we'll try to add the item to their basket, if we can't we'll email them a link to your store product.</p>
|
| 81 |
+
<p><strong>Remember!</strong> Users can buy with options. For example, to buy jeans in size 32, and color "khaki", a user comments "#buy 32 khaki"</p>
|
| 82 |
+
</td>
|
| 83 |
+
<td style="width:40%">
|
| 84 |
+
<iframe width="560" height="315" src="https://gotags.co.uk/magento/embed" frameborder="0" allowfullscreen></iframe>
|
| 85 |
+
</td>
|
| 86 |
+
</tr>
|
| 87 |
+
</table>
|
| 88 |
+
</div>
|
package.xml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>GOtags_GOtags</name>
|
| 4 |
+
<version>0.0.1</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://www.gnu.org/copyleft/gpl.html">GNU General Public License v3 (GPL-3)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>GOtags monazites your Instagram photos by allowing your users to buy directly from your photo pages.</summary>
|
| 10 |
+
<description>Enabling this module allows the GOtags service to provide your Instagram users the ability to buy directly from your Instagram photo pages.
|
| 11 |
+

|
| 12 |
+
Simply connect your Instagram account with GOtags, provide us some simple details, and tag @GOtags in your photos you wish to enable and we'll do the rest!
|
| 13 |
+

|
| 14 |
+
https://gotags.co.uk</description>
|
| 15 |
+
<notes>GOtags service is currently under beta, as such this process may change and the terms of the module may change in later versions.</notes>
|
| 16 |
+
<authors><author><name>Ashley White</name><user>gotags</user><email>hello@gotags.co.uk</email></author></authors>
|
| 17 |
+
<date>2014-07-07</date>
|
| 18 |
+
<time>11:33:54</time>
|
| 19 |
+
<contents><target name="magecommunity"><dir name="Gotags"><dir name="Gotags"><dir name="Block"><dir name="Adminhtml"><file name="Gotagsbackend.php" hash="58b9abf59a5b0cad4c1e57306c7a0d18"/></dir></dir><dir name="Helper"><file name="Data.php" hash="6423d0cda77417cabc378396a5db9dcf"/></dir><dir name="Model"><file name="Api.php" hash="a2c96072dec575e1b72da3bf061d4d7a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="GotagsbackendController.php" hash="c3097fa781ececd78d359130e163ccaa"/></dir></dir><dir name="etc"><file name="api.xml" hash="5bcbac16f44cd4d04034fcaa795e0f56"/><file name="config.xml" hash="4086c55e42511a1d40620bf713e37b1b"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="gotags"><file name="gotagsbackend.phtml" hash="bdc13469149436754e4bfcca750e8d91"/></dir></dir><dir name="layout"><file name="gotags.xml" hash="244d1cf285d1d41021ceeb79b80876a8"/></dir></dir></dir></dir></target></contents>
|
| 20 |
+
<compatible/>
|
| 21 |
+
<dependencies><required><php><min>5.5.0</min><max>5.5.14</max></php></required></dependencies>
|
| 22 |
+
</package>
|
