Version Notes
This release addresses
Price lookup change.
Label change to address the same.
Download this release
Release Info
| Developer | Krishna |
| Extension | sellonflubit |
| Version | 0.3.0 |
| Comparing to | |
| See all releases | |
Code changes from version 0.2.8 to 0.3.0
- app/code/community/Flubit/Flubit/Model/Flubit.php +1122 -1122
- app/code/community/Flubit/Flubit/Model/Flubit/Price.php +26 -27
- app/code/community/Flubit/Flubit/controllers/Adminhtml/FlubitController.php +233 -233
- app/code/community/Flubit/Flubit/etc/system.xml +177 -177
- app/code/community/Flubit/Flubitlog/controllers/Adminhtml/FlubitlogController.php +260 -260
- package.xml +12 -18
app/code/community/Flubit/Flubit/Model/Flubit.php
CHANGED
|
@@ -1,1123 +1,1123 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
/**
|
| 4 |
-
* Class Flubit Model Flubit
|
| 5 |
-
*
|
| 6 |
-
* @package Flubit
|
| 7 |
-
* @category Flubit_Model
|
| 8 |
-
* @author Flubit team
|
| 9 |
-
*/
|
| 10 |
-
class Flubit_Flubit_Model_Flubit extends Mage_Core_Model_Abstract {
|
| 11 |
-
|
| 12 |
-
const CONSUMER_API = 'flubit_section/flubit_configuration/flubit_consumer_key';
|
| 13 |
-
const SECRET_KEY = 'flubit_section/flubit_configuration/flubit_secret';
|
| 14 |
-
const CONSUMER_URL = 'flubit_section/flubit_configuration/flubit_url';
|
| 15 |
-
const LOG_TYPE = 'flubit_section/flubit_setup/log_type_list';
|
| 16 |
-
const LOGDATE_OLDER = 'flubit_section/flubit_setup/logdate_cron_settings';
|
| 17 |
-
|
| 18 |
-
/**
|
| 19 |
-
* Constructor for load Flubit Order
|
| 20 |
-
*
|
| 21 |
-
*/
|
| 22 |
-
protected function _construct() {
|
| 23 |
-
try {
|
| 24 |
-
$this->_init("flubit/flubit");
|
| 25 |
-
} catch (Exception $e) {
|
| 26 |
-
Mage::log('_construct ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 27 |
-
}
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
/**
|
| 31 |
-
* Method to get Flubit Orders
|
| 32 |
-
*/
|
| 33 |
-
public function getFlubitOrders() {
|
| 34 |
-
try {
|
| 35 |
-
$config = Mage::getModel('flubit/config');
|
| 36 |
-
$data = $config->getFlubitOrders();
|
| 37 |
-
} catch (Exception $e) {
|
| 38 |
-
Mage::log('getFlubitOrders ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 39 |
-
}
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
/**
|
| 43 |
-
* Method to Process Flubit Orders
|
| 44 |
-
*/
|
| 45 |
-
public function processFlubitOrders() {
|
| 46 |
-
try {
|
| 47 |
-
$this->refundFlubitOrders();
|
| 48 |
-
} catch (Exception $e) {
|
| 49 |
-
Mage::log('processFlubitOrders ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 50 |
-
}
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
/**
|
| 54 |
-
* Method to Dispatch Flubit Orders
|
| 55 |
-
*/
|
| 56 |
-
public function dispatchFlubitOrders() {
|
| 57 |
-
try {
|
| 58 |
-
$config = Mage::getModel('flubit/config');
|
| 59 |
-
$data = $config->dispatchFlubitOrders();
|
| 60 |
-
} catch (Exception $e) {
|
| 61 |
-
Mage::log('dispatchFlubitOrders ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 62 |
-
}
|
| 63 |
-
}
|
| 64 |
-
|
| 65 |
-
/**
|
| 66 |
-
* Method to Cancel Flubit Orders
|
| 67 |
-
*/
|
| 68 |
-
public function cancelFlubitOrders() {
|
| 69 |
-
try {
|
| 70 |
-
$config = Mage::getModel('flubit/config');
|
| 71 |
-
$data = $config->cancelFlubitOrders();
|
| 72 |
-
} catch (Exception $e) {
|
| 73 |
-
Mage::log('cancelFlubitOrders ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 74 |
-
}
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
/**
|
| 78 |
-
* Method to Refund Flubit Orders
|
| 79 |
-
*/
|
| 80 |
-
public function refundFlubitOrders() {
|
| 81 |
-
try {
|
| 82 |
-
$config = Mage::getModel('flubit/config');
|
| 83 |
-
$data = $config->refundFlubitOrders();
|
| 84 |
-
} catch (Exception $e) {
|
| 85 |
-
Mage::log('refundFlubitOrders ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 86 |
-
}
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
/**
|
| 90 |
-
* Method to Send Product Feed
|
| 91 |
-
*/
|
| 92 |
-
public function sendProductFeed() {
|
| 93 |
-
try {
|
| 94 |
-
$this->_updateFlubitPrices();
|
| 95 |
-
$this->_updateFlubitQty();
|
| 96 |
-
$this->generateProductXML();
|
| 97 |
-
} catch (Exception $e) {
|
| 98 |
-
Mage::log('sendProductFeed ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 99 |
-
}
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
/**
|
| 103 |
-
* Method to delete log files and flubitlog table
|
| 104 |
-
*/
|
| 105 |
-
public function archiveLog() {
|
| 106 |
-
//Mage::log('archive',null,'hum.log');
|
| 107 |
-
//$olderthen = Mage::getStoreConfig(self::LOGDATE_OLDER);
|
| 108 |
-
$logbefore = date('Y-m-d h:i:s', strtotime('-' . 30 . ' day'));
|
| 109 |
-
$flubitlogs = Mage::getModel('flubitlog/flubitlog')->getCollection();
|
| 110 |
-
$flubitlogs->addFieldToFilter('datetime', array('lteq' => $logbefore));
|
| 111 |
-
$flubitlogs->load();
|
| 112 |
-
foreach ($flubitlogs as $flubitlog) {
|
| 113 |
-
$flubitlog->delete();
|
| 114 |
-
}
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
/**
|
| 118 |
-
* Method to Generate Product Xml
|
| 119 |
-
*/
|
| 120 |
-
public function generateProductXML() { // generate product xml and send to flubit
|
| 121 |
-
$configure = $this->checkConfiguration();
|
| 122 |
-
if ($configure->error == 'true' && $configure->right == 'false') {
|
| 123 |
-
Mage::throwException('Missing Keys in configuration');
|
| 124 |
-
}
|
| 125 |
-
// end checking of configuration
|
| 126 |
-
$this->_checkPendingFeedStatus();
|
| 127 |
-
|
| 128 |
-
// get the configuration from the file
|
| 129 |
-
$chunkSize = 10; // define if chunk size is not defined
|
| 130 |
-
$errorString = ''; // define blank error string
|
| 131 |
-
$returnString = '';
|
| 132 |
-
$errorFeed = '';
|
| 133 |
-
$productCount = 0;
|
| 134 |
-
$error = FALSE;
|
| 135 |
-
try {
|
| 136 |
-
$chunkSize = Mage::getStoreConfig('flubit_section/flubit_setup/flubit_chunk');
|
| 137 |
-
} catch (Exception $e) {
|
| 138 |
-
Mage::log('Could not retrive chunk size ' . $e, NULL, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 139 |
-
}
|
| 140 |
-
$allSku = array();
|
| 141 |
-
|
| 142 |
-
// get flubit collection for the prodcuts which are needed to be pushed
|
| 143 |
-
try {
|
| 144 |
-
$flubit_products = Mage::getModel('flubit/flubit')->getCollection()
|
| 145 |
-
->addFieldToFilter('status', '1')
|
| 146 |
-
->addFieldToFilter('is_deleted', '0')
|
| 147 |
-
->setOrder('flubit_id', 'ASC')
|
| 148 |
-
->setPageSize($chunkSize);
|
| 149 |
-
|
| 150 |
-
if (is_object($flubit_products)) {
|
| 151 |
-
if (count($flubit_products) > 0) {
|
| 152 |
-
|
| 153 |
-
$create_feed_prodcut_xml = ''; // initialise the new product xml
|
| 154 |
-
$update_feed_prodcut_xml = ''; // initialise the update product xml
|
| 155 |
-
|
| 156 |
-
$store = Mage::app()->getStore(); // get deafult store
|
| 157 |
-
$tax_calculation_obj = Mage::getModel('tax/calculation')->getRateRequest(null, null, null, $store);
|
| 158 |
-
|
| 159 |
-
$newXML = '';
|
| 160 |
-
$updateXML = '';
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
foreach ($flubit_products as $flubit_Prodcut) {
|
| 164 |
-
// get magento product id for the given sku
|
| 165 |
-
if ($flubit_Prodcut->getSku() == '') { // we cannot proceed further if sku is missing
|
| 166 |
-
Mage::log('Missing SKU for flubit product ', NULL, Flubit_Flubit_Helper_Data::FLUBIT_CREATE_PRODUCT);
|
| 167 |
-
// save the status to zero so that its called next time only once its updated from backend
|
| 168 |
-
$flubit_Prodcut->setStatus('0')
|
| 169 |
-
->save();
|
| 170 |
-
continue;
|
| 171 |
-
}
|
| 172 |
-
$product_id = Mage::getModel('catalog/product')->getIdBySku(trim($flubit_Prodcut->getSku()));
|
| 173 |
-
$product = Mage::getModel('catalog/product')->load($product_id);
|
| 174 |
-
|
| 175 |
-
// check if the prodcut exist in magento
|
| 176 |
-
if (!$product->getId()) {
|
| 177 |
-
Mage::log('Sku ' . $product->getSku() . ' does not found in Magento.', null, Flubit_Flubit_Helper_Data::FLUBIT_FAILED_PRODUCT);
|
| 178 |
-
$flubit_Prodcut->setStatus('0')
|
| 179 |
-
->save();
|
| 180 |
-
continue;
|
| 181 |
-
}
|
| 182 |
-
// if there is no EAN, ASIN, ISBN or MPN we can't push it to Flubit
|
| 183 |
-
if (!$this->checkEanValidation($product)) {
|
| 184 |
-
if (is_object($product)) {
|
| 185 |
-
|
| 186 |
-
$errorString .= '<tr>
|
| 187 |
-
<td style="padding:4px;">' . $product->getName() . '</td>
|
| 188 |
-
<td style="padding:4px;">' . $product->getSku() . ' </td>
|
| 189 |
-
<td style="padding:4px;"> ' . 'Missing Identifiers. ' . '</td>
|
| 190 |
-
</tr>';
|
| 191 |
-
|
| 192 |
-
$response = 'Product SKU : <b>"' . $product->getSku() . '"</b> identifiers is blank. Please update the data where appropriate and send again. ';
|
| 193 |
-
$feedid = 'Product identifiers validation failed.';
|
| 194 |
-
|
| 195 |
-
$this->logFlubitProductsRequestResponse('', $response, 'Create Product', $feedid);
|
| 196 |
-
|
| 197 |
-
Mage::log($product->getSku() . ' missing identifiers', null, Flubit_Flubit_Helper_Data::FLUBIT_FAILED_PRODUCT);
|
| 198 |
-
// save the status to zero so that its called next time only once its updated from backend
|
| 199 |
-
$flubit_Prodcut->setStatus('0')
|
| 200 |
-
->save();
|
| 201 |
-
} else {
|
| 202 |
-
Mage::log('Product was deleted from Magento SKU :' . $product->getSku(), null, Flubit_Flubit_Helper_Data::FLUBIT_FAILED_PRODUCT);
|
| 203 |
-
}
|
| 204 |
-
continue;
|
| 205 |
-
}
|
| 206 |
-
// if there is no image we can't push it to Flubit
|
| 207 |
-
if (!$this->checkImageValidation($product)) {
|
| 208 |
-
|
| 209 |
-
$errorString .= '<tr>
|
| 210 |
-
<td style="padding:4px;">' . $product->getName() . '</td>
|
| 211 |
-
<td style="padding:4px;">' . $product->getSku() . ' </td>
|
| 212 |
-
<td style="padding:4px;"> ' . 'No image is uploaded, so cannot be pushed to Flubit' . ' </td>
|
| 213 |
-
</tr>';
|
| 214 |
-
|
| 215 |
-
$response = 'Product SKU <b>"' . $product->getSku() . '"</b> image is not available. Please update the data where appropriate and send again. ';
|
| 216 |
-
$feedid = 'Product image validation failed.';
|
| 217 |
-
$this->logFlubitProductsRequestResponse('', $response, 'Create Product', $feedid);
|
| 218 |
-
Mage::log($product->getSku() . ' Image is not available. please update and send again.', null, Flubit_Flubit_Helper_Data::FLUBIT_FAILED_PRODUCT);
|
| 219 |
-
//the product has not been pushed and so should be treated as new
|
| 220 |
-
// save the status to zero so that its called next time only once its updated from backend
|
| 221 |
-
$flubit_Prodcut->setStatus('0')
|
| 222 |
-
->save();
|
| 223 |
-
continue;
|
| 224 |
-
}
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
$flubit_stat = $product->getFlubitProduct(); // if product flubit stat is true
|
| 228 |
-
$status_stat = $product->getStatus(); // check if the product is active or inactive in magento
|
| 229 |
-
$stock = $product->getStockItem();
|
| 230 |
-
//Mage::log($stock->getData(), null, 'test.log');
|
| 231 |
-
$stock_status = $stock->getIsInStock();
|
| 232 |
-
|
| 233 |
-
$qtyStock = 0;
|
| 234 |
-
try {
|
| 235 |
-
$qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
|
| 236 |
-
$taxclassid = $product->getData('tax_class_id');
|
| 237 |
-
$percent = Mage::getModel('tax/calculation')->getRate($tax_calculation_obj->setProductClassId($taxclassid));
|
| 238 |
-
} catch (Exception $e) {
|
| 239 |
-
Mage::log(__LINE__ . ' Exception getting cataloginventory/stock_item tax/calculation Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 240 |
-
}
|
| 241 |
-
|
| 242 |
-
if ((floor($qtyStock) != $qtyStock)) { // check if the quantity is decimal
|
| 243 |
-
$errorString .= '<tr>
|
| 244 |
-
<td style="padding:4px;">' . $product->getName() . '</td>
|
| 245 |
-
<td style="padding:4px;">' . $product->getSku() . ' </td>
|
| 246 |
-
<td style="padding:4px;"> ' . 'Quantity is in decimal. Product cannot be pushed to Flubit.' . ' </td>
|
| 247 |
-
</tr>';
|
| 248 |
-
|
| 249 |
-
$response = 'Product SKU <b>"' . $product->getSku() . '"</b> quantity is in decimal. Please Insert it in integer only.';
|
| 250 |
-
$feedid = 'Product quantity validation failed.';
|
| 251 |
-
$this->logFlubitProductsRequestResponse('', $response, 'Create Product', $feedid);
|
| 252 |
-
|
| 253 |
-
Mage::log('quantity is in decimal = ' . $qtyStock, null, 'flubit_create_product.log');
|
| 254 |
-
$flubit_Prodcut->setStatus('0')
|
| 255 |
-
->save();
|
| 256 |
-
continue;
|
| 257 |
-
}
|
| 258 |
-
|
| 259 |
-
if (($flubit_stat == 1) && ($status_stat == 1) && ($stock_status) && ($qtyStock > 0)) {
|
| 260 |
-
$status = 'true';
|
| 261 |
-
} else {
|
| 262 |
-
$status = 'false';
|
| 263 |
-
}
|
| 264 |
-
|
| 265 |
-
if ($flubit_Prodcut->getNew() == '1') {
|
| 266 |
-
if ($product->getSku() != '') { // check if prodcut SKU is not null
|
| 267 |
-
$newXML .= '<product sku="' . $product->getSku() . '">';
|
| 268 |
-
$newXML .= '<title><![CDATA[' . $product->getName() . ']]></title>';
|
| 269 |
-
$newXML .= "<is_active>$status</is_active>";
|
| 270 |
-
$newXML .= '<base_price>' . (number_format($flubit_Prodcut->getPrice(), 2, '.', '')) . '</base_price>';
|
| 271 |
-
$newXML .= '<stock>' . number_format((int) $qtyStock, 0, '.', '') . '</stock>';
|
| 272 |
-
$newXML .= '<description><![CDATA[' . $this->removeNonUtfCharacters($product->getDescription()) . ']]></description>';
|
| 273 |
-
|
| 274 |
-
if ($product->getImage() != 'no_selection') {
|
| 275 |
-
$newXML .= '<images>';
|
| 276 |
-
$image_path = Mage::helper('catalog/image')->init($product, 'image');
|
| 277 |
-
$newXML .= '<image><![CDATA[' . $image_path . ']]></image>';
|
| 278 |
-
$newXML .= ' </images>';
|
| 279 |
-
}
|
| 280 |
-
if ($product->getFlubitEan() || $product->getFlubitAsin() || $product->getFlubitIsbn() || $product->getFlubitMpn()) {
|
| 281 |
-
$newXML .= '<identifiers>';
|
| 282 |
-
if ($product->getFlubitEan())
|
| 283 |
-
$newXML .= '<identifier type="EAN">' . $product->getFlubitEan() . '</identifier>';
|
| 284 |
-
if ($product->getFlubitAsin())
|
| 285 |
-
$newXML .= '<identifier type="ASIN">' . $product->getFlubitAsin() . '</identifier>';
|
| 286 |
-
if ($product->getFlubitIsbn())
|
| 287 |
-
$newXML .= '<identifier type="ISBN">' . $product->getFlubitIsbn() . '</identifier>';
|
| 288 |
-
if ($product->getFlubitMpn())
|
| 289 |
-
$newXML .= '<identifier type="MPN">' . $product->getFlubitMpn() . '</identifier>';
|
| 290 |
-
$newXML .= '</identifiers>';
|
| 291 |
-
}
|
| 292 |
-
if ($product->getFlubitBrand())
|
| 293 |
-
$newXML .= '<brand>' . $product->getFlubitBrand() . '</brand>';
|
| 294 |
-
if ($product->getFlubitStandardDelivery() || $product->getFlubitExpressDelivery()) {
|
| 295 |
-
$newXML .= '<delivery_cost>';
|
| 296 |
-
if ($product->getFlubitStandardDelivery())
|
| 297 |
-
$newXML .= '<standard>' . number_format($product->getFlubitStandardDelivery(), 2, '.', '') . '</standard>';
|
| 298 |
-
if ($product->getFlubitExpressDelivery())
|
| 299 |
-
$newXML .= '<express>' . number_format($product->getFlubitExpressDelivery(), 2, '.', '') . '</express>';
|
| 300 |
-
$newXML .= '</delivery_cost>';
|
| 301 |
-
}
|
| 302 |
-
if ($product->getWeight())
|
| 303 |
-
$newXML .= '<weight>' . number_format($product->getWeight(), 1, '.', '') . '</weight>';
|
| 304 |
-
if ($percent)
|
| 305 |
-
$newXML .= '<tax_rate>' . number_format($percent, 2, '.', '') . '</tax_rate>';
|
| 306 |
-
$newXML .= '</product>';
|
| 307 |
-
}
|
| 308 |
-
} else {
|
| 309 |
-
$updateXML .= '<product sku="' . $product->getSku() . '">';
|
| 310 |
-
$updateXML .= "<is_active>$status</is_active>";
|
| 311 |
-
$updateXML .= '<base_price>' . (number_format($flubit_Prodcut->getPrice(), 2, '.', '')) . '</base_price>';
|
| 312 |
-
$updateXML .= '<stock>' . number_format($qtyStock, 0, '.', '') . '</stock>';
|
| 313 |
-
$updateXML .= '</product>';
|
| 314 |
-
}
|
| 315 |
-
|
| 316 |
-
// set the flubit product status in flubit
|
| 317 |
-
|
| 318 |
-
try {
|
| 319 |
-
$flubitActiveStatus = '0';
|
| 320 |
-
if ($status == 'true')
|
| 321 |
-
$flubitActiveStatus = '1';
|
| 322 |
-
if ($flubit_Prodcut->getActiveStatus() != $flubitActiveStatus) {
|
| 323 |
-
//$flubit_Prodcut->setData(array('flubit_id' => $flubit_Prodcut->getId(), 'active_status' => $flubitActiveStatus))
|
| 324 |
-
$flubit_Prodcut->setActiveStatus($flubitActiveStatus)
|
| 325 |
-
->save();
|
| 326 |
-
}
|
| 327 |
-
} catch (Exception $e) {
|
| 328 |
-
Mage::log(__LINE__ . 'Exception Savingt flubit/flubit Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 329 |
-
}
|
| 330 |
-
$allSku[] = $product->getSku();
|
| 331 |
-
//Mage::log('Prodcut ' . print_r($product->getData(), TRUE ) , NULL, 'optimise.log');
|
| 332 |
-
}
|
| 333 |
-
// end for each of product list generation
|
| 334 |
-
|
| 335 |
-
if ($newXML != '') {
|
| 336 |
-
$create_feed_prodcut_xml = '<?xml version="1.0" encoding="UTF-8"?><products>' . $newXML . '</products>';
|
| 337 |
-
}
|
| 338 |
-
if ($updateXML != '') {
|
| 339 |
-
$update_feed_prodcut_xml = '<?xml version="1.0" encoding="UTF-8"?><products>' . $updateXML . '</products>';
|
| 340 |
-
}
|
| 341 |
-
//Mage::log($create_feed_prodcut_xml, NULL, 'CreateProduct.xml');
|
| 342 |
-
//Mage::log($update_feed_prodcut_xml, NULL, 'UpdateProduct.xml');
|
| 343 |
-
//Mage::log(print_r($allSku, TRUE), NULL, 'allSku.xml');
|
| 344 |
-
// preparing error String to be displayed on press of sync button
|
| 345 |
-
$productCount = count($allSku);
|
| 346 |
-
|
| 347 |
-
if ($errorString != '') {
|
| 348 |
-
$errorString = '<div>Following product(s) has failed.</div><br/>
|
| 349 |
-
<style type="text/css">
|
| 350 |
-
#tableOuter1{
|
| 351 |
-
border-style: solid;
|
| 352 |
-
border-width: 1px;
|
| 353 |
-
border-collapse: collapse;
|
| 354 |
-
margin: 0;
|
| 355 |
-
padding:4;
|
| 356 |
-
width:100%;
|
| 357 |
-
}
|
| 358 |
-
|
| 359 |
-
#tableOuter1 th,#tableOuter1 td{
|
| 360 |
-
border-style: solid;
|
| 361 |
-
border-width: 0 1px 1px 0;
|
| 362 |
-
border-collapse: collapse;
|
| 363 |
-
margin: 0;
|
| 364 |
-
padding:4;
|
| 365 |
-
}
|
| 366 |
-
</style>
|
| 367 |
-
<table id="tableOuter1" cellspacing="0" cellpadding="0">
|
| 368 |
-
<tr>
|
| 369 |
-
<th width="250"><strong>Product Name</strong></th>
|
| 370 |
-
<th width="250"><strong>Product SKU</strong></th>
|
| 371 |
-
<th width="250"><strong>Error Message</strong></th>
|
| 372 |
-
</tr>
|
| 373 |
-
' . $errorString . '
|
| 374 |
-
</table>';
|
| 375 |
-
}
|
| 376 |
-
$failed_sku_create = array();
|
| 377 |
-
$failed_sku_update = array();
|
| 378 |
-
$createFailedCount = 0;
|
| 379 |
-
$updateFailedCount = 0;
|
| 380 |
-
$feedError = '';
|
| 381 |
-
$feedStatus = '';
|
| 382 |
-
$feedMode = '';
|
| 383 |
-
$feedResponseXML = '';
|
| 384 |
-
// get model of config
|
| 385 |
-
$config = Mage::getModel('flubit/config');
|
| 386 |
-
// send the prodcuct create feed to flubit and save the id returned to log
|
| 387 |
-
if ($create_feed_prodcut_xml != '') { // if create product feed is not null send to flubit
|
| 388 |
-
$create_result = $config->createFlubitProducts($create_feed_prodcut_xml);
|
| 389 |
-
if ($create_result != '') {
|
| 390 |
-
Mage::log($create_result, NULL, 'createfeed.log');
|
| 391 |
-
if (is_object($create_result)) {
|
| 392 |
-
if ($create_result->getName() == 'id') {
|
| 393 |
-
$this->feedLog($create_result, 'Create');
|
| 394 |
-
$returnString .= 'Created Feed ID : ' . (String) $create_result . '<br/>';
|
| 395 |
-
// get the feed response if its a create feed
|
| 396 |
-
$feedCheckResponseCreate = $this->getFeedErrors($create_result);
|
| 397 |
-
|
| 398 |
-
$createFailedCount = $feedCheckResponseCreate->failedCount;
|
| 399 |
-
$errorString .= $feedCheckResponseCreate->html;
|
| 400 |
-
$failed_sku_create = $feedCheckResponseCreate->sku;
|
| 401 |
-
$feedError .= $feedCheckResponseCreate->error;
|
| 402 |
-
$feedResponseCreateXML = $feedCheckResponseCreate->responsexml;
|
| 403 |
-
|
| 404 |
-
$this->logFlubitProductsRequestResponse($create_feed_prodcut_xml, $feedResponseCreateXML, 'Create Product', $create_result);
|
| 405 |
-
// if feedresponse is fetched and is a success mark it to db as fetched
|
| 406 |
-
$feedResponseCreateXML = simplexml_load_string($feedResponseCreateXML);
|
| 407 |
-
if ($feedResponseCreateXML['status'] == 'processed') {
|
| 408 |
-
if ($feedResponseCreateXML->results->errors->total == 0) {
|
| 409 |
-
$this->feedResponseFetchedMarkToDb($create_result);
|
| 410 |
-
}
|
| 411 |
-
}
|
| 412 |
-
}
|
| 413 |
-
}
|
| 414 |
-
} else {
|
| 415 |
-
Mage::throwException('Response not received from flubit for create product request.');
|
| 416 |
-
}
|
| 417 |
-
}
|
| 418 |
-
// send the prodcuct uppdate feed to flubit and save the id returned to log
|
| 419 |
-
if ($update_feed_prodcut_xml != '') { // if create product feed is not null send to flubit
|
| 420 |
-
$update_result = $config->updateFlubitProducts($update_feed_prodcut_xml);
|
| 421 |
-
if ($update_result != '') {
|
| 422 |
-
Mage::log(print_r($update_result, true), NULL, 'updatefeed.log');
|
| 423 |
-
if (is_object($update_result)) {
|
| 424 |
-
if ($update_result->getName() == 'id') {
|
| 425 |
-
$this->feedLog($update_result, 'update');
|
| 426 |
-
$returnString .= 'Updated Feed ID : ' . (String) $update_result . '<br/>';
|
| 427 |
-
// get the feed response if its a update feed
|
| 428 |
-
$feedCheckResponseUpdate = $this->getFeedErrors($update_result);
|
| 429 |
-
|
| 430 |
-
$updateFailedCount = $feedCheckResponseUpdate->failedCount;
|
| 431 |
-
$errorString .= $feedCheckResponseUpdate->html;
|
| 432 |
-
$failed_sku_update = $feedCheckResponseUpdate->sku;
|
| 433 |
-
$feedError .= $feedCheckResponseUpdate->error;
|
| 434 |
-
$feedResponseupdateXML = $feedCheckResponseUpdate->responsexml;
|
| 435 |
-
|
| 436 |
-
$this->logFlubitProductsRequestResponse($update_feed_prodcut_xml, $feedResponseupdateXML, 'Update Product', $update_result);
|
| 437 |
-
// if feedresponse is fetched and is a success mark it to db as fetched
|
| 438 |
-
$feedResponseupdateXML = simplexml_load_string($feedResponseupdateXML);
|
| 439 |
-
if ($feedResponseupdateXML['status'] == 'processed') {
|
| 440 |
-
if ($feedResponseupdateXML->results->errors->total == 0) {
|
| 441 |
-
$this->feedResponseFetchedMarkToDb($update_result);
|
| 442 |
-
}
|
| 443 |
-
}
|
| 444 |
-
}
|
| 445 |
-
}
|
| 446 |
-
} else {
|
| 447 |
-
Mage::throwException('Response not received from flubit for update product request.');
|
| 448 |
-
}
|
| 449 |
-
}
|
| 450 |
-
|
| 451 |
-
// get differance of failed SKU from create and update
|
| 452 |
-
$allSku = array_diff($allSku, $failed_sku_create);
|
| 453 |
-
$allSku = array_diff($allSku, $failed_sku_update);
|
| 454 |
-
|
| 455 |
-
if ($errorFeed == '') {
|
| 456 |
-
try {
|
| 457 |
-
$flubits = Mage::getModel('flubit/flubit')->getCollection();
|
| 458 |
-
$flubits->addFieldToFilter('sku', array('in' => $allSku))
|
| 459 |
-
;
|
| 460 |
-
foreach ($flubits as $flubit) {
|
| 461 |
-
$flubit
|
| 462 |
-
->setStatus('2')
|
| 463 |
-
->setNew('0')
|
| 464 |
-
->save();
|
| 465 |
-
}
|
| 466 |
-
} catch (Exception $e) {
|
| 467 |
-
Mage::log(__LINE__ . ' Exception Savingt flubit/flubit Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 468 |
-
}
|
| 469 |
-
}
|
| 470 |
-
}
|
| 471 |
-
}
|
| 472 |
-
} catch (Exception $e) {
|
| 473 |
-
$error = $e->getMessage();
|
| 474 |
-
Mage::log('Try getting flubit prodcuts data ' . $e, NULL, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 475 |
-
}
|
| 476 |
-
|
| 477 |
-
if (!$error) {
|
| 478 |
-
if ($productCount != 0) {
|
| 479 |
-
$returnString .= "\n\t<p>Total Products Pushed: " . ($productCount - $createFailedCount - $updateFailedCount ) . '</p>';
|
| 480 |
-
if ($errorString != '')
|
| 481 |
-
Mage::getSingleton('adminhtml/session')->addError($errorString);
|
| 482 |
-
} else if (($productCount == 0 ) && ($errorFeed != '')) {
|
| 483 |
-
$returnString = "<p>Prodcuts not pushed. Please Retry</p>";
|
| 484 |
-
} else {
|
| 485 |
-
$returnString = "<p>There are $productCount products to be pushed to Flubit.</p>";
|
| 486 |
-
if ($errorString != '')
|
| 487 |
-
Mage::getSingleton('adminhtml/session')->addError($errorString);
|
| 488 |
-
}
|
| 489 |
-
} else {
|
| 490 |
-
Mage::log('Error Occured ' . $error, null, Flubit_Flubit_Helper_Data::FLUBIT_FAILED_PRODUCT);
|
| 491 |
-
Mage::throwException($error);
|
| 492 |
-
}
|
| 493 |
-
return $returnString;
|
| 494 |
-
}
|
| 495 |
-
|
| 496 |
-
/**
|
| 497 |
-
* Method to check feed and insert into Logs table
|
| 498 |
-
* @param string
|
| 499 |
-
* @return None
|
| 500 |
-
*/
|
| 501 |
-
public function feedLog($feedId, $type) {
|
| 502 |
-
if (($feedId != '') && ($type != '')) {
|
| 503 |
-
try {
|
| 504 |
-
$feedModel = Mage::getModel('flubit/logs');
|
| 505 |
-
$feedModel->setFeedType($type)
|
| 506 |
-
->setFeedId($feedId)
|
| 507 |
-
->setStatus('0')
|
| 508 |
-
->setCreatedAt(date('Y-m-d H:i:s'))
|
| 509 |
-
->save();
|
| 510 |
-
} catch (Exception $e) {
|
| 511 |
-
Mage::log(__LINE__ . ' Exception Flubit Feed Log ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 512 |
-
}
|
| 513 |
-
}
|
| 514 |
-
}
|
| 515 |
-
|
| 516 |
-
/**
|
| 517 |
-
* Method to check server side validation for blank check key & secret
|
| 518 |
-
* @param string
|
| 519 |
-
* @return boolean
|
| 520 |
-
*/
|
| 521 |
-
public function checkConfiguration() {
|
| 522 |
-
$return = new stdClass();
|
| 523 |
-
$return->right = 'false';
|
| 524 |
-
$return->error = 'false';
|
| 525 |
-
|
| 526 |
-
try {
|
| 527 |
-
$api = Mage::getStoreConfig(self::CONSUMER_API);
|
| 528 |
-
$key = Mage::getStoreConfig(self::SECRET_KEY);
|
| 529 |
-
$url = Mage::getStoreConfig(self::CONSUMER_URL);
|
| 530 |
-
|
| 531 |
-
if (!empty($api) && !empty($key) && !empty($url)) {
|
| 532 |
-
$obj = new Flubit_Flubit_Client($api, $key, $url);
|
| 533 |
-
|
| 534 |
-
$return->right = 'true';
|
| 535 |
-
} else {
|
| 536 |
-
Mage::log('Missing Keys in configuration', null, Flubit_Flubit_Helper_Data::FLUBIT_MISSING_CONFIG);
|
| 537 |
-
$return->error = 'true';
|
| 538 |
-
}
|
| 539 |
-
} catch (Exception $e) {
|
| 540 |
-
Mage::log('Missing Keys in configuration', null, Flubit_Flubit_Helper_Data::FLUBIT_MISSING_CONFIG);
|
| 541 |
-
$return->error = 'true';
|
| 542 |
-
}
|
| 543 |
-
return $return;
|
| 544 |
-
}
|
| 545 |
-
|
| 546 |
-
/**
|
| 547 |
-
* Method to update global price according to configuration
|
| 548 |
-
* @param integer $product
|
| 549 |
-
* @return int
|
| 550 |
-
*/
|
| 551 |
-
public function updateFlubitPrice() {
|
| 552 |
-
//Mage::log('price',null,'hum.log');
|
| 553 |
-
try {
|
| 554 |
-
$priceBasedOn = Mage::getStoreConfig('flubit_section/flubit_setup/price_based_on');
|
| 555 |
-
$globalPrice = Mage::getStoreConfig('flubit_section/flubit_setup/global_price');
|
| 556 |
-
$flubitCollection = Mage::getModel('flubit/flubit')->getCollection()
|
| 557 |
-
->addfieldtofilter('use_global_price', '1')
|
| 558 |
-
->addfieldtofilter('global_price_update', '0')
|
| 559 |
-
->addFieldToSelect('sku')
|
| 560 |
-
->addFieldToSelect('flubit_id')
|
| 561 |
-
->addFieldToSelect('price')
|
| 562 |
-
->setOrder('flubit_id', 'DESC')
|
| 563 |
-
->setPageSize('200');
|
| 564 |
-
//Mage::log($flubitCollection->getData(), null, 'hum.log');
|
| 565 |
-
foreach ($flubitCollection as $flubit) {
|
| 566 |
-
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $flubit->getSku());
|
| 567 |
-
if (is_object($product)) {
|
| 568 |
-
if ($priceBasedOn) {
|
| 569 |
-
$priceOfProduct = $product->getData($priceBasedOn); // Get price based on selected price
|
| 570 |
-
} else {
|
| 571 |
-
$priceOfProduct = $product->getPrice($priceBasedOn); // get default magento price
|
| 572 |
-
}
|
| 573 |
-
|
| 574 |
-
$flubitPrice = $priceOfProduct
|
| 575 |
-
$flubitPrice = number_format($flubitPrice, 2, '.', '');
|
| 576 |
-
|
| 577 |
-
if ($flubitPrice != $flubit->getPrice()) {
|
| 578 |
-
//updating the price in the main table
|
| 579 |
-
$flubit->setPrice($flubitPrice)
|
| 580 |
-
->setGlobalPriceUpdate('1')
|
| 581 |
-
->setStatus('1')
|
| 582 |
-
->save();
|
| 583 |
-
}
|
| 584 |
-
} // product object check
|
| 585 |
-
}
|
| 586 |
-
} catch (Exception $e) {
|
| 587 |
-
Mage::log(__LINE__ . ' Exception get flubit price Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 588 |
-
}
|
| 589 |
-
return 0;
|
| 590 |
-
}
|
| 591 |
-
|
| 592 |
-
/**
|
| 593 |
-
* Method to get Flubit Price
|
| 594 |
-
* @param integer $product
|
| 595 |
-
* @return int
|
| 596 |
-
*/
|
| 597 |
-
public function getFlubitPrice($product) {
|
| 598 |
-
try {
|
| 599 |
-
$priceBasedOn = Mage::getStoreConfig('flubit_section/flubit_setup/price_based_on');
|
| 600 |
-
$globalPrice = Mage::getStoreConfig('flubit_section/flubit_setup/global_price');
|
| 601 |
-
|
| 602 |
-
if (is_object($product)) {
|
| 603 |
-
|
| 604 |
-
$flubitProduct = Mage::getModel('flubit/flubit')->getcollection()->addfieldtofilter('sku', $product->getSku());
|
| 605 |
-
$flubitPriceUseGlobal = 0; // set by default
|
| 606 |
-
foreach ($flubitProduct as $flubit) {
|
| 607 |
-
$flubitPriceUseGlobal = $flubit->getUseGlobalPrice();
|
| 608 |
-
}
|
| 609 |
-
// if global price is zero than calculate with the given conditions
|
| 610 |
-
if (($product->getFlubitBasePrice() != 0.00) && ($flubitPriceUseGlobal == 0))
|
| 611 |
-
return $product->getFlubitBasePrice(); // return default flubit price
|
| 612 |
-
else if ($priceBasedOn)
|
| 613 |
-
$priceBasedOn = $product->getData($priceBasedOn); // Get price based on selected price
|
| 614 |
-
else {
|
| 615 |
-
$priceBasedOn = $product->getPrice($priceBasedOn); // get default magento price
|
| 616 |
-
}
|
| 617 |
-
$flubitPrice = $priceBasedOn
|
| 618 |
-
$flubitPrice = number_format($flubitPrice, 2, '.', '');
|
| 619 |
-
//$product->setFlubitBasePrice($flubitPrice)->save();
|
| 620 |
-
if ($flubitPriceUseGlobal == 0) {
|
| 621 |
-
if (is_object($flubit)) {
|
| 622 |
-
$flubit->setUseGlobalPrice(1)
|
| 623 |
-
->save();
|
| 624 |
-
}
|
| 625 |
-
}
|
| 626 |
-
return $flubitPrice;
|
| 627 |
-
}
|
| 628 |
-
} catch (Exception $e) {
|
| 629 |
-
Mage::log(__LINE__ . ' Exception get flubit price Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 630 |
-
}
|
| 631 |
-
return 0;
|
| 632 |
-
}
|
| 633 |
-
|
| 634 |
-
/**
|
| 635 |
-
* Method to Update Flubit Price
|
| 636 |
-
*/
|
| 637 |
-
private function _updateFlubitPrices() {
|
| 638 |
-
try {
|
| 639 |
-
$flubitCollection = Mage::getModel('flubit/flubit')->getCollection();
|
| 640 |
-
|
| 641 |
-
foreach ($flubitCollection as $flubit) {
|
| 642 |
-
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $flubit->getSku());
|
| 643 |
-
if (is_object($product)) {
|
| 644 |
-
$flubitPrice = $this->getFlubitPrice($product);
|
| 645 |
-
|
| 646 |
-
if (($flubitPrice != $flubit->getPrice()) || ($product->getFlubitBasePrice() != $flubitPrice)) {
|
| 647 |
-
try {
|
| 648 |
-
//updating the price in the main table
|
| 649 |
-
$flubit->setPrice($flubitPrice)
|
| 650 |
-
->setStatus('1')
|
| 651 |
-
->save();
|
| 652 |
-
//updating the product attribute flubit base price
|
| 653 |
-
$product->setFlubitBasePrice($flubitPrice)
|
| 654 |
-
->save();
|
| 655 |
-
} catch (Exception $e) {
|
| 656 |
-
Mage::log('Update Flubit Price Exception ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 657 |
-
}
|
| 658 |
-
}
|
| 659 |
-
}
|
| 660 |
-
}
|
| 661 |
-
} catch (Exception $e) {
|
| 662 |
-
Mage::log(__LINE__ . ' Exception updateFlubitPrices Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 663 |
-
}
|
| 664 |
-
}
|
| 665 |
-
|
| 666 |
-
/**
|
| 667 |
-
* Method to Update Flubit Quantity
|
| 668 |
-
*/
|
| 669 |
-
private function _updateFlubitQty() {
|
| 670 |
-
try {
|
| 671 |
-
$flubitCollection = Mage::getModel('flubit/flubit')->getCollection();
|
| 672 |
-
|
| 673 |
-
foreach ($flubitCollection as $flubit) {
|
| 674 |
-
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $flubit->getSku());
|
| 675 |
-
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
|
| 676 |
-
|
| 677 |
-
if ($qty != (int) $flubit->getQty()) {
|
| 678 |
-
//updating the Qty in the main table
|
| 679 |
-
$flubit->setQty($qty)
|
| 680 |
-
->setStatus('1')
|
| 681 |
-
->save();
|
| 682 |
-
}
|
| 683 |
-
}
|
| 684 |
-
} catch (Exception $e) {
|
| 685 |
-
Mage::log(__LINE__ . ' Exception _updateFlubitQty ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 686 |
-
}
|
| 687 |
-
}
|
| 688 |
-
|
| 689 |
-
/**
|
| 690 |
-
* Method for Check Ean, Asin, Isbn, Mpn
|
| 691 |
-
*
|
| 692 |
-
* @param String $pr
|
| 693 |
-
* @return boolean
|
| 694 |
-
*/
|
| 695 |
-
public function checkEanValidation($pr) {
|
| 696 |
-
try {
|
| 697 |
-
if (is_object($pr)) {
|
| 698 |
-
if ($pr->getFlubitEan() || $pr->getFlubitAsin() || $pr->getFlubitIsbn() || $pr->getFlubitMpn()) {
|
| 699 |
-
return true;
|
| 700 |
-
}
|
| 701 |
-
}
|
| 702 |
-
return false;
|
| 703 |
-
} catch (Exception $e) {
|
| 704 |
-
Mage::log(__LINE__ . ' Exception checkEanValidation ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 705 |
-
}
|
| 706 |
-
}
|
| 707 |
-
|
| 708 |
-
/**
|
| 709 |
-
* Method for Check Image not Blank
|
| 710 |
-
*
|
| 711 |
-
* @param String $pr
|
| 712 |
-
* @return boolean
|
| 713 |
-
*/
|
| 714 |
-
public function checkImageValidation($pr) {
|
| 715 |
-
if ($pr->getImage() != 'no_selection') {
|
| 716 |
-
try {
|
| 717 |
-
$image_path = Mage::helper('catalog/image')->init($pr, 'image');
|
| 718 |
-
if ($image_path != '') {
|
| 719 |
-
return true;
|
| 720 |
-
}
|
| 721 |
-
} catch (Exception $e) {
|
| 722 |
-
Mage::log(__LINE__ . ' Exception Image Validation ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 723 |
-
}
|
| 724 |
-
}
|
| 725 |
-
return false;
|
| 726 |
-
}
|
| 727 |
-
|
| 728 |
-
/**
|
| 729 |
-
* Method for Check Image not Blank
|
| 730 |
-
*
|
| 731 |
-
* @param String $pr
|
| 732 |
-
* @return boolean
|
| 733 |
-
*/
|
| 734 |
-
public function checkQuantityValidation($pr) {
|
| 735 |
-
//Mage::log($pr->getQty() , null, flubit_create_product.log);
|
| 736 |
-
if (is_int($pr->getQty())) {
|
| 737 |
-
return true;
|
| 738 |
-
}
|
| 739 |
-
return false;
|
| 740 |
-
}
|
| 741 |
-
|
| 742 |
-
/**
|
| 743 |
-
* Method to remove non utf character
|
| 744 |
-
*
|
| 745 |
-
* @param String $Str
|
| 746 |
-
* @return String
|
| 747 |
-
*/
|
| 748 |
-
public function removeNonUtfCharacters($Str) {
|
| 749 |
-
try {
|
| 750 |
-
$StrArr = STR_SPLIT($Str);
|
| 751 |
-
$NewStr = '';
|
| 752 |
-
foreach ($StrArr as $Char) {
|
| 753 |
-
$CharNo = ORD($Char);
|
| 754 |
-
if ($CharNo == 163) {
|
| 755 |
-
$NewStr .= $Char;
|
| 756 |
-
continue;
|
| 757 |
-
} // keep £
|
| 758 |
-
if ($CharNo > 31 && $CharNo < 127) {
|
| 759 |
-
$NewStr .= $Char;
|
| 760 |
-
}
|
| 761 |
-
}
|
| 762 |
-
} catch (Exception $e) {
|
| 763 |
-
Mage::log(__LINE__ . ' Exception removeNonUtfCharacters ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 764 |
-
}
|
| 765 |
-
return $NewStr;
|
| 766 |
-
}
|
| 767 |
-
|
| 768 |
-
/**
|
| 769 |
-
* Method to check the status of the pushed feed
|
| 770 |
-
*
|
| 771 |
-
* @param SimpleXmlObject
|
| 772 |
-
* @param String mode
|
| 773 |
-
* @return Object
|
| 774 |
-
*/
|
| 775 |
-
public function getFeedErrors($xmlObj) {
|
| 776 |
-
try {
|
| 777 |
-
//Mage::log('Check For feed id ' . $xmlObj, null, 'Test_Feed.log');
|
| 778 |
-
//sleep(5);
|
| 779 |
-
$return = new stdClass();
|
| 780 |
-
$return->failedCount = 0;
|
| 781 |
-
$return->html = '';
|
| 782 |
-
$return->sku = array();
|
| 783 |
-
$return->error = '';
|
| 784 |
-
$return->status = '';
|
| 785 |
-
$return->mode = '';
|
| 786 |
-
$return->responsexml = '';
|
| 787 |
-
|
| 788 |
-
try {
|
| 789 |
-
$config = Mage::getModel('flubit/config');
|
| 790 |
-
$xmlObjRes = $config->getproductFeedStatus($xmlObj, 'xml');
|
| 791 |
-
$return->responsexml = $xmlObjRes;
|
| 792 |
-
} catch (Exception $e) {
|
| 793 |
-
Mage::log('Exception Getting Feed Errors ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 794 |
-
}
|
| 795 |
-
|
| 796 |
-
$xmlObjRes = simplexml_load_string($xmlObjRes);
|
| 797 |
-
if (is_object($xmlObjRes)) {
|
| 798 |
-
|
| 799 |
-
if ($xmlObjRes->getName() == 'error') {
|
| 800 |
-
$errorCode = $xmlObjRes['code'];
|
| 801 |
-
$return->error = $xmlObjRes['message'];
|
| 802 |
-
$this->feedResponseFetchedMarkToDb($xmlObj); // feed response recived mark in database
|
| 803 |
-
Mage::log('Error: Code ' . $errorCode . ' Error Message : ' . $return->error, null, Flubit_Flubit_Helper_Data::FLUBIT_FEED);
|
| 804 |
-
} else if ($xmlObjRes->getName() == 'feed') {
|
| 805 |
-
if ($xmlObjRes['status'] == 'invalid') {
|
| 806 |
-
$return->error = 'Invalid Feed Sent to flubit';
|
| 807 |
-
$this->feedResponseFetchedMarkToDb($xmlObj); // feed response recived mark in database
|
| 808 |
-
}
|
| 809 |
-
|
| 810 |
-
if ($xmlObjRes['status'] == 'processing') {
|
| 811 |
-
Mage::log('Feed ID is Under Processing : ' . $xmlObj, null, Flubit_Flubit_Helper_Data::FLUBIT_FEED);
|
| 812 |
-
} else if ($xmlObjRes['status'] == 'processed') {
|
| 813 |
-
//Mage::log('hello afetr created check : ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 814 |
-
if (isset($xmlObjRes->results->created)) {
|
| 815 |
-
//Mage::log('afetr created check : ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 816 |
-
$return->mode = 'created';
|
| 817 |
-
$this->feedResponseFetchedMarkToDb($xmlObj); // feed response recived mark in database
|
| 818 |
-
//Mage::log('After Create mark db : ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 819 |
-
if (isset($xmlObjRes->results->errors->total)) {
|
| 820 |
-
if ($xmlObjRes->results->errors->total > 0) {
|
| 821 |
-
$return->failedCount = $xmlObjRes->results->errors->total;
|
| 822 |
-
$innerTable = '';
|
| 823 |
-
$productAlreadyExist = array();
|
| 824 |
-
foreach ($xmlObjRes->results->errors->sample->error as $error) {
|
| 825 |
-
$productName = '';
|
| 826 |
-
try {
|
| 827 |
-
$productNameObj = Mage::getModel('catalog/product')->loadByAttribute('sku', $error['sku']);
|
| 828 |
-
if (is_object($productNameObj))
|
| 829 |
-
$productName = $productNameObj->getName();
|
| 830 |
-
else {
|
| 831 |
-
Mage::log('Unable to get product Name for SKU: ' . $error['sku'], null, Flubit_Flubit_Helper_Data::FLUBIT_FEED);
|
| 832 |
-
}
|
| 833 |
-
} catch (Exception $e) {
|
| 834 |
-
Mage::log('Unable to get name of product Get Feed Errors ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 835 |
-
}
|
| 836 |
-
if ($error == 'Product already exists.') {
|
| 837 |
-
$productAlreadyExist[] = $error['sku'];
|
| 838 |
-
} else {
|
| 839 |
-
$return->sku[] = $error['sku'];
|
| 840 |
-
$innerTable .= '<tr>
|
| 841 |
-
<td style="padding:4px;">' . $productName . '</td>
|
| 842 |
-
<td style="padding:4px;">' . $error['sku'] . ' </td>
|
| 843 |
-
<td style="padding:4px;"> ' . $error . ' </td>
|
| 844 |
-
</tr>';
|
| 845 |
-
}
|
| 846 |
-
}
|
| 847 |
-
if ($innerTable != '')
|
| 848 |
-
$return->html = '<div>Following product(s) has failed to sync.</div><br/>
|
| 849 |
-
<style type="text/css">
|
| 850 |
-
#tableOuter{
|
| 851 |
-
border-style: solid;
|
| 852 |
-
border-width: 1px;
|
| 853 |
-
border-collapse: collapse;
|
| 854 |
-
margin: 0;
|
| 855 |
-
padding:4;
|
| 856 |
-
width:100%;
|
| 857 |
-
}
|
| 858 |
-
|
| 859 |
-
#tableOuter th,#tableOuter td{
|
| 860 |
-
border-style: solid;
|
| 861 |
-
border-width: 0 1px 1px 0;
|
| 862 |
-
border-collapse: collapse;
|
| 863 |
-
margin: 0;
|
| 864 |
-
padding:4;
|
| 865 |
-
}
|
| 866 |
-
</style>
|
| 867 |
-
<table id="tableOuter" cellspacing="0" cellpadding="0">
|
| 868 |
-
<tr>
|
| 869 |
-
<th width="250"><strong>Product Name</strong></th>
|
| 870 |
-
<th width="250"><strong>Product SKU</strong></th>
|
| 871 |
-
<th width="250"><strong>Error Message</strong></th>
|
| 872 |
-
</tr>
|
| 873 |
-
' . $innerTable . '
|
| 874 |
-
</table>';
|
| 875 |
-
if (count($productAlreadyExist) > 0) {
|
| 876 |
-
$this->requeuFailedFeedSku($productAlreadyExist, '');
|
| 877 |
-
Mage::log('Update Product to be in create request :' . print_r($productAlreadyExist, true), null, 'up_error.log');
|
| 878 |
-
// since returned error is product already exist in list
|
| 879 |
-
// such that it goen in update Request
|
| 880 |
-
}
|
| 881 |
-
}
|
| 882 |
-
}
|
| 883 |
-
} else {
|
| 884 |
-
//Mage::log('Not Inside created block: ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 885 |
-
}
|
| 886 |
-
if (isset($xmlObjRes->results->updated)) {
|
| 887 |
-
$return->mode = 'updated';
|
| 888 |
-
if (isset($xmlObjRes->results->errors->total)) {
|
| 889 |
-
if ($xmlObjRes->results->errors->total > 0) {
|
| 890 |
-
$return->failedCount = $xmlObjRes->results->errors->total;
|
| 891 |
-
$UpdateFailedSku = array();
|
| 892 |
-
$innerTable = '';
|
| 893 |
-
foreach ($xmlObjRes->results->errors->sample->error as $error) {
|
| 894 |
-
$productName = '';
|
| 895 |
-
try {
|
| 896 |
-
$productName = Mage::getModel('catalog/product')->loadByAttribute('sku', $error['sku'])->getName();
|
| 897 |
-
} catch (Exception $e) {
|
| 898 |
-
Mage::log('Unable to get name of product Get Feed Errors ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 899 |
-
}
|
| 900 |
-
|
| 901 |
-
//$return->sku[] = $error['sku'];
|
| 902 |
-
|
| 903 |
-
if ($error == 'Product does not exist in cache.') // check if prodcut not in cache exists
|
| 904 |
-
$UpdateFailedSku[] = $error['sku'];
|
| 905 |
-
else
|
| 906 |
-
$return->sku[] = $error['sku'];
|
| 907 |
-
|
| 908 |
-
//Mage::log('Update Product Error :' . $error , null , 'up_error.log' );
|
| 909 |
-
|
| 910 |
-
$innerTable .= '<tr>
|
| 911 |
-
<td style="padding:4px;">' . $productName . '</td>
|
| 912 |
-
<td style="padding:4px;">' . $error['sku'] . ' </td>
|
| 913 |
-
<td style="padding:4px;"> ' . $error . ' </td>
|
| 914 |
-
</tr>';
|
| 915 |
-
}
|
| 916 |
-
if ($innerTable != '')
|
| 917 |
-
$return->html = '<div>Following product(s) Updates has failed to sync.</div><br/>
|
| 918 |
-
<style type="text/css">
|
| 919 |
-
#tableOuter2{
|
| 920 |
-
border-style: solid;
|
| 921 |
-
border-width: 1px;
|
| 922 |
-
border-collapse: collapse;
|
| 923 |
-
margin: 0;
|
| 924 |
-
padding:4;
|
| 925 |
-
width:100%;
|
| 926 |
-
}
|
| 927 |
-
|
| 928 |
-
#tableOuter2 th,#tableOuter2 td{
|
| 929 |
-
border-style: solid;
|
| 930 |
-
border-width: 0 1px 1px 0;
|
| 931 |
-
border-collapse: collapse;
|
| 932 |
-
margin: 0;
|
| 933 |
-
padding:4;
|
| 934 |
-
}
|
| 935 |
-
</style>
|
| 936 |
-
<table id="tableOuter2" cellspacing="0" cellpadding="0">
|
| 937 |
-
<tr>
|
| 938 |
-
<th width="250"><strong>Product Name</strong></th>
|
| 939 |
-
<th width="250"><strong>Product SKU</strong></th>
|
| 940 |
-
<th width="250"><strong>Error Message</strong></th>
|
| 941 |
-
</tr>
|
| 942 |
-
' . $innerTable . '
|
| 943 |
-
</table>';
|
| 944 |
-
// update products to create new if the returned skus have not in cache error
|
| 945 |
-
if (count($UpdateFailedSku) > 0) {
|
| 946 |
-
$this->requeuFailedFeedSku($UpdateFailedSku, 'created');
|
| 947 |
-
//Mage::log('Update Product to be in create request :' . print_r($UpdateFailedSku,true) , null , 'up_error.log' );
|
| 948 |
-
// since returned error is not exist in cache we need to update product
|
| 949 |
-
// such that it goen in create request
|
| 950 |
-
}
|
| 951 |
-
}
|
| 952 |
-
}
|
| 953 |
-
$this->feedResponseFetchedMarkToDb($xmlObj);
|
| 954 |
-
// feed response recived mark in database
|
| 955 |
-
//Mage::log('After update mark db : ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 956 |
-
} else {
|
| 957 |
-
//Mage::log('Not Inside Updated Block : ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 958 |
-
}
|
| 959 |
-
}
|
| 960 |
-
} else {
|
| 961 |
-
|
| 962 |
-
}
|
| 963 |
-
}
|
| 964 |
-
return $return;
|
| 965 |
-
} catch (Exception $e) {
|
| 966 |
-
Mage::log(__LINE__ . ' Exception getFeedErrors ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 967 |
-
}
|
| 968 |
-
}
|
| 969 |
-
|
| 970 |
-
/**
|
| 971 |
-
* Method to mark the response of checked feed to DB
|
| 972 |
-
*
|
| 973 |
-
* @param String
|
| 974 |
-
* @return void
|
| 975 |
-
*/
|
| 976 |
-
public function feedResponseFetchedMarkToDb($feedId) {
|
| 977 |
-
//Mage::log('Inside MArk feed response : ' . ' Feed Id = ' . $feedId , null, 'temptest.log' );
|
| 978 |
-
try {
|
| 979 |
-
|
| 980 |
-
$logs = Mage::getModel('flubit/logs')->getCollection()
|
| 981 |
-
->addFieldToFilter('feed_id', $feedId);
|
| 982 |
-
|
| 983 |
-
foreach ($logs as $flb) {
|
| 984 |
-
//Mage::log('Save Feed Status As Fetched : ' . $flb->getId() . ' Feed Id = ' . $feedId , null, 'temptest.log' );
|
| 985 |
-
$flb->setData(array('flubit_id' => $flb->getId(), 'status' => 1))
|
| 986 |
-
->save();
|
| 987 |
-
}
|
| 988 |
-
} catch (Exception $e) {
|
| 989 |
-
Mage::log('Error Saving to Database Flubit Log Exception : ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 990 |
-
}
|
| 991 |
-
}
|
| 992 |
-
|
| 993 |
-
/**
|
| 994 |
-
* Method to check all pending feeds whose status is not fetched
|
| 995 |
-
*
|
| 996 |
-
* @param void
|
| 997 |
-
* @return void
|
| 998 |
-
*/
|
| 999 |
-
public function _checkPendingFeedStatus() {
|
| 1000 |
-
try {
|
| 1001 |
-
$logs = Mage::getModel('flubit/logs')->getCollection()
|
| 1002 |
-
->addFieldToFilter('status', 0);
|
| 1003 |
-
//Mage::log(print_r($logs, true), null, 'flubit_product_feed.log');
|
| 1004 |
-
foreach ($logs as $flb) {
|
| 1005 |
-
Mage::log('Feeds Returned : ' . $flb->getFeedId(), null, 'temptest.log');
|
| 1006 |
-
$result = $this->getFeedErrors($flb->getFeedId());
|
| 1007 |
-
$this->logFlubitProductsRequestResponse('Request sent to check feed id: <b>"' . $flb->getFeedId() . '"</b>', $result->responsexml, 'Check Feed Response', $flb->getFeedId());
|
| 1008 |
-
if ($result->failedCount > 0) {
|
| 1009 |
-
Mage::log('Failed Count: ' . $result->failedCount . ' Mode = ' . $result->mode . ' SKU' . print_r($result->sku, true), null, 'temptest.log');
|
| 1010 |
-
$this->requeuFailedFeedSku($result->sku, $result->mode);
|
| 1011 |
-
}
|
| 1012 |
-
//Mage::log('Response : ' . print_r($result,true) , null, 'temptest.log' );
|
| 1013 |
-
}
|
| 1014 |
-
} catch (Exception $e) {
|
| 1015 |
-
Mage::log('Error Fetching Feeds : ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 1016 |
-
}
|
| 1017 |
-
}
|
| 1018 |
-
|
| 1019 |
-
/**
|
| 1020 |
-
* Method to requeue the products for create and update
|
| 1021 |
-
*
|
| 1022 |
-
* @param array
|
| 1023 |
-
* @param String
|
| 1024 |
-
*
|
| 1025 |
-
* @return void
|
| 1026 |
-
*/
|
| 1027 |
-
public function requeuFailedFeedSku($sku, $mode) {
|
| 1028 |
-
try {
|
| 1029 |
-
if (is_array($sku)) {
|
| 1030 |
-
Mage::log('Requeue Failed Products: ' . print_r($sku, true), null, 'temptest.log');
|
| 1031 |
-
if (count($sku) > 0) {
|
| 1032 |
-
$new = 0;
|
| 1033 |
-
|
| 1034 |
-
if ($mode == 'created')
|
| 1035 |
-
$new = 1;
|
| 1036 |
-
foreach ($sku as $flsku) {
|
| 1037 |
-
$prod = Mage::getModel('flubit/flubit')->getCollection()
|
| 1038 |
-
->addFieldToFilter('sku', $flsku);
|
| 1039 |
-
foreach ($prod as $flprod) {
|
| 1040 |
-
try {
|
| 1041 |
-
$flprod->setData(array('flubit_id' => $flprod->getId(), 'status' => 1, 'new' => $new))
|
| 1042 |
-
->save();
|
| 1043 |
-
Mage::log('updated logs ' . $flprod->getId() . ' new = ' . $new, null, 'temptest.log');
|
| 1044 |
-
} catch (Exception $e) {
|
| 1045 |
-
Mage::log('Error Flubit product update Exception : ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 1046 |
-
}
|
| 1047 |
-
}
|
| 1048 |
-
}
|
| 1049 |
-
}
|
| 1050 |
-
}
|
| 1051 |
-
} catch (Exception $e) {
|
| 1052 |
-
Mage::log(__LINE__ . ' Exception getFeedErrors ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 1053 |
-
}
|
| 1054 |
-
}
|
| 1055 |
-
|
| 1056 |
-
/**
|
| 1057 |
-
* Method to Error logging the products for create and update and Check Feed Response
|
| 1058 |
-
*
|
| 1059 |
-
* @param array
|
| 1060 |
-
* @param String
|
| 1061 |
-
*
|
| 1062 |
-
* @return void
|
| 1063 |
-
*/
|
| 1064 |
-
function logFlubitProductsRequestResponse($request, $response, $mode, $feedId) {
|
| 1065 |
-
|
| 1066 |
-
if ($mode == 'Create Product') {
|
| 1067 |
-
$action = 1;
|
| 1068 |
-
} else if ($mode == 'Update Product') {
|
| 1069 |
-
$action = 2;
|
| 1070 |
-
} else if ($mode == 'Check Feed Response') {
|
| 1071 |
-
$action = 10;
|
| 1072 |
-
}
|
| 1073 |
-
if ($request != '') {
|
| 1074 |
-
if ($action == 10) {
|
| 1075 |
-
$request = $request;
|
| 1076 |
-
} else {
|
| 1077 |
-
$dom = new DOMDocument;
|
| 1078 |
-
$dom->preserveWhiteSpace = FALSE;
|
| 1079 |
-
$dom->loadXML($request);
|
| 1080 |
-
$dom->formatOutput = TRUE;
|
| 1081 |
-
$request = $dom->saveXml();
|
| 1082 |
-
}
|
| 1083 |
-
}
|
| 1084 |
-
$level = 2;
|
| 1085 |
-
|
| 1086 |
-
if ($response != '' && $request != '') {
|
| 1087 |
-
$xmlObjResCreate = simplexml_load_string($response);
|
| 1088 |
-
|
| 1089 |
-
if ($xmlObjResCreate->getName() == 'feed') {
|
| 1090 |
-
if ($xmlObjResCreate['status'] == 'processing' || $xmlObjResCreate['status'] == 'awaiting_validation' || $xmlObjResCreate['status'] == 'awaiting_processing') {
|
| 1091 |
-
$level = 1;
|
| 1092 |
-
}
|
| 1093 |
-
if ($xmlObjResCreate['status'] == 'processed') {
|
| 1094 |
-
if ($xmlObjResCreate->results->errors->total == 0) {
|
| 1095 |
-
$level = 1;
|
| 1096 |
-
}
|
| 1097 |
-
}
|
| 1098 |
-
} //feed if close
|
| 1099 |
-
}
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
if (($request != '') || ($response != '')) {
|
| 1104 |
-
try {
|
| 1105 |
-
$flubitlog = Mage::getModel('flubitlog/flubitlog');
|
| 1106 |
-
$flubitlog->setData(
|
| 1107 |
-
array(
|
| 1108 |
-
'request_xml' => $request,
|
| 1109 |
-
'feedid' => $feedId,
|
| 1110 |
-
'response_xml' => $response,
|
| 1111 |
-
'action' => $action,
|
| 1112 |
-
'datetime' => date('Y-m-d H:i:s'),
|
| 1113 |
-
'level' => $level
|
| 1114 |
-
)
|
| 1115 |
-
)
|
| 1116 |
-
->save();
|
| 1117 |
-
} catch (Exception $e) {
|
| 1118 |
-
|
| 1119 |
-
}
|
| 1120 |
-
}
|
| 1121 |
-
}
|
| 1122 |
-
|
| 1123 |
}
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Class Flubit Model Flubit
|
| 5 |
+
*
|
| 6 |
+
* @package Flubit
|
| 7 |
+
* @category Flubit_Model
|
| 8 |
+
* @author Flubit team
|
| 9 |
+
*/
|
| 10 |
+
class Flubit_Flubit_Model_Flubit extends Mage_Core_Model_Abstract {
|
| 11 |
+
|
| 12 |
+
const CONSUMER_API = 'flubit_section/flubit_configuration/flubit_consumer_key';
|
| 13 |
+
const SECRET_KEY = 'flubit_section/flubit_configuration/flubit_secret';
|
| 14 |
+
const CONSUMER_URL = 'flubit_section/flubit_configuration/flubit_url';
|
| 15 |
+
const LOG_TYPE = 'flubit_section/flubit_setup/log_type_list';
|
| 16 |
+
const LOGDATE_OLDER = 'flubit_section/flubit_setup/logdate_cron_settings';
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Constructor for load Flubit Order
|
| 20 |
+
*
|
| 21 |
+
*/
|
| 22 |
+
protected function _construct() {
|
| 23 |
+
try {
|
| 24 |
+
$this->_init("flubit/flubit");
|
| 25 |
+
} catch (Exception $e) {
|
| 26 |
+
Mage::log('_construct ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Method to get Flubit Orders
|
| 32 |
+
*/
|
| 33 |
+
public function getFlubitOrders() {
|
| 34 |
+
try {
|
| 35 |
+
$config = Mage::getModel('flubit/config');
|
| 36 |
+
$data = $config->getFlubitOrders();
|
| 37 |
+
} catch (Exception $e) {
|
| 38 |
+
Mage::log('getFlubitOrders ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Method to Process Flubit Orders
|
| 44 |
+
*/
|
| 45 |
+
public function processFlubitOrders() {
|
| 46 |
+
try {
|
| 47 |
+
$this->refundFlubitOrders();
|
| 48 |
+
} catch (Exception $e) {
|
| 49 |
+
Mage::log('processFlubitOrders ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* Method to Dispatch Flubit Orders
|
| 55 |
+
*/
|
| 56 |
+
public function dispatchFlubitOrders() {
|
| 57 |
+
try {
|
| 58 |
+
$config = Mage::getModel('flubit/config');
|
| 59 |
+
$data = $config->dispatchFlubitOrders();
|
| 60 |
+
} catch (Exception $e) {
|
| 61 |
+
Mage::log('dispatchFlubitOrders ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Method to Cancel Flubit Orders
|
| 67 |
+
*/
|
| 68 |
+
public function cancelFlubitOrders() {
|
| 69 |
+
try {
|
| 70 |
+
$config = Mage::getModel('flubit/config');
|
| 71 |
+
$data = $config->cancelFlubitOrders();
|
| 72 |
+
} catch (Exception $e) {
|
| 73 |
+
Mage::log('cancelFlubitOrders ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* Method to Refund Flubit Orders
|
| 79 |
+
*/
|
| 80 |
+
public function refundFlubitOrders() {
|
| 81 |
+
try {
|
| 82 |
+
$config = Mage::getModel('flubit/config');
|
| 83 |
+
$data = $config->refundFlubitOrders();
|
| 84 |
+
} catch (Exception $e) {
|
| 85 |
+
Mage::log('refundFlubitOrders ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Method to Send Product Feed
|
| 91 |
+
*/
|
| 92 |
+
public function sendProductFeed() {
|
| 93 |
+
try {
|
| 94 |
+
$this->_updateFlubitPrices();
|
| 95 |
+
$this->_updateFlubitQty();
|
| 96 |
+
$this->generateProductXML();
|
| 97 |
+
} catch (Exception $e) {
|
| 98 |
+
Mage::log('sendProductFeed ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Method to delete log files and flubitlog table
|
| 104 |
+
*/
|
| 105 |
+
public function archiveLog() {
|
| 106 |
+
//Mage::log('archive',null,'hum.log');
|
| 107 |
+
//$olderthen = Mage::getStoreConfig(self::LOGDATE_OLDER);
|
| 108 |
+
$logbefore = date('Y-m-d h:i:s', strtotime('-' . 30 . ' day'));
|
| 109 |
+
$flubitlogs = Mage::getModel('flubitlog/flubitlog')->getCollection();
|
| 110 |
+
$flubitlogs->addFieldToFilter('datetime', array('lteq' => $logbefore));
|
| 111 |
+
$flubitlogs->load();
|
| 112 |
+
foreach ($flubitlogs as $flubitlog) {
|
| 113 |
+
$flubitlog->delete();
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* Method to Generate Product Xml
|
| 119 |
+
*/
|
| 120 |
+
public function generateProductXML() { // generate product xml and send to flubit
|
| 121 |
+
$configure = $this->checkConfiguration();
|
| 122 |
+
if ($configure->error == 'true' && $configure->right == 'false') {
|
| 123 |
+
Mage::throwException('Missing Keys in configuration');
|
| 124 |
+
}
|
| 125 |
+
// end checking of configuration
|
| 126 |
+
$this->_checkPendingFeedStatus();
|
| 127 |
+
|
| 128 |
+
// get the configuration from the file
|
| 129 |
+
$chunkSize = 10; // define if chunk size is not defined
|
| 130 |
+
$errorString = ''; // define blank error string
|
| 131 |
+
$returnString = '';
|
| 132 |
+
$errorFeed = '';
|
| 133 |
+
$productCount = 0;
|
| 134 |
+
$error = FALSE;
|
| 135 |
+
try {
|
| 136 |
+
$chunkSize = Mage::getStoreConfig('flubit_section/flubit_setup/flubit_chunk');
|
| 137 |
+
} catch (Exception $e) {
|
| 138 |
+
Mage::log('Could not retrive chunk size ' . $e, NULL, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 139 |
+
}
|
| 140 |
+
$allSku = array();
|
| 141 |
+
|
| 142 |
+
// get flubit collection for the prodcuts which are needed to be pushed
|
| 143 |
+
try {
|
| 144 |
+
$flubit_products = Mage::getModel('flubit/flubit')->getCollection()
|
| 145 |
+
->addFieldToFilter('status', '1')
|
| 146 |
+
->addFieldToFilter('is_deleted', '0')
|
| 147 |
+
->setOrder('flubit_id', 'ASC')
|
| 148 |
+
->setPageSize($chunkSize);
|
| 149 |
+
|
| 150 |
+
if (is_object($flubit_products)) {
|
| 151 |
+
if (count($flubit_products) > 0) {
|
| 152 |
+
|
| 153 |
+
$create_feed_prodcut_xml = ''; // initialise the new product xml
|
| 154 |
+
$update_feed_prodcut_xml = ''; // initialise the update product xml
|
| 155 |
+
|
| 156 |
+
$store = Mage::app()->getStore(); // get deafult store
|
| 157 |
+
$tax_calculation_obj = Mage::getModel('tax/calculation')->getRateRequest(null, null, null, $store);
|
| 158 |
+
|
| 159 |
+
$newXML = '';
|
| 160 |
+
$updateXML = '';
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
foreach ($flubit_products as $flubit_Prodcut) {
|
| 164 |
+
// get magento product id for the given sku
|
| 165 |
+
if ($flubit_Prodcut->getSku() == '') { // we cannot proceed further if sku is missing
|
| 166 |
+
Mage::log('Missing SKU for flubit product ', NULL, Flubit_Flubit_Helper_Data::FLUBIT_CREATE_PRODUCT);
|
| 167 |
+
// save the status to zero so that its called next time only once its updated from backend
|
| 168 |
+
$flubit_Prodcut->setStatus('0')
|
| 169 |
+
->save();
|
| 170 |
+
continue;
|
| 171 |
+
}
|
| 172 |
+
$product_id = Mage::getModel('catalog/product')->getIdBySku(trim($flubit_Prodcut->getSku()));
|
| 173 |
+
$product = Mage::getModel('catalog/product')->load($product_id);
|
| 174 |
+
|
| 175 |
+
// check if the prodcut exist in magento
|
| 176 |
+
if (!$product->getId()) {
|
| 177 |
+
Mage::log('Sku ' . $product->getSku() . ' does not found in Magento.', null, Flubit_Flubit_Helper_Data::FLUBIT_FAILED_PRODUCT);
|
| 178 |
+
$flubit_Prodcut->setStatus('0')
|
| 179 |
+
->save();
|
| 180 |
+
continue;
|
| 181 |
+
}
|
| 182 |
+
// if there is no EAN, ASIN, ISBN or MPN we can't push it to Flubit
|
| 183 |
+
if (!$this->checkEanValidation($product)) {
|
| 184 |
+
if (is_object($product)) {
|
| 185 |
+
|
| 186 |
+
$errorString .= '<tr>
|
| 187 |
+
<td style="padding:4px;">' . $product->getName() . '</td>
|
| 188 |
+
<td style="padding:4px;">' . $product->getSku() . ' </td>
|
| 189 |
+
<td style="padding:4px;"> ' . 'Missing Identifiers. ' . '</td>
|
| 190 |
+
</tr>';
|
| 191 |
+
|
| 192 |
+
$response = 'Product SKU : <b>"' . $product->getSku() . '"</b> identifiers is blank. Please update the data where appropriate and send again. ';
|
| 193 |
+
$feedid = 'Product identifiers validation failed.';
|
| 194 |
+
|
| 195 |
+
$this->logFlubitProductsRequestResponse('', $response, 'Create Product', $feedid);
|
| 196 |
+
|
| 197 |
+
Mage::log($product->getSku() . ' missing identifiers', null, Flubit_Flubit_Helper_Data::FLUBIT_FAILED_PRODUCT);
|
| 198 |
+
// save the status to zero so that its called next time only once its updated from backend
|
| 199 |
+
$flubit_Prodcut->setStatus('0')
|
| 200 |
+
->save();
|
| 201 |
+
} else {
|
| 202 |
+
Mage::log('Product was deleted from Magento SKU :' . $product->getSku(), null, Flubit_Flubit_Helper_Data::FLUBIT_FAILED_PRODUCT);
|
| 203 |
+
}
|
| 204 |
+
continue;
|
| 205 |
+
}
|
| 206 |
+
// if there is no image we can't push it to Flubit
|
| 207 |
+
if (!$this->checkImageValidation($product)) {
|
| 208 |
+
|
| 209 |
+
$errorString .= '<tr>
|
| 210 |
+
<td style="padding:4px;">' . $product->getName() . '</td>
|
| 211 |
+
<td style="padding:4px;">' . $product->getSku() . ' </td>
|
| 212 |
+
<td style="padding:4px;"> ' . 'No image is uploaded, so cannot be pushed to Flubit' . ' </td>
|
| 213 |
+
</tr>';
|
| 214 |
+
|
| 215 |
+
$response = 'Product SKU <b>"' . $product->getSku() . '"</b> image is not available. Please update the data where appropriate and send again. ';
|
| 216 |
+
$feedid = 'Product image validation failed.';
|
| 217 |
+
$this->logFlubitProductsRequestResponse('', $response, 'Create Product', $feedid);
|
| 218 |
+
Mage::log($product->getSku() . ' Image is not available. please update and send again.', null, Flubit_Flubit_Helper_Data::FLUBIT_FAILED_PRODUCT);
|
| 219 |
+
//the product has not been pushed and so should be treated as new
|
| 220 |
+
// save the status to zero so that its called next time only once its updated from backend
|
| 221 |
+
$flubit_Prodcut->setStatus('0')
|
| 222 |
+
->save();
|
| 223 |
+
continue;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
$flubit_stat = $product->getFlubitProduct(); // if product flubit stat is true
|
| 228 |
+
$status_stat = $product->getStatus(); // check if the product is active or inactive in magento
|
| 229 |
+
$stock = $product->getStockItem();
|
| 230 |
+
//Mage::log($stock->getData(), null, 'test.log');
|
| 231 |
+
$stock_status = $stock->getIsInStock();
|
| 232 |
+
|
| 233 |
+
$qtyStock = 0;
|
| 234 |
+
try {
|
| 235 |
+
$qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
|
| 236 |
+
$taxclassid = $product->getData('tax_class_id');
|
| 237 |
+
$percent = Mage::getModel('tax/calculation')->getRate($tax_calculation_obj->setProductClassId($taxclassid));
|
| 238 |
+
} catch (Exception $e) {
|
| 239 |
+
Mage::log(__LINE__ . ' Exception getting cataloginventory/stock_item tax/calculation Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
if ((floor($qtyStock) != $qtyStock)) { // check if the quantity is decimal
|
| 243 |
+
$errorString .= '<tr>
|
| 244 |
+
<td style="padding:4px;">' . $product->getName() . '</td>
|
| 245 |
+
<td style="padding:4px;">' . $product->getSku() . ' </td>
|
| 246 |
+
<td style="padding:4px;"> ' . 'Quantity is in decimal. Product cannot be pushed to Flubit.' . ' </td>
|
| 247 |
+
</tr>';
|
| 248 |
+
|
| 249 |
+
$response = 'Product SKU <b>"' . $product->getSku() . '"</b> quantity is in decimal. Please Insert it in integer only.';
|
| 250 |
+
$feedid = 'Product quantity validation failed.';
|
| 251 |
+
$this->logFlubitProductsRequestResponse('', $response, 'Create Product', $feedid);
|
| 252 |
+
|
| 253 |
+
Mage::log('quantity is in decimal = ' . $qtyStock, null, 'flubit_create_product.log');
|
| 254 |
+
$flubit_Prodcut->setStatus('0')
|
| 255 |
+
->save();
|
| 256 |
+
continue;
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
if (($flubit_stat == 1) && ($status_stat == 1) && ($stock_status) && ($qtyStock > 0)) {
|
| 260 |
+
$status = 'true';
|
| 261 |
+
} else {
|
| 262 |
+
$status = 'false';
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
if ($flubit_Prodcut->getNew() == '1') {
|
| 266 |
+
if ($product->getSku() != '') { // check if prodcut SKU is not null
|
| 267 |
+
$newXML .= '<product sku="' . $product->getSku() . '">';
|
| 268 |
+
$newXML .= '<title><![CDATA[' . $product->getName() . ']]></title>';
|
| 269 |
+
$newXML .= "<is_active>$status</is_active>";
|
| 270 |
+
$newXML .= '<base_price>' . (number_format($flubit_Prodcut->getPrice(), 2, '.', '')) . '</base_price>';
|
| 271 |
+
$newXML .= '<stock>' . number_format((int) $qtyStock, 0, '.', '') . '</stock>';
|
| 272 |
+
$newXML .= '<description><![CDATA[' . $this->removeNonUtfCharacters($product->getDescription()) . ']]></description>';
|
| 273 |
+
|
| 274 |
+
if ($product->getImage() != 'no_selection') {
|
| 275 |
+
$newXML .= '<images>';
|
| 276 |
+
$image_path = Mage::helper('catalog/image')->init($product, 'image');
|
| 277 |
+
$newXML .= '<image><![CDATA[' . $image_path . ']]></image>';
|
| 278 |
+
$newXML .= ' </images>';
|
| 279 |
+
}
|
| 280 |
+
if ($product->getFlubitEan() || $product->getFlubitAsin() || $product->getFlubitIsbn() || $product->getFlubitMpn()) {
|
| 281 |
+
$newXML .= '<identifiers>';
|
| 282 |
+
if ($product->getFlubitEan())
|
| 283 |
+
$newXML .= '<identifier type="EAN">' . $product->getFlubitEan() . '</identifier>';
|
| 284 |
+
if ($product->getFlubitAsin())
|
| 285 |
+
$newXML .= '<identifier type="ASIN">' . $product->getFlubitAsin() . '</identifier>';
|
| 286 |
+
if ($product->getFlubitIsbn())
|
| 287 |
+
$newXML .= '<identifier type="ISBN">' . $product->getFlubitIsbn() . '</identifier>';
|
| 288 |
+
if ($product->getFlubitMpn())
|
| 289 |
+
$newXML .= '<identifier type="MPN">' . $product->getFlubitMpn() . '</identifier>';
|
| 290 |
+
$newXML .= '</identifiers>';
|
| 291 |
+
}
|
| 292 |
+
if ($product->getFlubitBrand())
|
| 293 |
+
$newXML .= '<brand>' . $product->getFlubitBrand() . '</brand>';
|
| 294 |
+
if ($product->getFlubitStandardDelivery() || $product->getFlubitExpressDelivery()) {
|
| 295 |
+
$newXML .= '<delivery_cost>';
|
| 296 |
+
if ($product->getFlubitStandardDelivery())
|
| 297 |
+
$newXML .= '<standard>' . number_format($product->getFlubitStandardDelivery(), 2, '.', '') . '</standard>';
|
| 298 |
+
if ($product->getFlubitExpressDelivery())
|
| 299 |
+
$newXML .= '<express>' . number_format($product->getFlubitExpressDelivery(), 2, '.', '') . '</express>';
|
| 300 |
+
$newXML .= '</delivery_cost>';
|
| 301 |
+
}
|
| 302 |
+
if ($product->getWeight())
|
| 303 |
+
$newXML .= '<weight>' . number_format($product->getWeight(), 1, '.', '') . '</weight>';
|
| 304 |
+
if ($percent)
|
| 305 |
+
$newXML .= '<tax_rate>' . number_format($percent, 2, '.', '') . '</tax_rate>';
|
| 306 |
+
$newXML .= '</product>';
|
| 307 |
+
}
|
| 308 |
+
} else {
|
| 309 |
+
$updateXML .= '<product sku="' . $product->getSku() . '">';
|
| 310 |
+
$updateXML .= "<is_active>$status</is_active>";
|
| 311 |
+
$updateXML .= '<base_price>' . (number_format($flubit_Prodcut->getPrice(), 2, '.', '')) . '</base_price>';
|
| 312 |
+
$updateXML .= '<stock>' . number_format($qtyStock, 0, '.', '') . '</stock>';
|
| 313 |
+
$updateXML .= '</product>';
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
// set the flubit product status in flubit
|
| 317 |
+
|
| 318 |
+
try {
|
| 319 |
+
$flubitActiveStatus = '0';
|
| 320 |
+
if ($status == 'true')
|
| 321 |
+
$flubitActiveStatus = '1';
|
| 322 |
+
if ($flubit_Prodcut->getActiveStatus() != $flubitActiveStatus) {
|
| 323 |
+
//$flubit_Prodcut->setData(array('flubit_id' => $flubit_Prodcut->getId(), 'active_status' => $flubitActiveStatus))
|
| 324 |
+
$flubit_Prodcut->setActiveStatus($flubitActiveStatus)
|
| 325 |
+
->save();
|
| 326 |
+
}
|
| 327 |
+
} catch (Exception $e) {
|
| 328 |
+
Mage::log(__LINE__ . 'Exception Savingt flubit/flubit Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 329 |
+
}
|
| 330 |
+
$allSku[] = $product->getSku();
|
| 331 |
+
//Mage::log('Prodcut ' . print_r($product->getData(), TRUE ) , NULL, 'optimise.log');
|
| 332 |
+
}
|
| 333 |
+
// end for each of product list generation
|
| 334 |
+
|
| 335 |
+
if ($newXML != '') {
|
| 336 |
+
$create_feed_prodcut_xml = '<?xml version="1.0" encoding="UTF-8"?><products>' . $newXML . '</products>';
|
| 337 |
+
}
|
| 338 |
+
if ($updateXML != '') {
|
| 339 |
+
$update_feed_prodcut_xml = '<?xml version="1.0" encoding="UTF-8"?><products>' . $updateXML . '</products>';
|
| 340 |
+
}
|
| 341 |
+
//Mage::log($create_feed_prodcut_xml, NULL, 'CreateProduct.xml');
|
| 342 |
+
//Mage::log($update_feed_prodcut_xml, NULL, 'UpdateProduct.xml');
|
| 343 |
+
//Mage::log(print_r($allSku, TRUE), NULL, 'allSku.xml');
|
| 344 |
+
// preparing error String to be displayed on press of sync button
|
| 345 |
+
$productCount = count($allSku);
|
| 346 |
+
|
| 347 |
+
if ($errorString != '') {
|
| 348 |
+
$errorString = '<div>Following product(s) has failed.</div><br/>
|
| 349 |
+
<style type="text/css">
|
| 350 |
+
#tableOuter1{
|
| 351 |
+
border-style: solid;
|
| 352 |
+
border-width: 1px;
|
| 353 |
+
border-collapse: collapse;
|
| 354 |
+
margin: 0;
|
| 355 |
+
padding:4;
|
| 356 |
+
width:100%;
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
#tableOuter1 th,#tableOuter1 td{
|
| 360 |
+
border-style: solid;
|
| 361 |
+
border-width: 0 1px 1px 0;
|
| 362 |
+
border-collapse: collapse;
|
| 363 |
+
margin: 0;
|
| 364 |
+
padding:4;
|
| 365 |
+
}
|
| 366 |
+
</style>
|
| 367 |
+
<table id="tableOuter1" cellspacing="0" cellpadding="0">
|
| 368 |
+
<tr>
|
| 369 |
+
<th width="250"><strong>Product Name</strong></th>
|
| 370 |
+
<th width="250"><strong>Product SKU</strong></th>
|
| 371 |
+
<th width="250"><strong>Error Message</strong></th>
|
| 372 |
+
</tr>
|
| 373 |
+
' . $errorString . '
|
| 374 |
+
</table>';
|
| 375 |
+
}
|
| 376 |
+
$failed_sku_create = array();
|
| 377 |
+
$failed_sku_update = array();
|
| 378 |
+
$createFailedCount = 0;
|
| 379 |
+
$updateFailedCount = 0;
|
| 380 |
+
$feedError = '';
|
| 381 |
+
$feedStatus = '';
|
| 382 |
+
$feedMode = '';
|
| 383 |
+
$feedResponseXML = '';
|
| 384 |
+
// get model of config
|
| 385 |
+
$config = Mage::getModel('flubit/config');
|
| 386 |
+
// send the prodcuct create feed to flubit and save the id returned to log
|
| 387 |
+
if ($create_feed_prodcut_xml != '') { // if create product feed is not null send to flubit
|
| 388 |
+
$create_result = $config->createFlubitProducts($create_feed_prodcut_xml);
|
| 389 |
+
if ($create_result != '') {
|
| 390 |
+
Mage::log($create_result, NULL, 'createfeed.log');
|
| 391 |
+
if (is_object($create_result)) {
|
| 392 |
+
if ($create_result->getName() == 'id') {
|
| 393 |
+
$this->feedLog($create_result, 'Create');
|
| 394 |
+
$returnString .= 'Created Feed ID : ' . (String) $create_result . '<br/>';
|
| 395 |
+
// get the feed response if its a create feed
|
| 396 |
+
$feedCheckResponseCreate = $this->getFeedErrors($create_result);
|
| 397 |
+
|
| 398 |
+
$createFailedCount = $feedCheckResponseCreate->failedCount;
|
| 399 |
+
$errorString .= $feedCheckResponseCreate->html;
|
| 400 |
+
$failed_sku_create = $feedCheckResponseCreate->sku;
|
| 401 |
+
$feedError .= $feedCheckResponseCreate->error;
|
| 402 |
+
$feedResponseCreateXML = $feedCheckResponseCreate->responsexml;
|
| 403 |
+
|
| 404 |
+
$this->logFlubitProductsRequestResponse($create_feed_prodcut_xml, $feedResponseCreateXML, 'Create Product', $create_result);
|
| 405 |
+
// if feedresponse is fetched and is a success mark it to db as fetched
|
| 406 |
+
$feedResponseCreateXML = simplexml_load_string($feedResponseCreateXML);
|
| 407 |
+
if ($feedResponseCreateXML['status'] == 'processed') {
|
| 408 |
+
if ($feedResponseCreateXML->results->errors->total == 0) {
|
| 409 |
+
$this->feedResponseFetchedMarkToDb($create_result);
|
| 410 |
+
}
|
| 411 |
+
}
|
| 412 |
+
}
|
| 413 |
+
}
|
| 414 |
+
} else {
|
| 415 |
+
Mage::throwException('Response not received from flubit for create product request.');
|
| 416 |
+
}
|
| 417 |
+
}
|
| 418 |
+
// send the prodcuct uppdate feed to flubit and save the id returned to log
|
| 419 |
+
if ($update_feed_prodcut_xml != '') { // if create product feed is not null send to flubit
|
| 420 |
+
$update_result = $config->updateFlubitProducts($update_feed_prodcut_xml);
|
| 421 |
+
if ($update_result != '') {
|
| 422 |
+
Mage::log(print_r($update_result, true), NULL, 'updatefeed.log');
|
| 423 |
+
if (is_object($update_result)) {
|
| 424 |
+
if ($update_result->getName() == 'id') {
|
| 425 |
+
$this->feedLog($update_result, 'update');
|
| 426 |
+
$returnString .= 'Updated Feed ID : ' . (String) $update_result . '<br/>';
|
| 427 |
+
// get the feed response if its a update feed
|
| 428 |
+
$feedCheckResponseUpdate = $this->getFeedErrors($update_result);
|
| 429 |
+
|
| 430 |
+
$updateFailedCount = $feedCheckResponseUpdate->failedCount;
|
| 431 |
+
$errorString .= $feedCheckResponseUpdate->html;
|
| 432 |
+
$failed_sku_update = $feedCheckResponseUpdate->sku;
|
| 433 |
+
$feedError .= $feedCheckResponseUpdate->error;
|
| 434 |
+
$feedResponseupdateXML = $feedCheckResponseUpdate->responsexml;
|
| 435 |
+
|
| 436 |
+
$this->logFlubitProductsRequestResponse($update_feed_prodcut_xml, $feedResponseupdateXML, 'Update Product', $update_result);
|
| 437 |
+
// if feedresponse is fetched and is a success mark it to db as fetched
|
| 438 |
+
$feedResponseupdateXML = simplexml_load_string($feedResponseupdateXML);
|
| 439 |
+
if ($feedResponseupdateXML['status'] == 'processed') {
|
| 440 |
+
if ($feedResponseupdateXML->results->errors->total == 0) {
|
| 441 |
+
$this->feedResponseFetchedMarkToDb($update_result);
|
| 442 |
+
}
|
| 443 |
+
}
|
| 444 |
+
}
|
| 445 |
+
}
|
| 446 |
+
} else {
|
| 447 |
+
Mage::throwException('Response not received from flubit for update product request.');
|
| 448 |
+
}
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
// get differance of failed SKU from create and update
|
| 452 |
+
$allSku = array_diff($allSku, $failed_sku_create);
|
| 453 |
+
$allSku = array_diff($allSku, $failed_sku_update);
|
| 454 |
+
|
| 455 |
+
if ($errorFeed == '') {
|
| 456 |
+
try {
|
| 457 |
+
$flubits = Mage::getModel('flubit/flubit')->getCollection();
|
| 458 |
+
$flubits->addFieldToFilter('sku', array('in' => $allSku))
|
| 459 |
+
;
|
| 460 |
+
foreach ($flubits as $flubit) {
|
| 461 |
+
$flubit
|
| 462 |
+
->setStatus('2')
|
| 463 |
+
->setNew('0')
|
| 464 |
+
->save();
|
| 465 |
+
}
|
| 466 |
+
} catch (Exception $e) {
|
| 467 |
+
Mage::log(__LINE__ . ' Exception Savingt flubit/flubit Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 468 |
+
}
|
| 469 |
+
}
|
| 470 |
+
}
|
| 471 |
+
}
|
| 472 |
+
} catch (Exception $e) {
|
| 473 |
+
$error = $e->getMessage();
|
| 474 |
+
Mage::log('Try getting flubit prodcuts data ' . $e, NULL, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
if (!$error) {
|
| 478 |
+
if ($productCount != 0) {
|
| 479 |
+
$returnString .= "\n\t<p>Total Products Pushed: " . ($productCount - $createFailedCount - $updateFailedCount ) . '</p>';
|
| 480 |
+
if ($errorString != '')
|
| 481 |
+
Mage::getSingleton('adminhtml/session')->addError($errorString);
|
| 482 |
+
} else if (($productCount == 0 ) && ($errorFeed != '')) {
|
| 483 |
+
$returnString = "<p>Prodcuts not pushed. Please Retry</p>";
|
| 484 |
+
} else {
|
| 485 |
+
$returnString = "<p>There are $productCount products to be pushed to Flubit.</p>";
|
| 486 |
+
if ($errorString != '')
|
| 487 |
+
Mage::getSingleton('adminhtml/session')->addError($errorString);
|
| 488 |
+
}
|
| 489 |
+
} else {
|
| 490 |
+
Mage::log('Error Occured ' . $error, null, Flubit_Flubit_Helper_Data::FLUBIT_FAILED_PRODUCT);
|
| 491 |
+
Mage::throwException($error);
|
| 492 |
+
}
|
| 493 |
+
return $returnString;
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
/**
|
| 497 |
+
* Method to check feed and insert into Logs table
|
| 498 |
+
* @param string
|
| 499 |
+
* @return None
|
| 500 |
+
*/
|
| 501 |
+
public function feedLog($feedId, $type) {
|
| 502 |
+
if (($feedId != '') && ($type != '')) {
|
| 503 |
+
try {
|
| 504 |
+
$feedModel = Mage::getModel('flubit/logs');
|
| 505 |
+
$feedModel->setFeedType($type)
|
| 506 |
+
->setFeedId($feedId)
|
| 507 |
+
->setStatus('0')
|
| 508 |
+
->setCreatedAt(date('Y-m-d H:i:s'))
|
| 509 |
+
->save();
|
| 510 |
+
} catch (Exception $e) {
|
| 511 |
+
Mage::log(__LINE__ . ' Exception Flubit Feed Log ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 512 |
+
}
|
| 513 |
+
}
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
/**
|
| 517 |
+
* Method to check server side validation for blank check key & secret
|
| 518 |
+
* @param string
|
| 519 |
+
* @return boolean
|
| 520 |
+
*/
|
| 521 |
+
public function checkConfiguration() {
|
| 522 |
+
$return = new stdClass();
|
| 523 |
+
$return->right = 'false';
|
| 524 |
+
$return->error = 'false';
|
| 525 |
+
|
| 526 |
+
try {
|
| 527 |
+
$api = Mage::getStoreConfig(self::CONSUMER_API);
|
| 528 |
+
$key = Mage::getStoreConfig(self::SECRET_KEY);
|
| 529 |
+
$url = Mage::getStoreConfig(self::CONSUMER_URL);
|
| 530 |
+
|
| 531 |
+
if (!empty($api) && !empty($key) && !empty($url)) {
|
| 532 |
+
$obj = new Flubit_Flubit_Client($api, $key, $url);
|
| 533 |
+
|
| 534 |
+
$return->right = 'true';
|
| 535 |
+
} else {
|
| 536 |
+
Mage::log('Missing Keys in configuration', null, Flubit_Flubit_Helper_Data::FLUBIT_MISSING_CONFIG);
|
| 537 |
+
$return->error = 'true';
|
| 538 |
+
}
|
| 539 |
+
} catch (Exception $e) {
|
| 540 |
+
Mage::log('Missing Keys in configuration', null, Flubit_Flubit_Helper_Data::FLUBIT_MISSING_CONFIG);
|
| 541 |
+
$return->error = 'true';
|
| 542 |
+
}
|
| 543 |
+
return $return;
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
/**
|
| 547 |
+
* Method to update global price according to configuration
|
| 548 |
+
* @param integer $product
|
| 549 |
+
* @return int
|
| 550 |
+
*/
|
| 551 |
+
public function updateFlubitPrice() {
|
| 552 |
+
//Mage::log('price',null,'hum.log');
|
| 553 |
+
try {
|
| 554 |
+
$priceBasedOn = Mage::getStoreConfig('flubit_section/flubit_setup/price_based_on');
|
| 555 |
+
$globalPrice = Mage::getStoreConfig('flubit_section/flubit_setup/global_price');
|
| 556 |
+
$flubitCollection = Mage::getModel('flubit/flubit')->getCollection()
|
| 557 |
+
->addfieldtofilter('use_global_price', '1')
|
| 558 |
+
->addfieldtofilter('global_price_update', '0')
|
| 559 |
+
->addFieldToSelect('sku')
|
| 560 |
+
->addFieldToSelect('flubit_id')
|
| 561 |
+
->addFieldToSelect('price')
|
| 562 |
+
->setOrder('flubit_id', 'DESC')
|
| 563 |
+
->setPageSize('200');
|
| 564 |
+
//Mage::log($flubitCollection->getData(), null, 'hum.log');
|
| 565 |
+
foreach ($flubitCollection as $flubit) {
|
| 566 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $flubit->getSku());
|
| 567 |
+
if (is_object($product)) {
|
| 568 |
+
if ($priceBasedOn) {
|
| 569 |
+
$priceOfProduct = $product->getData($priceBasedOn); // Get price based on selected price
|
| 570 |
+
} else {
|
| 571 |
+
$priceOfProduct = $product->getPrice($priceBasedOn); // get default magento price
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
$flubitPrice = $priceOfProduct * $globalPrice;
|
| 575 |
+
$flubitPrice = number_format($flubitPrice, 2, '.', '');
|
| 576 |
+
|
| 577 |
+
if ($flubitPrice != $flubit->getPrice()) {
|
| 578 |
+
//updating the price in the main table
|
| 579 |
+
$flubit->setPrice($flubitPrice)
|
| 580 |
+
->setGlobalPriceUpdate('1')
|
| 581 |
+
->setStatus('1')
|
| 582 |
+
->save();
|
| 583 |
+
}
|
| 584 |
+
} // product object check
|
| 585 |
+
}
|
| 586 |
+
} catch (Exception $e) {
|
| 587 |
+
Mage::log(__LINE__ . ' Exception get flubit price Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 588 |
+
}
|
| 589 |
+
return 0;
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
/**
|
| 593 |
+
* Method to get Flubit Price
|
| 594 |
+
* @param integer $product
|
| 595 |
+
* @return int
|
| 596 |
+
*/
|
| 597 |
+
public function getFlubitPrice($product) {
|
| 598 |
+
try {
|
| 599 |
+
$priceBasedOn = Mage::getStoreConfig('flubit_section/flubit_setup/price_based_on');
|
| 600 |
+
$globalPrice = Mage::getStoreConfig('flubit_section/flubit_setup/global_price');
|
| 601 |
+
|
| 602 |
+
if (is_object($product)) {
|
| 603 |
+
|
| 604 |
+
$flubitProduct = Mage::getModel('flubit/flubit')->getcollection()->addfieldtofilter('sku', $product->getSku());
|
| 605 |
+
$flubitPriceUseGlobal = 0; // set by default
|
| 606 |
+
foreach ($flubitProduct as $flubit) {
|
| 607 |
+
$flubitPriceUseGlobal = $flubit->getUseGlobalPrice();
|
| 608 |
+
}
|
| 609 |
+
// if global price is zero than calculate with the given conditions
|
| 610 |
+
if (($product->getFlubitBasePrice() != 0.00) && ($flubitPriceUseGlobal == 0))
|
| 611 |
+
return $product->getFlubitBasePrice(); // return default flubit price
|
| 612 |
+
else if ($priceBasedOn)
|
| 613 |
+
$priceBasedOn = $product->getData($priceBasedOn); // Get price based on selected price
|
| 614 |
+
else {
|
| 615 |
+
$priceBasedOn = $product->getPrice($priceBasedOn); // get default magento price
|
| 616 |
+
}
|
| 617 |
+
$flubitPrice = $priceBasedOn * $globalPrice;
|
| 618 |
+
$flubitPrice = number_format($flubitPrice, 2, '.', '');
|
| 619 |
+
//$product->setFlubitBasePrice($flubitPrice)->save();
|
| 620 |
+
if ($flubitPriceUseGlobal == 0) {
|
| 621 |
+
if (is_object($flubit)) {
|
| 622 |
+
$flubit->setUseGlobalPrice(1)
|
| 623 |
+
->save();
|
| 624 |
+
}
|
| 625 |
+
}
|
| 626 |
+
return $flubitPrice;
|
| 627 |
+
}
|
| 628 |
+
} catch (Exception $e) {
|
| 629 |
+
Mage::log(__LINE__ . ' Exception get flubit price Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 630 |
+
}
|
| 631 |
+
return 0;
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
/**
|
| 635 |
+
* Method to Update Flubit Price
|
| 636 |
+
*/
|
| 637 |
+
private function _updateFlubitPrices() {
|
| 638 |
+
try {
|
| 639 |
+
$flubitCollection = Mage::getModel('flubit/flubit')->getCollection();
|
| 640 |
+
|
| 641 |
+
foreach ($flubitCollection as $flubit) {
|
| 642 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $flubit->getSku());
|
| 643 |
+
if (is_object($product)) {
|
| 644 |
+
$flubitPrice = $this->getFlubitPrice($product);
|
| 645 |
+
|
| 646 |
+
if (($flubitPrice != $flubit->getPrice()) || ($product->getFlubitBasePrice() != $flubitPrice)) {
|
| 647 |
+
try {
|
| 648 |
+
//updating the price in the main table
|
| 649 |
+
$flubit->setPrice($flubitPrice)
|
| 650 |
+
->setStatus('1')
|
| 651 |
+
->save();
|
| 652 |
+
//updating the product attribute flubit base price
|
| 653 |
+
$product->setFlubitBasePrice($flubitPrice)
|
| 654 |
+
->save();
|
| 655 |
+
} catch (Exception $e) {
|
| 656 |
+
Mage::log('Update Flubit Price Exception ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 657 |
+
}
|
| 658 |
+
}
|
| 659 |
+
}
|
| 660 |
+
}
|
| 661 |
+
} catch (Exception $e) {
|
| 662 |
+
Mage::log(__LINE__ . ' Exception updateFlubitPrices Model data ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 663 |
+
}
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
/**
|
| 667 |
+
* Method to Update Flubit Quantity
|
| 668 |
+
*/
|
| 669 |
+
private function _updateFlubitQty() {
|
| 670 |
+
try {
|
| 671 |
+
$flubitCollection = Mage::getModel('flubit/flubit')->getCollection();
|
| 672 |
+
|
| 673 |
+
foreach ($flubitCollection as $flubit) {
|
| 674 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $flubit->getSku());
|
| 675 |
+
$qty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
|
| 676 |
+
|
| 677 |
+
if ($qty != (int) $flubit->getQty()) {
|
| 678 |
+
//updating the Qty in the main table
|
| 679 |
+
$flubit->setQty($qty)
|
| 680 |
+
->setStatus('1')
|
| 681 |
+
->save();
|
| 682 |
+
}
|
| 683 |
+
}
|
| 684 |
+
} catch (Exception $e) {
|
| 685 |
+
Mage::log(__LINE__ . ' Exception _updateFlubitQty ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 686 |
+
}
|
| 687 |
+
}
|
| 688 |
+
|
| 689 |
+
/**
|
| 690 |
+
* Method for Check Ean, Asin, Isbn, Mpn
|
| 691 |
+
*
|
| 692 |
+
* @param String $pr
|
| 693 |
+
* @return boolean
|
| 694 |
+
*/
|
| 695 |
+
public function checkEanValidation($pr) {
|
| 696 |
+
try {
|
| 697 |
+
if (is_object($pr)) {
|
| 698 |
+
if ($pr->getFlubitEan() || $pr->getFlubitAsin() || $pr->getFlubitIsbn() || $pr->getFlubitMpn()) {
|
| 699 |
+
return true;
|
| 700 |
+
}
|
| 701 |
+
}
|
| 702 |
+
return false;
|
| 703 |
+
} catch (Exception $e) {
|
| 704 |
+
Mage::log(__LINE__ . ' Exception checkEanValidation ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 705 |
+
}
|
| 706 |
+
}
|
| 707 |
+
|
| 708 |
+
/**
|
| 709 |
+
* Method for Check Image not Blank
|
| 710 |
+
*
|
| 711 |
+
* @param String $pr
|
| 712 |
+
* @return boolean
|
| 713 |
+
*/
|
| 714 |
+
public function checkImageValidation($pr) {
|
| 715 |
+
if ($pr->getImage() != 'no_selection') {
|
| 716 |
+
try {
|
| 717 |
+
$image_path = Mage::helper('catalog/image')->init($pr, 'image');
|
| 718 |
+
if ($image_path != '') {
|
| 719 |
+
return true;
|
| 720 |
+
}
|
| 721 |
+
} catch (Exception $e) {
|
| 722 |
+
Mage::log(__LINE__ . ' Exception Image Validation ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 723 |
+
}
|
| 724 |
+
}
|
| 725 |
+
return false;
|
| 726 |
+
}
|
| 727 |
+
|
| 728 |
+
/**
|
| 729 |
+
* Method for Check Image not Blank
|
| 730 |
+
*
|
| 731 |
+
* @param String $pr
|
| 732 |
+
* @return boolean
|
| 733 |
+
*/
|
| 734 |
+
public function checkQuantityValidation($pr) {
|
| 735 |
+
//Mage::log($pr->getQty() , null, flubit_create_product.log);
|
| 736 |
+
if (is_int($pr->getQty())) {
|
| 737 |
+
return true;
|
| 738 |
+
}
|
| 739 |
+
return false;
|
| 740 |
+
}
|
| 741 |
+
|
| 742 |
+
/**
|
| 743 |
+
* Method to remove non utf character
|
| 744 |
+
*
|
| 745 |
+
* @param String $Str
|
| 746 |
+
* @return String
|
| 747 |
+
*/
|
| 748 |
+
public function removeNonUtfCharacters($Str) {
|
| 749 |
+
try {
|
| 750 |
+
$StrArr = STR_SPLIT($Str);
|
| 751 |
+
$NewStr = '';
|
| 752 |
+
foreach ($StrArr as $Char) {
|
| 753 |
+
$CharNo = ORD($Char);
|
| 754 |
+
if ($CharNo == 163) {
|
| 755 |
+
$NewStr .= $Char;
|
| 756 |
+
continue;
|
| 757 |
+
} // keep £
|
| 758 |
+
if ($CharNo > 31 && $CharNo < 127) {
|
| 759 |
+
$NewStr .= $Char;
|
| 760 |
+
}
|
| 761 |
+
}
|
| 762 |
+
} catch (Exception $e) {
|
| 763 |
+
Mage::log(__LINE__ . ' Exception removeNonUtfCharacters ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 764 |
+
}
|
| 765 |
+
return $NewStr;
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
/**
|
| 769 |
+
* Method to check the status of the pushed feed
|
| 770 |
+
*
|
| 771 |
+
* @param SimpleXmlObject
|
| 772 |
+
* @param String mode
|
| 773 |
+
* @return Object
|
| 774 |
+
*/
|
| 775 |
+
public function getFeedErrors($xmlObj) {
|
| 776 |
+
try {
|
| 777 |
+
//Mage::log('Check For feed id ' . $xmlObj, null, 'Test_Feed.log');
|
| 778 |
+
//sleep(5);
|
| 779 |
+
$return = new stdClass();
|
| 780 |
+
$return->failedCount = 0;
|
| 781 |
+
$return->html = '';
|
| 782 |
+
$return->sku = array();
|
| 783 |
+
$return->error = '';
|
| 784 |
+
$return->status = '';
|
| 785 |
+
$return->mode = '';
|
| 786 |
+
$return->responsexml = '';
|
| 787 |
+
|
| 788 |
+
try {
|
| 789 |
+
$config = Mage::getModel('flubit/config');
|
| 790 |
+
$xmlObjRes = $config->getproductFeedStatus($xmlObj, 'xml');
|
| 791 |
+
$return->responsexml = $xmlObjRes;
|
| 792 |
+
} catch (Exception $e) {
|
| 793 |
+
Mage::log('Exception Getting Feed Errors ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 794 |
+
}
|
| 795 |
+
|
| 796 |
+
$xmlObjRes = simplexml_load_string($xmlObjRes);
|
| 797 |
+
if (is_object($xmlObjRes)) {
|
| 798 |
+
|
| 799 |
+
if ($xmlObjRes->getName() == 'error') {
|
| 800 |
+
$errorCode = $xmlObjRes['code'];
|
| 801 |
+
$return->error = $xmlObjRes['message'];
|
| 802 |
+
$this->feedResponseFetchedMarkToDb($xmlObj); // feed response recived mark in database
|
| 803 |
+
Mage::log('Error: Code ' . $errorCode . ' Error Message : ' . $return->error, null, Flubit_Flubit_Helper_Data::FLUBIT_FEED);
|
| 804 |
+
} else if ($xmlObjRes->getName() == 'feed') {
|
| 805 |
+
if ($xmlObjRes['status'] == 'invalid') {
|
| 806 |
+
$return->error = 'Invalid Feed Sent to flubit';
|
| 807 |
+
$this->feedResponseFetchedMarkToDb($xmlObj); // feed response recived mark in database
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
if ($xmlObjRes['status'] == 'processing') {
|
| 811 |
+
Mage::log('Feed ID is Under Processing : ' . $xmlObj, null, Flubit_Flubit_Helper_Data::FLUBIT_FEED);
|
| 812 |
+
} else if ($xmlObjRes['status'] == 'processed') {
|
| 813 |
+
//Mage::log('hello afetr created check : ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 814 |
+
if (isset($xmlObjRes->results->created)) {
|
| 815 |
+
//Mage::log('afetr created check : ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 816 |
+
$return->mode = 'created';
|
| 817 |
+
$this->feedResponseFetchedMarkToDb($xmlObj); // feed response recived mark in database
|
| 818 |
+
//Mage::log('After Create mark db : ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 819 |
+
if (isset($xmlObjRes->results->errors->total)) {
|
| 820 |
+
if ($xmlObjRes->results->errors->total > 0) {
|
| 821 |
+
$return->failedCount = $xmlObjRes->results->errors->total;
|
| 822 |
+
$innerTable = '';
|
| 823 |
+
$productAlreadyExist = array();
|
| 824 |
+
foreach ($xmlObjRes->results->errors->sample->error as $error) {
|
| 825 |
+
$productName = '';
|
| 826 |
+
try {
|
| 827 |
+
$productNameObj = Mage::getModel('catalog/product')->loadByAttribute('sku', $error['sku']);
|
| 828 |
+
if (is_object($productNameObj))
|
| 829 |
+
$productName = $productNameObj->getName();
|
| 830 |
+
else {
|
| 831 |
+
Mage::log('Unable to get product Name for SKU: ' . $error['sku'], null, Flubit_Flubit_Helper_Data::FLUBIT_FEED);
|
| 832 |
+
}
|
| 833 |
+
} catch (Exception $e) {
|
| 834 |
+
Mage::log('Unable to get name of product Get Feed Errors ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 835 |
+
}
|
| 836 |
+
if ($error == 'Product already exists.') {
|
| 837 |
+
$productAlreadyExist[] = $error['sku'];
|
| 838 |
+
} else {
|
| 839 |
+
$return->sku[] = $error['sku'];
|
| 840 |
+
$innerTable .= '<tr>
|
| 841 |
+
<td style="padding:4px;">' . $productName . '</td>
|
| 842 |
+
<td style="padding:4px;">' . $error['sku'] . ' </td>
|
| 843 |
+
<td style="padding:4px;"> ' . $error . ' </td>
|
| 844 |
+
</tr>';
|
| 845 |
+
}
|
| 846 |
+
}
|
| 847 |
+
if ($innerTable != '')
|
| 848 |
+
$return->html = '<div>Following product(s) has failed to sync.</div><br/>
|
| 849 |
+
<style type="text/css">
|
| 850 |
+
#tableOuter{
|
| 851 |
+
border-style: solid;
|
| 852 |
+
border-width: 1px;
|
| 853 |
+
border-collapse: collapse;
|
| 854 |
+
margin: 0;
|
| 855 |
+
padding:4;
|
| 856 |
+
width:100%;
|
| 857 |
+
}
|
| 858 |
+
|
| 859 |
+
#tableOuter th,#tableOuter td{
|
| 860 |
+
border-style: solid;
|
| 861 |
+
border-width: 0 1px 1px 0;
|
| 862 |
+
border-collapse: collapse;
|
| 863 |
+
margin: 0;
|
| 864 |
+
padding:4;
|
| 865 |
+
}
|
| 866 |
+
</style>
|
| 867 |
+
<table id="tableOuter" cellspacing="0" cellpadding="0">
|
| 868 |
+
<tr>
|
| 869 |
+
<th width="250"><strong>Product Name</strong></th>
|
| 870 |
+
<th width="250"><strong>Product SKU</strong></th>
|
| 871 |
+
<th width="250"><strong>Error Message</strong></th>
|
| 872 |
+
</tr>
|
| 873 |
+
' . $innerTable . '
|
| 874 |
+
</table>';
|
| 875 |
+
if (count($productAlreadyExist) > 0) {
|
| 876 |
+
$this->requeuFailedFeedSku($productAlreadyExist, '');
|
| 877 |
+
Mage::log('Update Product to be in create request :' . print_r($productAlreadyExist, true), null, 'up_error.log');
|
| 878 |
+
// since returned error is product already exist in list
|
| 879 |
+
// such that it goen in update Request
|
| 880 |
+
}
|
| 881 |
+
}
|
| 882 |
+
}
|
| 883 |
+
} else {
|
| 884 |
+
//Mage::log('Not Inside created block: ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 885 |
+
}
|
| 886 |
+
if (isset($xmlObjRes->results->updated)) {
|
| 887 |
+
$return->mode = 'updated';
|
| 888 |
+
if (isset($xmlObjRes->results->errors->total)) {
|
| 889 |
+
if ($xmlObjRes->results->errors->total > 0) {
|
| 890 |
+
$return->failedCount = $xmlObjRes->results->errors->total;
|
| 891 |
+
$UpdateFailedSku = array();
|
| 892 |
+
$innerTable = '';
|
| 893 |
+
foreach ($xmlObjRes->results->errors->sample->error as $error) {
|
| 894 |
+
$productName = '';
|
| 895 |
+
try {
|
| 896 |
+
$productName = Mage::getModel('catalog/product')->loadByAttribute('sku', $error['sku'])->getName();
|
| 897 |
+
} catch (Exception $e) {
|
| 898 |
+
Mage::log('Unable to get name of product Get Feed Errors ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 899 |
+
}
|
| 900 |
+
|
| 901 |
+
//$return->sku[] = $error['sku'];
|
| 902 |
+
|
| 903 |
+
if ($error == 'Product does not exist in cache.') // check if prodcut not in cache exists
|
| 904 |
+
$UpdateFailedSku[] = $error['sku'];
|
| 905 |
+
else
|
| 906 |
+
$return->sku[] = $error['sku'];
|
| 907 |
+
|
| 908 |
+
//Mage::log('Update Product Error :' . $error , null , 'up_error.log' );
|
| 909 |
+
|
| 910 |
+
$innerTable .= '<tr>
|
| 911 |
+
<td style="padding:4px;">' . $productName . '</td>
|
| 912 |
+
<td style="padding:4px;">' . $error['sku'] . ' </td>
|
| 913 |
+
<td style="padding:4px;"> ' . $error . ' </td>
|
| 914 |
+
</tr>';
|
| 915 |
+
}
|
| 916 |
+
if ($innerTable != '')
|
| 917 |
+
$return->html = '<div>Following product(s) Updates has failed to sync.</div><br/>
|
| 918 |
+
<style type="text/css">
|
| 919 |
+
#tableOuter2{
|
| 920 |
+
border-style: solid;
|
| 921 |
+
border-width: 1px;
|
| 922 |
+
border-collapse: collapse;
|
| 923 |
+
margin: 0;
|
| 924 |
+
padding:4;
|
| 925 |
+
width:100%;
|
| 926 |
+
}
|
| 927 |
+
|
| 928 |
+
#tableOuter2 th,#tableOuter2 td{
|
| 929 |
+
border-style: solid;
|
| 930 |
+
border-width: 0 1px 1px 0;
|
| 931 |
+
border-collapse: collapse;
|
| 932 |
+
margin: 0;
|
| 933 |
+
padding:4;
|
| 934 |
+
}
|
| 935 |
+
</style>
|
| 936 |
+
<table id="tableOuter2" cellspacing="0" cellpadding="0">
|
| 937 |
+
<tr>
|
| 938 |
+
<th width="250"><strong>Product Name</strong></th>
|
| 939 |
+
<th width="250"><strong>Product SKU</strong></th>
|
| 940 |
+
<th width="250"><strong>Error Message</strong></th>
|
| 941 |
+
</tr>
|
| 942 |
+
' . $innerTable . '
|
| 943 |
+
</table>';
|
| 944 |
+
// update products to create new if the returned skus have not in cache error
|
| 945 |
+
if (count($UpdateFailedSku) > 0) {
|
| 946 |
+
$this->requeuFailedFeedSku($UpdateFailedSku, 'created');
|
| 947 |
+
//Mage::log('Update Product to be in create request :' . print_r($UpdateFailedSku,true) , null , 'up_error.log' );
|
| 948 |
+
// since returned error is not exist in cache we need to update product
|
| 949 |
+
// such that it goen in create request
|
| 950 |
+
}
|
| 951 |
+
}
|
| 952 |
+
}
|
| 953 |
+
$this->feedResponseFetchedMarkToDb($xmlObj);
|
| 954 |
+
// feed response recived mark in database
|
| 955 |
+
//Mage::log('After update mark db : ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 956 |
+
} else {
|
| 957 |
+
//Mage::log('Not Inside Updated Block : ' . ' Feed Id = ' . $xmlObj , null, 'temptest.log' );
|
| 958 |
+
}
|
| 959 |
+
}
|
| 960 |
+
} else {
|
| 961 |
+
|
| 962 |
+
}
|
| 963 |
+
}
|
| 964 |
+
return $return;
|
| 965 |
+
} catch (Exception $e) {
|
| 966 |
+
Mage::log(__LINE__ . ' Exception getFeedErrors ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 967 |
+
}
|
| 968 |
+
}
|
| 969 |
+
|
| 970 |
+
/**
|
| 971 |
+
* Method to mark the response of checked feed to DB
|
| 972 |
+
*
|
| 973 |
+
* @param String
|
| 974 |
+
* @return void
|
| 975 |
+
*/
|
| 976 |
+
public function feedResponseFetchedMarkToDb($feedId) {
|
| 977 |
+
//Mage::log('Inside MArk feed response : ' . ' Feed Id = ' . $feedId , null, 'temptest.log' );
|
| 978 |
+
try {
|
| 979 |
+
|
| 980 |
+
$logs = Mage::getModel('flubit/logs')->getCollection()
|
| 981 |
+
->addFieldToFilter('feed_id', $feedId);
|
| 982 |
+
|
| 983 |
+
foreach ($logs as $flb) {
|
| 984 |
+
//Mage::log('Save Feed Status As Fetched : ' . $flb->getId() . ' Feed Id = ' . $feedId , null, 'temptest.log' );
|
| 985 |
+
$flb->setData(array('flubit_id' => $flb->getId(), 'status' => 1))
|
| 986 |
+
->save();
|
| 987 |
+
}
|
| 988 |
+
} catch (Exception $e) {
|
| 989 |
+
Mage::log('Error Saving to Database Flubit Log Exception : ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 990 |
+
}
|
| 991 |
+
}
|
| 992 |
+
|
| 993 |
+
/**
|
| 994 |
+
* Method to check all pending feeds whose status is not fetched
|
| 995 |
+
*
|
| 996 |
+
* @param void
|
| 997 |
+
* @return void
|
| 998 |
+
*/
|
| 999 |
+
public function _checkPendingFeedStatus() {
|
| 1000 |
+
try {
|
| 1001 |
+
$logs = Mage::getModel('flubit/logs')->getCollection()
|
| 1002 |
+
->addFieldToFilter('status', 0);
|
| 1003 |
+
//Mage::log(print_r($logs, true), null, 'flubit_product_feed.log');
|
| 1004 |
+
foreach ($logs as $flb) {
|
| 1005 |
+
Mage::log('Feeds Returned : ' . $flb->getFeedId(), null, 'temptest.log');
|
| 1006 |
+
$result = $this->getFeedErrors($flb->getFeedId());
|
| 1007 |
+
$this->logFlubitProductsRequestResponse('Request sent to check feed id: <b>"' . $flb->getFeedId() . '"</b>', $result->responsexml, 'Check Feed Response', $flb->getFeedId());
|
| 1008 |
+
if ($result->failedCount > 0) {
|
| 1009 |
+
Mage::log('Failed Count: ' . $result->failedCount . ' Mode = ' . $result->mode . ' SKU' . print_r($result->sku, true), null, 'temptest.log');
|
| 1010 |
+
$this->requeuFailedFeedSku($result->sku, $result->mode);
|
| 1011 |
+
}
|
| 1012 |
+
//Mage::log('Response : ' . print_r($result,true) , null, 'temptest.log' );
|
| 1013 |
+
}
|
| 1014 |
+
} catch (Exception $e) {
|
| 1015 |
+
Mage::log('Error Fetching Feeds : ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 1016 |
+
}
|
| 1017 |
+
}
|
| 1018 |
+
|
| 1019 |
+
/**
|
| 1020 |
+
* Method to requeue the products for create and update
|
| 1021 |
+
*
|
| 1022 |
+
* @param array
|
| 1023 |
+
* @param String
|
| 1024 |
+
*
|
| 1025 |
+
* @return void
|
| 1026 |
+
*/
|
| 1027 |
+
public function requeuFailedFeedSku($sku, $mode) {
|
| 1028 |
+
try {
|
| 1029 |
+
if (is_array($sku)) {
|
| 1030 |
+
Mage::log('Requeue Failed Products: ' . print_r($sku, true), null, 'temptest.log');
|
| 1031 |
+
if (count($sku) > 0) {
|
| 1032 |
+
$new = 0;
|
| 1033 |
+
|
| 1034 |
+
if ($mode == 'created')
|
| 1035 |
+
$new = 1;
|
| 1036 |
+
foreach ($sku as $flsku) {
|
| 1037 |
+
$prod = Mage::getModel('flubit/flubit')->getCollection()
|
| 1038 |
+
->addFieldToFilter('sku', $flsku);
|
| 1039 |
+
foreach ($prod as $flprod) {
|
| 1040 |
+
try {
|
| 1041 |
+
$flprod->setData(array('flubit_id' => $flprod->getId(), 'status' => 1, 'new' => $new))
|
| 1042 |
+
->save();
|
| 1043 |
+
Mage::log('updated logs ' . $flprod->getId() . ' new = ' . $new, null, 'temptest.log');
|
| 1044 |
+
} catch (Exception $e) {
|
| 1045 |
+
Mage::log('Error Flubit product update Exception : ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 1046 |
+
}
|
| 1047 |
+
}
|
| 1048 |
+
}
|
| 1049 |
+
}
|
| 1050 |
+
}
|
| 1051 |
+
} catch (Exception $e) {
|
| 1052 |
+
Mage::log(__LINE__ . ' Exception getFeedErrors ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 1053 |
+
}
|
| 1054 |
+
}
|
| 1055 |
+
|
| 1056 |
+
/**
|
| 1057 |
+
* Method to Error logging the products for create and update and Check Feed Response
|
| 1058 |
+
*
|
| 1059 |
+
* @param array
|
| 1060 |
+
* @param String
|
| 1061 |
+
*
|
| 1062 |
+
* @return void
|
| 1063 |
+
*/
|
| 1064 |
+
function logFlubitProductsRequestResponse($request, $response, $mode, $feedId) {
|
| 1065 |
+
|
| 1066 |
+
if ($mode == 'Create Product') {
|
| 1067 |
+
$action = 1;
|
| 1068 |
+
} else if ($mode == 'Update Product') {
|
| 1069 |
+
$action = 2;
|
| 1070 |
+
} else if ($mode == 'Check Feed Response') {
|
| 1071 |
+
$action = 10;
|
| 1072 |
+
}
|
| 1073 |
+
if ($request != '') {
|
| 1074 |
+
if ($action == 10) {
|
| 1075 |
+
$request = $request;
|
| 1076 |
+
} else {
|
| 1077 |
+
$dom = new DOMDocument;
|
| 1078 |
+
$dom->preserveWhiteSpace = FALSE;
|
| 1079 |
+
$dom->loadXML($request);
|
| 1080 |
+
$dom->formatOutput = TRUE;
|
| 1081 |
+
$request = $dom->saveXml();
|
| 1082 |
+
}
|
| 1083 |
+
}
|
| 1084 |
+
$level = 2;
|
| 1085 |
+
|
| 1086 |
+
if ($response != '' && $request != '') {
|
| 1087 |
+
$xmlObjResCreate = simplexml_load_string($response);
|
| 1088 |
+
|
| 1089 |
+
if ($xmlObjResCreate->getName() == 'feed') {
|
| 1090 |
+
if ($xmlObjResCreate['status'] == 'processing' || $xmlObjResCreate['status'] == 'awaiting_validation' || $xmlObjResCreate['status'] == 'awaiting_processing') {
|
| 1091 |
+
$level = 1;
|
| 1092 |
+
}
|
| 1093 |
+
if ($xmlObjResCreate['status'] == 'processed') {
|
| 1094 |
+
if ($xmlObjResCreate->results->errors->total == 0) {
|
| 1095 |
+
$level = 1;
|
| 1096 |
+
}
|
| 1097 |
+
}
|
| 1098 |
+
} //feed if close
|
| 1099 |
+
}
|
| 1100 |
+
|
| 1101 |
+
|
| 1102 |
+
|
| 1103 |
+
if (($request != '') || ($response != '')) {
|
| 1104 |
+
try {
|
| 1105 |
+
$flubitlog = Mage::getModel('flubitlog/flubitlog');
|
| 1106 |
+
$flubitlog->setData(
|
| 1107 |
+
array(
|
| 1108 |
+
'request_xml' => $request,
|
| 1109 |
+
'feedid' => $feedId,
|
| 1110 |
+
'response_xml' => $response,
|
| 1111 |
+
'action' => $action,
|
| 1112 |
+
'datetime' => date('Y-m-d H:i:s'),
|
| 1113 |
+
'level' => $level
|
| 1114 |
+
)
|
| 1115 |
+
)
|
| 1116 |
+
->save();
|
| 1117 |
+
} catch (Exception $e) {
|
| 1118 |
+
|
| 1119 |
+
}
|
| 1120 |
+
}
|
| 1121 |
+
}
|
| 1122 |
+
|
| 1123 |
}
|
app/code/community/Flubit/Flubit/Model/Flubit/Price.php
CHANGED
|
@@ -1,27 +1,26 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
/**
|
| 4 |
-
* Class Flubit Model Flubit Price
|
| 5 |
-
*
|
| 6 |
-
* @package Flubit
|
| 7 |
-
* @category Flubit_Model
|
| 8 |
-
* @author Flubit team
|
| 9 |
-
*/
|
| 10 |
-
class Flubit_Flubit_Model_Flubit_Price {
|
| 11 |
-
|
| 12 |
-
/**
|
| 13 |
-
* Options getter
|
| 14 |
-
*
|
| 15 |
-
* @return array
|
| 16 |
-
*/
|
| 17 |
-
public function toOptionArray() {
|
| 18 |
-
return array(
|
| 19 |
-
array('value' => "", 'label' => ''),
|
| 20 |
-
array('value' => "price", 'label' => Mage::helper('adminhtml')->__('Price')),
|
| 21 |
-
array('value' => "
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
}
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Class Flubit Model Flubit Price
|
| 5 |
+
*
|
| 6 |
+
* @package Flubit
|
| 7 |
+
* @category Flubit_Model
|
| 8 |
+
* @author Flubit team
|
| 9 |
+
*/
|
| 10 |
+
class Flubit_Flubit_Model_Flubit_Price {
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Options getter
|
| 14 |
+
*
|
| 15 |
+
* @return array
|
| 16 |
+
*/
|
| 17 |
+
public function toOptionArray() {
|
| 18 |
+
return array(
|
| 19 |
+
array('value' => "", 'label' => ''),
|
| 20 |
+
array('value' => "price", 'label' => Mage::helper('adminhtml')->__('Price')),
|
| 21 |
+
array('value' => "cost", 'label' => Mage::helper('adminhtml')->__('Cost')),
|
| 22 |
+
|
| 23 |
+
);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
}
|
|
|
app/code/community/Flubit/Flubit/controllers/Adminhtml/FlubitController.php
CHANGED
|
@@ -1,234 +1,234 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
/**
|
| 4 |
-
* Class Flubit Adminhtml Flubit
|
| 5 |
-
*
|
| 6 |
-
* @package Flubit
|
| 7 |
-
* @category Flubit_Adminhtml
|
| 8 |
-
* @author Flubit team
|
| 9 |
-
*/
|
| 10 |
-
class Flubit_Flubit_Adminhtml_FlubitController extends Mage_Adminhtml_Controller_Action {
|
| 11 |
-
|
| 12 |
-
/**
|
| 13 |
-
* Method for InitAction Load
|
| 14 |
-
* @return \Flubit_Flubit_Adminhtml_FlubitController
|
| 15 |
-
*/
|
| 16 |
-
protected function _initAction() {
|
| 17 |
-
try {
|
| 18 |
-
$this->loadLayout()
|
| 19 |
-
->_setActiveMenu('flubit/items')
|
| 20 |
-
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 21 |
-
|
| 22 |
-
return $this;
|
| 23 |
-
} catch (Exception $e) {
|
| 24 |
-
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController _initAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 25 |
-
}
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
/**
|
| 29 |
-
* Method for Index Method load Action and Render
|
| 30 |
-
*
|
| 31 |
-
*/
|
| 32 |
-
public function indexAction() {
|
| 33 |
-
// Let's call our initAction method which will set some basic params for each action
|
| 34 |
-
try {
|
| 35 |
-
$this->_initAction()
|
| 36 |
-
->renderLayout();
|
| 37 |
-
} catch (Exception $e) {
|
| 38 |
-
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController indexAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 39 |
-
}
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
/**
|
| 43 |
-
* Method for Render to Edit
|
| 44 |
-
*
|
| 45 |
-
*/
|
| 46 |
-
public function newAction() {
|
| 47 |
-
// We just forward the new action to a blank edit form
|
| 48 |
-
$this->_forward('edit');
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
/**
|
| 52 |
-
* Method for Render to Edit Action
|
| 53 |
-
*
|
| 54 |
-
* @return none
|
| 55 |
-
*/
|
| 56 |
-
public function editAction() {
|
| 57 |
-
try {
|
| 58 |
-
$this->_initAction();
|
| 59 |
-
|
| 60 |
-
// Get id if available
|
| 61 |
-
$id = $this->getRequest()->getParam('id');
|
| 62 |
-
$model = Mage::getModel('flubit/flubit');
|
| 63 |
-
|
| 64 |
-
if ($id) {
|
| 65 |
-
// Load record
|
| 66 |
-
$model->load($id);
|
| 67 |
-
|
| 68 |
-
// Check if record is loaded
|
| 69 |
-
if (!$model->getId()) {
|
| 70 |
-
Mage::getSingleton('adminhtml/session')->addError($this->__('This baz no longer exists.'));
|
| 71 |
-
$this->_redirect('*/*/');
|
| 72 |
-
|
| 73 |
-
return;
|
| 74 |
-
}
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
$this->_title($model->getId() ? $model->getName() : $this->__('New Baz'));
|
| 78 |
-
|
| 79 |
-
$data = Mage::getSingleton('adminhtml/session')->getBazData(true);
|
| 80 |
-
if (!empty($data)) {
|
| 81 |
-
$model->setData($data);
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
Mage::register('flubit', $model);
|
| 85 |
-
|
| 86 |
-
$this->_initAction()
|
| 87 |
-
->_addBreadcrumb($id ? $this->__('Edit Baz') : $this->__('New Baz'), $id ? $this->__('Edit Baz') : $this->__('New Baz'))
|
| 88 |
-
->_addContent($this->getLayout()->createBlock('foo_bar/adminhtml_baz_edit')->setData('action', $this->getUrl('*/*/save')))
|
| 89 |
-
->renderLayout();
|
| 90 |
-
} catch (Exception $e) {
|
| 91 |
-
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController editAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 92 |
-
}
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
-
/**
|
| 96 |
-
* Method for Save Product Session Message
|
| 97 |
-
*
|
| 98 |
-
*/
|
| 99 |
-
public function saveAction() {
|
| 100 |
-
try {
|
| 101 |
-
if ($postData = $this->getRequest()->getPost()) {
|
| 102 |
-
$model = Mage::getSingleton('foo_bar/baz');
|
| 103 |
-
$model->setData($postData);
|
| 104 |
-
|
| 105 |
-
try {
|
| 106 |
-
$model->save();
|
| 107 |
-
|
| 108 |
-
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The baz has been saved.'));
|
| 109 |
-
$this->_redirect('*/*/');
|
| 110 |
-
|
| 111 |
-
return;
|
| 112 |
-
} catch (Mage_Core_Exception $e) {
|
| 113 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 114 |
-
} catch (Exception $e) {
|
| 115 |
-
Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving this baz.'));
|
| 116 |
-
}
|
| 117 |
-
|
| 118 |
-
Mage::getSingleton('adminhtml/session')->setBazData($postData);
|
| 119 |
-
$this->_redirectReferer();
|
| 120 |
-
}
|
| 121 |
-
} catch (Exception $e) {
|
| 122 |
-
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController saveAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 123 |
-
}
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
/**
|
| 127 |
-
* Method for Update Flubit Price
|
| 128 |
-
*
|
| 129 |
-
*/
|
| 130 |
-
public function updateFlubitPriceAction() {
|
| 131 |
-
try {
|
| 132 |
-
$error = false;
|
| 133 |
-
$message = '';
|
| 134 |
-
|
| 135 |
-
$fieldId = (int) $this->getRequest()->getParam('id');
|
| 136 |
-
$price = number_format($this->getRequest()->getParam('price'), 2, '.', '');
|
| 137 |
-
$sku = $this->getRequest()->getParam('sku');
|
| 138 |
-
if ($fieldId) {
|
| 139 |
-
$collection = Mage::getModel('flubit/flubit')->getCollection();
|
| 140 |
-
$collection->addFieldToFilter('flubit_id', $fieldId);
|
| 141 |
-
|
| 142 |
-
foreach ($collection as $flubit) {
|
| 143 |
-
$sku = $flubit->getSku();
|
| 144 |
-
$flubit->setPrice($price)
|
| 145 |
-
->setStatus(1)
|
| 146 |
-
->save();
|
| 147 |
-
}
|
| 148 |
-
$message = Mage::helper('adminhtml')->__('Flubit Price overriden for "%s"', $flubit->getSku());
|
| 149 |
-
} else {
|
| 150 |
-
$error = true;
|
| 151 |
-
$message = 'An error occured. Please retry';
|
| 152 |
-
}
|
| 153 |
-
$return = array();
|
| 154 |
-
if ($error) {
|
| 155 |
-
$return['ERROR'] = 1;
|
| 156 |
-
} else {
|
| 157 |
-
$return['SUCCESS'] = 1;
|
| 158 |
-
$return['PRICE'] = $price;
|
| 159 |
-
}
|
| 160 |
-
|
| 161 |
-
$return['MESSAGE'] = $message;
|
| 162 |
-
return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($return));
|
| 163 |
-
} catch (Exception $e) {
|
| 164 |
-
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController updateFlubitPriceAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 165 |
-
}
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
-
/**
|
| 169 |
-
* Method for Update Flubit Price Calculator
|
| 170 |
-
*
|
| 171 |
-
*/
|
| 172 |
-
public function updateFlubitPriceCalculatorAction() {
|
| 173 |
-
try {
|
| 174 |
-
$error = false;
|
| 175 |
-
$message = '';
|
| 176 |
-
$fieldId = (int) $this->getRequest()->getParam('id');
|
| 177 |
-
$status = $this->getRequest()->getParam('status');
|
| 178 |
-
$priceBasedOn = Mage::getStoreConfig('flubit_section/flubit_setup/price_based_on');
|
| 179 |
-
$globalPrice = Mage::getStoreConfig('flubit_section/flubit_setup/global_price');
|
| 180 |
-
if ($fieldId && $status !== '') {
|
| 181 |
-
$collection = Mage::getModel('flubit/flubit')->getCollection()
|
| 182 |
-
->addFieldToFilter('flubit_id', $fieldId)
|
| 183 |
-
->addFieldToSelect('sku')
|
| 184 |
-
->addFieldToSelect('flubit_id')
|
| 185 |
-
->addFieldToSelect('price');
|
| 186 |
-
foreach ($collection as $flubit) {
|
| 187 |
-
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $flubit->getSku());
|
| 188 |
-
if (is_object($product)) {
|
| 189 |
-
if ($priceBasedOn) {
|
| 190 |
-
$priceOfProduct = $product->getData($priceBasedOn); // Get price based on selected price
|
| 191 |
-
} else {
|
| 192 |
-
$priceOfProduct = $product->getPrice($priceBasedOn); // get default magento price
|
| 193 |
-
}
|
| 194 |
-
|
| 195 |
-
$flubitPrice = $priceOfProduct
|
| 196 |
-
$flubitPrice = number_format($flubitPrice, 2, '.', '');
|
| 197 |
-
//updating the price in the main table
|
| 198 |
-
if ($status == '1') {
|
| 199 |
-
$flubit->setPrice($flubitPrice)
|
| 200 |
-
->setUseGlobalPrice('1')
|
| 201 |
-
->setGlobalPriceUpdate('1')
|
| 202 |
-
->setStatus('1')
|
| 203 |
-
->save();
|
| 204 |
-
} else {
|
| 205 |
-
$flubit->setGlobalPriceUpdate('1')
|
| 206 |
-
->setUseGlobalPrice('0')
|
| 207 |
-
->setStatus('1')
|
| 208 |
-
->save();
|
| 209 |
-
}
|
| 210 |
-
$message = Mage::helper('adminhtml')->__('Flubit Price overriden for "%s"', $flubit->getSku());
|
| 211 |
-
} // product object check
|
| 212 |
-
}
|
| 213 |
-
} else {
|
| 214 |
-
$error = true;
|
| 215 |
-
$message = Mage::helper('adminhtml')->__('Missing flubit row id or status.');
|
| 216 |
-
}
|
| 217 |
-
|
| 218 |
-
$return = array();
|
| 219 |
-
if ($error) {
|
| 220 |
-
$return['ERROR'] = 1;
|
| 221 |
-
} else {
|
| 222 |
-
$return['SUCCESS'] = 1;
|
| 223 |
-
$return['PRICE'] = $flubitPrice;
|
| 224 |
-
$return['ID'] = $fieldId;
|
| 225 |
-
}
|
| 226 |
-
|
| 227 |
-
$return['MESSAGE'] = $message;
|
| 228 |
-
return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($return));
|
| 229 |
-
} catch (Exception $e) {
|
| 230 |
-
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController updateFlubitPriceCalculatorAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 231 |
-
}
|
| 232 |
-
}
|
| 233 |
-
|
| 234 |
}
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Class Flubit Adminhtml Flubit
|
| 5 |
+
*
|
| 6 |
+
* @package Flubit
|
| 7 |
+
* @category Flubit_Adminhtml
|
| 8 |
+
* @author Flubit team
|
| 9 |
+
*/
|
| 10 |
+
class Flubit_Flubit_Adminhtml_FlubitController extends Mage_Adminhtml_Controller_Action {
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Method for InitAction Load
|
| 14 |
+
* @return \Flubit_Flubit_Adminhtml_FlubitController
|
| 15 |
+
*/
|
| 16 |
+
protected function _initAction() {
|
| 17 |
+
try {
|
| 18 |
+
$this->loadLayout()
|
| 19 |
+
->_setActiveMenu('flubit/items')
|
| 20 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 21 |
+
|
| 22 |
+
return $this;
|
| 23 |
+
} catch (Exception $e) {
|
| 24 |
+
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController _initAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Method for Index Method load Action and Render
|
| 30 |
+
*
|
| 31 |
+
*/
|
| 32 |
+
public function indexAction() {
|
| 33 |
+
// Let's call our initAction method which will set some basic params for each action
|
| 34 |
+
try {
|
| 35 |
+
$this->_initAction()
|
| 36 |
+
->renderLayout();
|
| 37 |
+
} catch (Exception $e) {
|
| 38 |
+
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController indexAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Method for Render to Edit
|
| 44 |
+
*
|
| 45 |
+
*/
|
| 46 |
+
public function newAction() {
|
| 47 |
+
// We just forward the new action to a blank edit form
|
| 48 |
+
$this->_forward('edit');
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Method for Render to Edit Action
|
| 53 |
+
*
|
| 54 |
+
* @return none
|
| 55 |
+
*/
|
| 56 |
+
public function editAction() {
|
| 57 |
+
try {
|
| 58 |
+
$this->_initAction();
|
| 59 |
+
|
| 60 |
+
// Get id if available
|
| 61 |
+
$id = $this->getRequest()->getParam('id');
|
| 62 |
+
$model = Mage::getModel('flubit/flubit');
|
| 63 |
+
|
| 64 |
+
if ($id) {
|
| 65 |
+
// Load record
|
| 66 |
+
$model->load($id);
|
| 67 |
+
|
| 68 |
+
// Check if record is loaded
|
| 69 |
+
if (!$model->getId()) {
|
| 70 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('This baz no longer exists.'));
|
| 71 |
+
$this->_redirect('*/*/');
|
| 72 |
+
|
| 73 |
+
return;
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
$this->_title($model->getId() ? $model->getName() : $this->__('New Baz'));
|
| 78 |
+
|
| 79 |
+
$data = Mage::getSingleton('adminhtml/session')->getBazData(true);
|
| 80 |
+
if (!empty($data)) {
|
| 81 |
+
$model->setData($data);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
Mage::register('flubit', $model);
|
| 85 |
+
|
| 86 |
+
$this->_initAction()
|
| 87 |
+
->_addBreadcrumb($id ? $this->__('Edit Baz') : $this->__('New Baz'), $id ? $this->__('Edit Baz') : $this->__('New Baz'))
|
| 88 |
+
->_addContent($this->getLayout()->createBlock('foo_bar/adminhtml_baz_edit')->setData('action', $this->getUrl('*/*/save')))
|
| 89 |
+
->renderLayout();
|
| 90 |
+
} catch (Exception $e) {
|
| 91 |
+
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController editAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* Method for Save Product Session Message
|
| 97 |
+
*
|
| 98 |
+
*/
|
| 99 |
+
public function saveAction() {
|
| 100 |
+
try {
|
| 101 |
+
if ($postData = $this->getRequest()->getPost()) {
|
| 102 |
+
$model = Mage::getSingleton('foo_bar/baz');
|
| 103 |
+
$model->setData($postData);
|
| 104 |
+
|
| 105 |
+
try {
|
| 106 |
+
$model->save();
|
| 107 |
+
|
| 108 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The baz has been saved.'));
|
| 109 |
+
$this->_redirect('*/*/');
|
| 110 |
+
|
| 111 |
+
return;
|
| 112 |
+
} catch (Mage_Core_Exception $e) {
|
| 113 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 114 |
+
} catch (Exception $e) {
|
| 115 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving this baz.'));
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
Mage::getSingleton('adminhtml/session')->setBazData($postData);
|
| 119 |
+
$this->_redirectReferer();
|
| 120 |
+
}
|
| 121 |
+
} catch (Exception $e) {
|
| 122 |
+
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController saveAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
/**
|
| 127 |
+
* Method for Update Flubit Price
|
| 128 |
+
*
|
| 129 |
+
*/
|
| 130 |
+
public function updateFlubitPriceAction() {
|
| 131 |
+
try {
|
| 132 |
+
$error = false;
|
| 133 |
+
$message = '';
|
| 134 |
+
|
| 135 |
+
$fieldId = (int) $this->getRequest()->getParam('id');
|
| 136 |
+
$price = number_format($this->getRequest()->getParam('price'), 2, '.', '');
|
| 137 |
+
$sku = $this->getRequest()->getParam('sku');
|
| 138 |
+
if ($fieldId) {
|
| 139 |
+
$collection = Mage::getModel('flubit/flubit')->getCollection();
|
| 140 |
+
$collection->addFieldToFilter('flubit_id', $fieldId);
|
| 141 |
+
|
| 142 |
+
foreach ($collection as $flubit) {
|
| 143 |
+
$sku = $flubit->getSku();
|
| 144 |
+
$flubit->setPrice($price)
|
| 145 |
+
->setStatus(1)
|
| 146 |
+
->save();
|
| 147 |
+
}
|
| 148 |
+
$message = Mage::helper('adminhtml')->__('Flubit Price overriden for "%s"', $flubit->getSku());
|
| 149 |
+
} else {
|
| 150 |
+
$error = true;
|
| 151 |
+
$message = 'An error occured. Please retry';
|
| 152 |
+
}
|
| 153 |
+
$return = array();
|
| 154 |
+
if ($error) {
|
| 155 |
+
$return['ERROR'] = 1;
|
| 156 |
+
} else {
|
| 157 |
+
$return['SUCCESS'] = 1;
|
| 158 |
+
$return['PRICE'] = $price;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
$return['MESSAGE'] = $message;
|
| 162 |
+
return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($return));
|
| 163 |
+
} catch (Exception $e) {
|
| 164 |
+
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController updateFlubitPriceAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
/**
|
| 169 |
+
* Method for Update Flubit Price Calculator
|
| 170 |
+
*
|
| 171 |
+
*/
|
| 172 |
+
public function updateFlubitPriceCalculatorAction() {
|
| 173 |
+
try {
|
| 174 |
+
$error = false;
|
| 175 |
+
$message = '';
|
| 176 |
+
$fieldId = (int) $this->getRequest()->getParam('id');
|
| 177 |
+
$status = $this->getRequest()->getParam('status');
|
| 178 |
+
$priceBasedOn = Mage::getStoreConfig('flubit_section/flubit_setup/price_based_on');
|
| 179 |
+
$globalPrice = Mage::getStoreConfig('flubit_section/flubit_setup/global_price');
|
| 180 |
+
if ($fieldId && $status !== '') {
|
| 181 |
+
$collection = Mage::getModel('flubit/flubit')->getCollection()
|
| 182 |
+
->addFieldToFilter('flubit_id', $fieldId)
|
| 183 |
+
->addFieldToSelect('sku')
|
| 184 |
+
->addFieldToSelect('flubit_id')
|
| 185 |
+
->addFieldToSelect('price');
|
| 186 |
+
foreach ($collection as $flubit) {
|
| 187 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $flubit->getSku());
|
| 188 |
+
if (is_object($product)) {
|
| 189 |
+
if ($priceBasedOn) {
|
| 190 |
+
$priceOfProduct = $product->getData($priceBasedOn); // Get price based on selected price
|
| 191 |
+
} else {
|
| 192 |
+
$priceOfProduct = $product->getPrice($priceBasedOn); // get default magento price
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
$flubitPrice = $priceOfProduct * $globalPrice;
|
| 196 |
+
$flubitPrice = number_format($flubitPrice, 2, '.', '');
|
| 197 |
+
//updating the price in the main table
|
| 198 |
+
if ($status == '1') {
|
| 199 |
+
$flubit->setPrice($flubitPrice)
|
| 200 |
+
->setUseGlobalPrice('1')
|
| 201 |
+
->setGlobalPriceUpdate('1')
|
| 202 |
+
->setStatus('1')
|
| 203 |
+
->save();
|
| 204 |
+
} else {
|
| 205 |
+
$flubit->setGlobalPriceUpdate('1')
|
| 206 |
+
->setUseGlobalPrice('0')
|
| 207 |
+
->setStatus('1')
|
| 208 |
+
->save();
|
| 209 |
+
}
|
| 210 |
+
$message = Mage::helper('adminhtml')->__('Flubit Price overriden for "%s"', $flubit->getSku());
|
| 211 |
+
} // product object check
|
| 212 |
+
}
|
| 213 |
+
} else {
|
| 214 |
+
$error = true;
|
| 215 |
+
$message = Mage::helper('adminhtml')->__('Missing flubit row id or status.');
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
$return = array();
|
| 219 |
+
if ($error) {
|
| 220 |
+
$return['ERROR'] = 1;
|
| 221 |
+
} else {
|
| 222 |
+
$return['SUCCESS'] = 1;
|
| 223 |
+
$return['PRICE'] = $flubitPrice;
|
| 224 |
+
$return['ID'] = $fieldId;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
$return['MESSAGE'] = $message;
|
| 228 |
+
return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($return));
|
| 229 |
+
} catch (Exception $e) {
|
| 230 |
+
Mage::log(__LINE__ . 'Exception Flubit_Flubit_Adminhtml_FlubitController updateFlubitPriceCalculatorAction ' . $e, null, Flubit_Flubit_Helper_Data::FLUBIT_EXCEPTIONS);
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
}
|
app/code/community/Flubit/Flubit/etc/system.xml
CHANGED
|
@@ -1,177 +1,177 @@
|
|
| 1 |
-
<?xml version="1.0"?>
|
| 2 |
-
<config>
|
| 3 |
-
<tabs>
|
| 4 |
-
<flubit_tab translate="label" module="flubit">
|
| 5 |
-
<!--<label>flubit</label>-->
|
| 6 |
-
<label><![CDATA[<div style="position: absolute;"><img id="flubit_logo" src="" alt="" border="0" /></div> <script>$('flubit_logo').src = SKIN_URL + "images/flubit/logo.png";</script>]]></label>
|
| 7 |
-
<sort_order>0</sort_order>
|
| 8 |
-
</flubit_tab>
|
| 9 |
-
</tabs>
|
| 10 |
-
<sections>
|
| 11 |
-
<flubit_section translate="label" module="flubit">
|
| 12 |
-
<label>Flubit</label>
|
| 13 |
-
<tab>flubit_tab</tab>
|
| 14 |
-
<frontend_type>text</frontend_type>
|
| 15 |
-
<sort_order>0</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 |
-
<groups>
|
| 20 |
-
<flubit_configuration translate="label">
|
| 21 |
-
<label>Flubit Configuration</label>
|
| 22 |
-
<frontend_type>text</frontend_type>
|
| 23 |
-
<sort_order>1</sort_order>
|
| 24 |
-
<show_in_default>1</show_in_default>
|
| 25 |
-
<show_in_website>1</show_in_website>
|
| 26 |
-
<show_in_store>1</show_in_store>
|
| 27 |
-
<comment><![CDATA[<span style="color:#2a6994;">
|
| 28 |
-
<strong style="color:#00AEED;">Disclaimer:</strong><br/>
|
| 29 |
-
In order for the extension to run please ensure that Crons/Scheduled Tasks are set up and executing on your hosted environment.<br/><br/>
|
| 30 |
-
If not the following functionalities will be affected.<br/>
|
| 31 |
-
<ul>
|
| 32 |
-
<li>1. Product Creation and Updates to the Flubit Channel.</li>
|
| 33 |
-
<li>2. Fetching Orders from Flubit.</li>
|
| 34 |
-
<li>3. Order Status Updates being sent to Flubit.</li>
|
| 35 |
-
|
| 36 |
-
</ul><br/>
|
| 37 |
-
<span style="color:#000;">Fields with * are Mandatory.</span>
|
| 38 |
-
</span><br/>
|
| 39 |
-
<br/>
|
| 40 |
-
]]></comment>
|
| 41 |
-
<fields>
|
| 42 |
-
<flubit_consumer_key translate="label">
|
| 43 |
-
<label>Consumer Key*</label>
|
| 44 |
-
<frontend_type>text</frontend_type>
|
| 45 |
-
<sort_order>1</sort_order>
|
| 46 |
-
<show_in_default>1</show_in_default>
|
| 47 |
-
<show_in_website>1</show_in_website>
|
| 48 |
-
<show_in_store>1</show_in_store>
|
| 49 |
-
<validate>required-entry</validate>
|
| 50 |
-
<comment>Please enter your personal consumer key provided by Flubit.</comment>
|
| 51 |
-
</flubit_consumer_key>
|
| 52 |
-
<flubit_secret translate="label">
|
| 53 |
-
<label>Secret*</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 |
-
<validate>required-entry</validate>
|
| 60 |
-
<comment>Please enter your personal secret key provided by Flubit.</comment>
|
| 61 |
-
</flubit_secret>
|
| 62 |
-
<flubit_url translate="label">
|
| 63 |
-
<label>URL*</label>
|
| 64 |
-
<frontend_type>text</frontend_type>
|
| 65 |
-
<sort_order>3</sort_order>
|
| 66 |
-
<show_in_default>1</show_in_default>
|
| 67 |
-
<show_in_website>1</show_in_website>
|
| 68 |
-
<show_in_store>1</show_in_store>
|
| 69 |
-
<validate>required-entry</validate>
|
| 70 |
-
<comment>Please enter the API URL</comment>
|
| 71 |
-
</flubit_url>
|
| 72 |
-
<run translate="label">
|
| 73 |
-
<frontend_type>button</frontend_type>
|
| 74 |
-
<frontend_model>Flubit_Flubit_Block_Adminhtml_Button</frontend_model>
|
| 75 |
-
<sort_order>20</sort_order>
|
| 76 |
-
<show_in_default>1</show_in_default>
|
| 77 |
-
<show_in_website>1</show_in_website>
|
| 78 |
-
<show_in_store>1</show_in_store>
|
| 79 |
-
</run>
|
| 80 |
-
</fields>
|
| 81 |
-
</flubit_configuration>
|
| 82 |
-
<flubit_setup translate="label">
|
| 83 |
-
<label>Flubit Setup</label>
|
| 84 |
-
<frontend_type>text</frontend_type>
|
| 85 |
-
<sort_order>2</sort_order>
|
| 86 |
-
<show_in_default>1</show_in_default>
|
| 87 |
-
<show_in_website>1</show_in_website>
|
| 88 |
-
<show_in_store>1</show_in_store>
|
| 89 |
-
<fields>
|
| 90 |
-
<product_cron_settings translate="label">
|
| 91 |
-
<label>Product Update Frequency</label>
|
| 92 |
-
<frontend_type>select</frontend_type>
|
| 93 |
-
<source_model>flubit/flubit_source</source_model>
|
| 94 |
-
<sort_order>1</sort_order>
|
| 95 |
-
<show_in_default>1</show_in_default>
|
| 96 |
-
<show_in_website>1</show_in_website>
|
| 97 |
-
<show_in_store>1</show_in_store>
|
| 98 |
-
<comment>How often do you want the cron to run?</comment>
|
| 99 |
-
</product_cron_settings>
|
| 100 |
-
<order_cron_settings translate="label">
|
| 101 |
-
<label>Order Fetch Freqency</label>
|
| 102 |
-
<frontend_type>select</frontend_type>
|
| 103 |
-
<source_model>flubit/flubit_order</source_model>
|
| 104 |
-
<sort_order>2</sort_order>
|
| 105 |
-
<show_in_default>1</show_in_default>
|
| 106 |
-
<show_in_website>1</show_in_website>
|
| 107 |
-
<show_in_store>1</show_in_store>
|
| 108 |
-
<comment>How often do you want the cron to run?</comment>
|
| 109 |
-
</order_cron_settings>
|
| 110 |
-
<order_dispatch_cron_settings translate="label">
|
| 111 |
-
<label>Dispatch Order Freqency</label>
|
| 112 |
-
<frontend_type>select</frontend_type>
|
| 113 |
-
<source_model>flubit/flubit_rcd</source_model>
|
| 114 |
-
<sort_order>3</sort_order>
|
| 115 |
-
<show_in_default>1</show_in_default>
|
| 116 |
-
<show_in_website>1</show_in_website>
|
| 117 |
-
<show_in_store>1</show_in_store>
|
| 118 |
-
<comment>How often do you want the cron to run?</comment>
|
| 119 |
-
</order_dispatch_cron_settings>
|
| 120 |
-
<order_cancel_cron_settings translate="label">
|
| 121 |
-
<label>Cancel Order Freqency</label>
|
| 122 |
-
<frontend_type>select</frontend_type>
|
| 123 |
-
<source_model>flubit/flubit_rcd</source_model>
|
| 124 |
-
<sort_order>4</sort_order>
|
| 125 |
-
<show_in_default>1</show_in_default>
|
| 126 |
-
<show_in_website>1</show_in_website>
|
| 127 |
-
<show_in_store>1</show_in_store>
|
| 128 |
-
<comment>How often do you want the cron to run?</comment>
|
| 129 |
-
</order_cancel_cron_settings>
|
| 130 |
-
<order_refund_cron_settings translate="label">
|
| 131 |
-
<label>Refund Order Freqency</label>
|
| 132 |
-
<frontend_type>select</frontend_type>
|
| 133 |
-
<source_model>flubit/flubit_rcd</source_model>
|
| 134 |
-
<sort_order>5</sort_order>
|
| 135 |
-
<show_in_default>1</show_in_default>
|
| 136 |
-
<show_in_website>1</show_in_website>
|
| 137 |
-
<show_in_store>1</show_in_store>
|
| 138 |
-
<comment>How often do you want the cron to run?</comment>
|
| 139 |
-
</order_refund_cron_settings>
|
| 140 |
-
<flubit_chunk translate="label">
|
| 141 |
-
<label>Product Chunk Size</label>
|
| 142 |
-
<frontend_type>select</frontend_type>
|
| 143 |
-
<source_model>flubit/flubit_chunk</source_model>
|
| 144 |
-
<sort_order>9</sort_order>
|
| 145 |
-
<show_in_default>1</show_in_default>
|
| 146 |
-
<show_in_website>1</show_in_website>
|
| 147 |
-
<show_in_store>1</show_in_store>
|
| 148 |
-
<validate>required-entry validate-greater-than-zero</validate>
|
| 149 |
-
<comment>Please select the maximum number of records you would like to push per request.</comment>
|
| 150 |
-
</flubit_chunk>
|
| 151 |
-
<price_based_on translate="label">
|
| 152 |
-
<label>FBP based On:*</label>
|
| 153 |
-
<frontend_type>select</frontend_type>
|
| 154 |
-
<source_model>flubit/flubit_price</source_model>
|
| 155 |
-
<sort_order>10</sort_order>
|
| 156 |
-
<show_in_default>1</show_in_default>
|
| 157 |
-
<show_in_website>1</show_in_website>
|
| 158 |
-
<show_in_store>1</show_in_store>
|
| 159 |
-
<validate>required-entry</validate>
|
| 160 |
-
<comment></comment>
|
| 161 |
-
</price_based_on>
|
| 162 |
-
<global_price translate="label">
|
| 163 |
-
<label>Percentage Calculation:(%)*</label>
|
| 164 |
-
<frontend_type>text</frontend_type>
|
| 165 |
-
<sort_order>11</sort_order>
|
| 166 |
-
<show_in_default>1</show_in_default>
|
| 167 |
-
<show_in_website>1</show_in_website>
|
| 168 |
-
<show_in_store>1</show_in_store>
|
| 169 |
-
<validate>required-entry validate-greater-than-zero</validate>
|
| 170 |
-
<comment>The above two fields allow you to apply a global percentage discount or surcharge based on either store price
|
| 171 |
-
</global_price>
|
| 172 |
-
</fields>
|
| 173 |
-
</flubit_setup>
|
| 174 |
-
</groups>
|
| 175 |
-
</flubit_section>
|
| 176 |
-
</sections>
|
| 177 |
-
</config>
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<tabs>
|
| 4 |
+
<flubit_tab translate="label" module="flubit">
|
| 5 |
+
<!--<label>flubit</label>-->
|
| 6 |
+
<label><![CDATA[<div style="position: absolute;"><img id="flubit_logo" src="" alt="" border="0" /></div> <script>$('flubit_logo').src = SKIN_URL + "images/flubit/logo.png";</script>]]></label>
|
| 7 |
+
<sort_order>0</sort_order>
|
| 8 |
+
</flubit_tab>
|
| 9 |
+
</tabs>
|
| 10 |
+
<sections>
|
| 11 |
+
<flubit_section translate="label" module="flubit">
|
| 12 |
+
<label>Flubit</label>
|
| 13 |
+
<tab>flubit_tab</tab>
|
| 14 |
+
<frontend_type>text</frontend_type>
|
| 15 |
+
<sort_order>0</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 |
+
<groups>
|
| 20 |
+
<flubit_configuration translate="label">
|
| 21 |
+
<label>Flubit Configuration</label>
|
| 22 |
+
<frontend_type>text</frontend_type>
|
| 23 |
+
<sort_order>1</sort_order>
|
| 24 |
+
<show_in_default>1</show_in_default>
|
| 25 |
+
<show_in_website>1</show_in_website>
|
| 26 |
+
<show_in_store>1</show_in_store>
|
| 27 |
+
<comment><![CDATA[<span style="color:#2a6994;">
|
| 28 |
+
<strong style="color:#00AEED;">Disclaimer:</strong><br/>
|
| 29 |
+
In order for the extension to run please ensure that Crons/Scheduled Tasks are set up and executing on your hosted environment.<br/><br/>
|
| 30 |
+
If not the following functionalities will be affected.<br/>
|
| 31 |
+
<ul>
|
| 32 |
+
<li>1. Product Creation and Updates to the Flubit Channel.</li>
|
| 33 |
+
<li>2. Fetching Orders from Flubit.</li>
|
| 34 |
+
<li>3. Order Status Updates being sent to Flubit.</li>
|
| 35 |
+
|
| 36 |
+
</ul><br/>
|
| 37 |
+
<span style="color:#000;">Fields with * are Mandatory.</span>
|
| 38 |
+
</span><br/>
|
| 39 |
+
<br/>
|
| 40 |
+
]]></comment>
|
| 41 |
+
<fields>
|
| 42 |
+
<flubit_consumer_key translate="label">
|
| 43 |
+
<label>Consumer Key*</label>
|
| 44 |
+
<frontend_type>text</frontend_type>
|
| 45 |
+
<sort_order>1</sort_order>
|
| 46 |
+
<show_in_default>1</show_in_default>
|
| 47 |
+
<show_in_website>1</show_in_website>
|
| 48 |
+
<show_in_store>1</show_in_store>
|
| 49 |
+
<validate>required-entry</validate>
|
| 50 |
+
<comment>Please enter your personal consumer key provided by Flubit.</comment>
|
| 51 |
+
</flubit_consumer_key>
|
| 52 |
+
<flubit_secret translate="label">
|
| 53 |
+
<label>Secret*</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 |
+
<validate>required-entry</validate>
|
| 60 |
+
<comment>Please enter your personal secret key provided by Flubit.</comment>
|
| 61 |
+
</flubit_secret>
|
| 62 |
+
<flubit_url translate="label">
|
| 63 |
+
<label>URL*</label>
|
| 64 |
+
<frontend_type>text</frontend_type>
|
| 65 |
+
<sort_order>3</sort_order>
|
| 66 |
+
<show_in_default>1</show_in_default>
|
| 67 |
+
<show_in_website>1</show_in_website>
|
| 68 |
+
<show_in_store>1</show_in_store>
|
| 69 |
+
<validate>required-entry</validate>
|
| 70 |
+
<comment>Please enter the API URL</comment>
|
| 71 |
+
</flubit_url>
|
| 72 |
+
<run translate="label">
|
| 73 |
+
<frontend_type>button</frontend_type>
|
| 74 |
+
<frontend_model>Flubit_Flubit_Block_Adminhtml_Button</frontend_model>
|
| 75 |
+
<sort_order>20</sort_order>
|
| 76 |
+
<show_in_default>1</show_in_default>
|
| 77 |
+
<show_in_website>1</show_in_website>
|
| 78 |
+
<show_in_store>1</show_in_store>
|
| 79 |
+
</run>
|
| 80 |
+
</fields>
|
| 81 |
+
</flubit_configuration>
|
| 82 |
+
<flubit_setup translate="label">
|
| 83 |
+
<label>Flubit Setup</label>
|
| 84 |
+
<frontend_type>text</frontend_type>
|
| 85 |
+
<sort_order>2</sort_order>
|
| 86 |
+
<show_in_default>1</show_in_default>
|
| 87 |
+
<show_in_website>1</show_in_website>
|
| 88 |
+
<show_in_store>1</show_in_store>
|
| 89 |
+
<fields>
|
| 90 |
+
<product_cron_settings translate="label">
|
| 91 |
+
<label>Product Update Frequency</label>
|
| 92 |
+
<frontend_type>select</frontend_type>
|
| 93 |
+
<source_model>flubit/flubit_source</source_model>
|
| 94 |
+
<sort_order>1</sort_order>
|
| 95 |
+
<show_in_default>1</show_in_default>
|
| 96 |
+
<show_in_website>1</show_in_website>
|
| 97 |
+
<show_in_store>1</show_in_store>
|
| 98 |
+
<comment>How often do you want the cron to run?</comment>
|
| 99 |
+
</product_cron_settings>
|
| 100 |
+
<order_cron_settings translate="label">
|
| 101 |
+
<label>Order Fetch Freqency</label>
|
| 102 |
+
<frontend_type>select</frontend_type>
|
| 103 |
+
<source_model>flubit/flubit_order</source_model>
|
| 104 |
+
<sort_order>2</sort_order>
|
| 105 |
+
<show_in_default>1</show_in_default>
|
| 106 |
+
<show_in_website>1</show_in_website>
|
| 107 |
+
<show_in_store>1</show_in_store>
|
| 108 |
+
<comment>How often do you want the cron to run?</comment>
|
| 109 |
+
</order_cron_settings>
|
| 110 |
+
<order_dispatch_cron_settings translate="label">
|
| 111 |
+
<label>Dispatch Order Freqency</label>
|
| 112 |
+
<frontend_type>select</frontend_type>
|
| 113 |
+
<source_model>flubit/flubit_rcd</source_model>
|
| 114 |
+
<sort_order>3</sort_order>
|
| 115 |
+
<show_in_default>1</show_in_default>
|
| 116 |
+
<show_in_website>1</show_in_website>
|
| 117 |
+
<show_in_store>1</show_in_store>
|
| 118 |
+
<comment>How often do you want the cron to run?</comment>
|
| 119 |
+
</order_dispatch_cron_settings>
|
| 120 |
+
<order_cancel_cron_settings translate="label">
|
| 121 |
+
<label>Cancel Order Freqency</label>
|
| 122 |
+
<frontend_type>select</frontend_type>
|
| 123 |
+
<source_model>flubit/flubit_rcd</source_model>
|
| 124 |
+
<sort_order>4</sort_order>
|
| 125 |
+
<show_in_default>1</show_in_default>
|
| 126 |
+
<show_in_website>1</show_in_website>
|
| 127 |
+
<show_in_store>1</show_in_store>
|
| 128 |
+
<comment>How often do you want the cron to run?</comment>
|
| 129 |
+
</order_cancel_cron_settings>
|
| 130 |
+
<order_refund_cron_settings translate="label">
|
| 131 |
+
<label>Refund Order Freqency</label>
|
| 132 |
+
<frontend_type>select</frontend_type>
|
| 133 |
+
<source_model>flubit/flubit_rcd</source_model>
|
| 134 |
+
<sort_order>5</sort_order>
|
| 135 |
+
<show_in_default>1</show_in_default>
|
| 136 |
+
<show_in_website>1</show_in_website>
|
| 137 |
+
<show_in_store>1</show_in_store>
|
| 138 |
+
<comment>How often do you want the cron to run?</comment>
|
| 139 |
+
</order_refund_cron_settings>
|
| 140 |
+
<flubit_chunk translate="label">
|
| 141 |
+
<label>Product Chunk Size</label>
|
| 142 |
+
<frontend_type>select</frontend_type>
|
| 143 |
+
<source_model>flubit/flubit_chunk</source_model>
|
| 144 |
+
<sort_order>9</sort_order>
|
| 145 |
+
<show_in_default>1</show_in_default>
|
| 146 |
+
<show_in_website>1</show_in_website>
|
| 147 |
+
<show_in_store>1</show_in_store>
|
| 148 |
+
<validate>required-entry validate-greater-than-zero</validate>
|
| 149 |
+
<comment>Please select the maximum number of records you would like to push per request.</comment>
|
| 150 |
+
</flubit_chunk>
|
| 151 |
+
<price_based_on translate="label">
|
| 152 |
+
<label>FBP based On:*</label>
|
| 153 |
+
<frontend_type>select</frontend_type>
|
| 154 |
+
<source_model>flubit/flubit_price</source_model>
|
| 155 |
+
<sort_order>10</sort_order>
|
| 156 |
+
<show_in_default>1</show_in_default>
|
| 157 |
+
<show_in_website>1</show_in_website>
|
| 158 |
+
<show_in_store>1</show_in_store>
|
| 159 |
+
<validate>required-entry</validate>
|
| 160 |
+
<comment></comment>
|
| 161 |
+
</price_based_on>
|
| 162 |
+
<global_price translate="label">
|
| 163 |
+
<label>Percentage Calculation:(%)*</label>
|
| 164 |
+
<frontend_type>text</frontend_type>
|
| 165 |
+
<sort_order>11</sort_order>
|
| 166 |
+
<show_in_default>1</show_in_default>
|
| 167 |
+
<show_in_website>1</show_in_website>
|
| 168 |
+
<show_in_store>1</show_in_store>
|
| 169 |
+
<validate>required-entry validate-greater-than-zero</validate>
|
| 170 |
+
<comment>The above two fields allow you to apply a global percentage discount or surcharge based on either store price or cost price. </comment>
|
| 171 |
+
</global_price>
|
| 172 |
+
</fields>
|
| 173 |
+
</flubit_setup>
|
| 174 |
+
</groups>
|
| 175 |
+
</flubit_section>
|
| 176 |
+
</sections>
|
| 177 |
+
</config>
|
app/code/community/Flubit/Flubitlog/controllers/Adminhtml/FlubitlogController.php
CHANGED
|
@@ -1,261 +1,261 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
/**
|
| 4 |
-
* Class Flubitlog Flubitlog Controller
|
| 5 |
-
*
|
| 6 |
-
* @package Flubit
|
| 7 |
-
* @category Flubitlog_FlubitlogController
|
| 8 |
-
* @author Flubit team
|
| 9 |
-
*/
|
| 10 |
-
class Flubit_Flubitlog_Adminhtml_FlubitlogController extends
|
| 11 |
-
|
| 12 |
-
/* @Method : initAction Autoloader
|
| 13 |
-
* @Parameter : None
|
| 14 |
-
* @return : None
|
| 15 |
-
*/
|
| 16 |
-
|
| 17 |
-
protected function _initAction() {
|
| 18 |
-
$this->loadLayout()
|
| 19 |
-
->_setActiveMenu('flubitlog/items')
|
| 20 |
-
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 21 |
-
|
| 22 |
-
return $this;
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
/* @Method : indexAction
|
| 26 |
-
* @Parameter : None
|
| 27 |
-
* @return : None
|
| 28 |
-
*/
|
| 29 |
-
|
| 30 |
-
public function indexAction() {
|
| 31 |
-
$this->_initAction()
|
| 32 |
-
->renderLayout();
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
/* @Method : Method for particular logging details by auto Id
|
| 36 |
-
* @Parameter : string Id
|
| 37 |
-
* @return : ArrayString
|
| 38 |
-
*/
|
| 39 |
-
|
| 40 |
-
public function detailAction() {
|
| 41 |
-
$id = $this->getRequest()->getParam('id');
|
| 42 |
-
|
| 43 |
-
$model = Mage::getModel('flubitlog/flubitlog')->load($id);
|
| 44 |
-
if ($model->getId() || $id == 0) {
|
| 45 |
-
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
| 46 |
-
if (!empty($data)) {
|
| 47 |
-
$model->setData($data);
|
| 48 |
-
}
|
| 49 |
-
Mage::register('flubitlog_data', $model);
|
| 50 |
-
$this->loadLayout();
|
| 51 |
-
//$this->_setActiveMenu('flubitlog/logs');
|
| 52 |
-
|
| 53 |
-
//$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 54 |
-
//$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
| 55 |
-
|
| 56 |
-
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
| 57 |
-
|
| 58 |
-
$this->_addContent($this->getLayout()->createBlock('flubitlog/adminhtml_flubitlog_detail'));
|
| 59 |
-
|
| 60 |
-
/*$this->_addContent($this->getLayout()->createBlock('flubitlog/adminhtml_flubitlog_edit'))
|
| 61 |
-
->_addLeft($this->getLayout()->createBlock('flubitlog/adminhtml_flubitlog_edit_tabs'));*/
|
| 62 |
-
|
| 63 |
-
$this->renderLayout();
|
| 64 |
-
} else {
|
| 65 |
-
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('flubitlog')->__('Logs does not exist'));
|
| 66 |
-
$this->_redirect('*/*/');
|
| 67 |
-
}
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
public function newAction() {
|
| 71 |
-
$this->_forward('edit');
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
/* @Method : Method for particular logging for Save
|
| 75 |
-
* @Parameter : string Id
|
| 76 |
-
* @return : ArrayString
|
| 77 |
-
*/
|
| 78 |
-
public function saveAction() {
|
| 79 |
-
if ($data = $this->getRequest()->getPost()) {
|
| 80 |
-
|
| 81 |
-
if (isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
| 82 |
-
try {
|
| 83 |
-
/* Starting upload */
|
| 84 |
-
$uploader = new Varien_File_Uploader('filename');
|
| 85 |
-
|
| 86 |
-
//Any extention would work
|
| 87 |
-
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
|
| 88 |
-
$uploader->setAllowRenameFiles(false);
|
| 89 |
-
|
| 90 |
-
$uploader->setFilesDispersion(false);
|
| 91 |
-
|
| 92 |
-
// We set media as the upload dir
|
| 93 |
-
$path = Mage::getBaseDir('media') . DS;
|
| 94 |
-
$uploader->save($path, $_FILES['filename']['name']);
|
| 95 |
-
} catch (Exception $e) {
|
| 96 |
-
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
//this way the name is saved in DB
|
| 100 |
-
$data['filename'] = $_FILES['filename']['name'];
|
| 101 |
-
}
|
| 102 |
-
|
| 103 |
-
$model = Mage::getModel('flubitlog/flubitlog');
|
| 104 |
-
$model->setData($data)
|
| 105 |
-
->setId($this->getRequest()->getParam('id'));
|
| 106 |
-
|
| 107 |
-
try {
|
| 108 |
-
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
| 109 |
-
$model->setCreatedTime(now())
|
| 110 |
-
->setUpdateTime(now());
|
| 111 |
-
} else {
|
| 112 |
-
$model->setUpdateTime(now());
|
| 113 |
-
}
|
| 114 |
-
|
| 115 |
-
$model->save();
|
| 116 |
-
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('flubitlog')->__('Item was successfully saved'));
|
| 117 |
-
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
| 118 |
-
|
| 119 |
-
if ($this->getRequest()->getParam('back')) {
|
| 120 |
-
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
| 121 |
-
return;
|
| 122 |
-
}
|
| 123 |
-
$this->_redirect('*/*/');
|
| 124 |
-
return;
|
| 125 |
-
} catch (Exception $e) {
|
| 126 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 127 |
-
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
| 128 |
-
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
| 129 |
-
return;
|
| 130 |
-
}
|
| 131 |
-
}
|
| 132 |
-
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('flubitlog')->__('Unable to find item to save'));
|
| 133 |
-
$this->_redirect('*/*/');
|
| 134 |
-
}
|
| 135 |
-
|
| 136 |
-
/* @Method : Method for delete logging by auto id
|
| 137 |
-
* @Parameter : string Id
|
| 138 |
-
* @return : ArrayString
|
| 139 |
-
*/
|
| 140 |
-
|
| 141 |
-
public function deleteAction() {
|
| 142 |
-
if ($this->getRequest()->getParam('id') > 0) {
|
| 143 |
-
try {
|
| 144 |
-
$model = Mage::getModel('flubitlog/flubitlog');
|
| 145 |
-
|
| 146 |
-
$model->setId($this->getRequest()->getParam('id'))
|
| 147 |
-
->delete();
|
| 148 |
-
|
| 149 |
-
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
| 150 |
-
$this->_redirect('*/*/');
|
| 151 |
-
} catch (Exception $e) {
|
| 152 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 153 |
-
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
| 154 |
-
}
|
| 155 |
-
}
|
| 156 |
-
$this->_redirect('*/*/');
|
| 157 |
-
}
|
| 158 |
-
|
| 159 |
-
/**
|
| 160 |
-
* Method for Delete Multiple Error logging
|
| 161 |
-
*
|
| 162 |
-
* @param string
|
| 163 |
-
* @return string
|
| 164 |
-
*/
|
| 165 |
-
|
| 166 |
-
public function massDeleteAction() {
|
| 167 |
-
$flubitlogIds = $this->getRequest()->getParam('flubitlog');
|
| 168 |
-
if (!is_array($flubitlogIds)) {
|
| 169 |
-
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
| 170 |
-
} else {
|
| 171 |
-
try {
|
| 172 |
-
foreach ($flubitlogIds as $flubitlogId) {
|
| 173 |
-
$flubitlog = Mage::getModel('flubitlog/flubitlog')->load($flubitlogId);
|
| 174 |
-
$flubitlog->delete();
|
| 175 |
-
}
|
| 176 |
-
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 177 |
-
Mage::helper('adminhtml')->__(
|
| 178 |
-
'Total of %d record(s) were successfully deleted', count($flubitlogIds)
|
| 179 |
-
)
|
| 180 |
-
);
|
| 181 |
-
} catch (Exception $e) {
|
| 182 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 183 |
-
}
|
| 184 |
-
}
|
| 185 |
-
$this->_redirect('*/*/index');
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
/**
|
| 189 |
-
* Method for Status Update Multiple Error logging
|
| 190 |
-
*
|
| 191 |
-
* @param string
|
| 192 |
-
* @return string
|
| 193 |
-
*/
|
| 194 |
-
|
| 195 |
-
public function massStatusAction() {
|
| 196 |
-
$flubitlogIds = $this->getRequest()->getParam('flubitlog');
|
| 197 |
-
if (!is_array($flubitlogIds)) {
|
| 198 |
-
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
| 199 |
-
} else {
|
| 200 |
-
try {
|
| 201 |
-
foreach ($flubitlogIds as $flubitlogId) {
|
| 202 |
-
$flubitlog = Mage::getSingleton('flubitlog/flubitlog')
|
| 203 |
-
->load($flubitlogId)
|
| 204 |
-
->setStatus($this->getRequest()->getParam('status'))
|
| 205 |
-
->setIsMassupdate(true)
|
| 206 |
-
->save();
|
| 207 |
-
}
|
| 208 |
-
$this->_getSession()->addSuccess(
|
| 209 |
-
$this->__('Total of %d record(s) were successfully updated', count($flubitlogIds))
|
| 210 |
-
);
|
| 211 |
-
} catch (Exception $e) {
|
| 212 |
-
$this->_getSession()->addError($e->getMessage());
|
| 213 |
-
}
|
| 214 |
-
}
|
| 215 |
-
$this->_redirect('*/*/index');
|
| 216 |
-
}
|
| 217 |
-
|
| 218 |
-
/**
|
| 219 |
-
* Method for Export CSV files
|
| 220 |
-
*
|
| 221 |
-
* @param None
|
| 222 |
-
* @return xls
|
| 223 |
-
*/
|
| 224 |
-
public function exportCsvAction() {
|
| 225 |
-
$fileName = 'flubitlog.csv';
|
| 226 |
-
$content = $this->getLayout()->createBlock('flubitlog/adminhtml_flubitlog_grid')
|
| 227 |
-
->getCsv();
|
| 228 |
-
|
| 229 |
-
$this->_sendUploadResponse($fileName, $content);
|
| 230 |
-
}
|
| 231 |
-
|
| 232 |
-
/**
|
| 233 |
-
* Method for Export Xml files
|
| 234 |
-
*
|
| 235 |
-
* @param None
|
| 236 |
-
* @return stringxml
|
| 237 |
-
*/
|
| 238 |
-
public function exportXmlAction() {
|
| 239 |
-
$fileName = 'flubitlog.xml';
|
| 240 |
-
$content = $this->getLayout()->createBlock('flubitlog/adminhtml_flubitlog_grid')
|
| 241 |
-
->getXml();
|
| 242 |
-
|
| 243 |
-
$this->_sendUploadResponse($fileName, $content);
|
| 244 |
-
}
|
| 245 |
-
|
| 246 |
-
protected function _sendUploadResponse($fileName, $content, $contentType = 'application/octet-stream') {
|
| 247 |
-
$response = $this->getResponse();
|
| 248 |
-
$response->setHeader('HTTP/1.1 200 OK', '');
|
| 249 |
-
$response->setHeader('Pragma', 'public', true);
|
| 250 |
-
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
| 251 |
-
$response->setHeader('Content-Disposition', 'attachment; filename=' . $fileName);
|
| 252 |
-
$response->setHeader('Last-Modified', date('r'));
|
| 253 |
-
$response->setHeader('Accept-Ranges', 'bytes');
|
| 254 |
-
$response->setHeader('Content-Length', strlen($content));
|
| 255 |
-
$response->setHeader('Content-type', $contentType);
|
| 256 |
-
$response->setBody($content);
|
| 257 |
-
$response->sendResponse();
|
| 258 |
-
die;
|
| 259 |
-
}
|
| 260 |
-
|
| 261 |
}
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Class Flubitlog Flubitlog Controller
|
| 5 |
+
*
|
| 6 |
+
* @package Flubit
|
| 7 |
+
* @category Flubitlog_FlubitlogController
|
| 8 |
+
* @author Flubit team
|
| 9 |
+
*/
|
| 10 |
+
class Flubit_Flubitlog_Adminhtml_FlubitlogController extends Mage_Adminhtml_Controller_Action {
|
| 11 |
+
|
| 12 |
+
/* @Method : initAction Autoloader
|
| 13 |
+
* @Parameter : None
|
| 14 |
+
* @return : None
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
protected function _initAction() {
|
| 18 |
+
$this->loadLayout()
|
| 19 |
+
->_setActiveMenu('flubitlog/items')
|
| 20 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 21 |
+
|
| 22 |
+
return $this;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/* @Method : indexAction
|
| 26 |
+
* @Parameter : None
|
| 27 |
+
* @return : None
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
public function indexAction() {
|
| 31 |
+
$this->_initAction()
|
| 32 |
+
->renderLayout();
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/* @Method : Method for particular logging details by auto Id
|
| 36 |
+
* @Parameter : string Id
|
| 37 |
+
* @return : ArrayString
|
| 38 |
+
*/
|
| 39 |
+
|
| 40 |
+
public function detailAction() {
|
| 41 |
+
$id = $this->getRequest()->getParam('id');
|
| 42 |
+
|
| 43 |
+
$model = Mage::getModel('flubitlog/flubitlog')->load($id);
|
| 44 |
+
if ($model->getId() || $id == 0) {
|
| 45 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
| 46 |
+
if (!empty($data)) {
|
| 47 |
+
$model->setData($data);
|
| 48 |
+
}
|
| 49 |
+
Mage::register('flubitlog_data', $model);
|
| 50 |
+
$this->loadLayout();
|
| 51 |
+
//$this->_setActiveMenu('flubitlog/logs');
|
| 52 |
+
|
| 53 |
+
//$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 54 |
+
//$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
| 55 |
+
|
| 56 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
| 57 |
+
|
| 58 |
+
$this->_addContent($this->getLayout()->createBlock('flubitlog/adminhtml_flubitlog_detail'));
|
| 59 |
+
|
| 60 |
+
/*$this->_addContent($this->getLayout()->createBlock('flubitlog/adminhtml_flubitlog_edit'))
|
| 61 |
+
->_addLeft($this->getLayout()->createBlock('flubitlog/adminhtml_flubitlog_edit_tabs'));*/
|
| 62 |
+
|
| 63 |
+
$this->renderLayout();
|
| 64 |
+
} else {
|
| 65 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('flubitlog')->__('Logs does not exist'));
|
| 66 |
+
$this->_redirect('*/*/');
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
public function newAction() {
|
| 71 |
+
$this->_forward('edit');
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/* @Method : Method for particular logging for Save
|
| 75 |
+
* @Parameter : string Id
|
| 76 |
+
* @return : ArrayString
|
| 77 |
+
*/
|
| 78 |
+
public function saveAction() {
|
| 79 |
+
if ($data = $this->getRequest()->getPost()) {
|
| 80 |
+
|
| 81 |
+
if (isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
| 82 |
+
try {
|
| 83 |
+
/* Starting upload */
|
| 84 |
+
$uploader = new Varien_File_Uploader('filename');
|
| 85 |
+
|
| 86 |
+
//Any extention would work
|
| 87 |
+
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
|
| 88 |
+
$uploader->setAllowRenameFiles(false);
|
| 89 |
+
|
| 90 |
+
$uploader->setFilesDispersion(false);
|
| 91 |
+
|
| 92 |
+
// We set media as the upload dir
|
| 93 |
+
$path = Mage::getBaseDir('media') . DS;
|
| 94 |
+
$uploader->save($path, $_FILES['filename']['name']);
|
| 95 |
+
} catch (Exception $e) {
|
| 96 |
+
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
//this way the name is saved in DB
|
| 100 |
+
$data['filename'] = $_FILES['filename']['name'];
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
$model = Mage::getModel('flubitlog/flubitlog');
|
| 104 |
+
$model->setData($data)
|
| 105 |
+
->setId($this->getRequest()->getParam('id'));
|
| 106 |
+
|
| 107 |
+
try {
|
| 108 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
| 109 |
+
$model->setCreatedTime(now())
|
| 110 |
+
->setUpdateTime(now());
|
| 111 |
+
} else {
|
| 112 |
+
$model->setUpdateTime(now());
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
$model->save();
|
| 116 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('flubitlog')->__('Item was successfully saved'));
|
| 117 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
| 118 |
+
|
| 119 |
+
if ($this->getRequest()->getParam('back')) {
|
| 120 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
| 121 |
+
return;
|
| 122 |
+
}
|
| 123 |
+
$this->_redirect('*/*/');
|
| 124 |
+
return;
|
| 125 |
+
} catch (Exception $e) {
|
| 126 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 127 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
| 128 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
| 129 |
+
return;
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('flubitlog')->__('Unable to find item to save'));
|
| 133 |
+
$this->_redirect('*/*/');
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/* @Method : Method for delete logging by auto id
|
| 137 |
+
* @Parameter : string Id
|
| 138 |
+
* @return : ArrayString
|
| 139 |
+
*/
|
| 140 |
+
|
| 141 |
+
public function deleteAction() {
|
| 142 |
+
if ($this->getRequest()->getParam('id') > 0) {
|
| 143 |
+
try {
|
| 144 |
+
$model = Mage::getModel('flubitlog/flubitlog');
|
| 145 |
+
|
| 146 |
+
$model->setId($this->getRequest()->getParam('id'))
|
| 147 |
+
->delete();
|
| 148 |
+
|
| 149 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
| 150 |
+
$this->_redirect('*/*/');
|
| 151 |
+
} catch (Exception $e) {
|
| 152 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 153 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
$this->_redirect('*/*/');
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
* Method for Delete Multiple Error logging
|
| 161 |
+
*
|
| 162 |
+
* @param string
|
| 163 |
+
* @return string
|
| 164 |
+
*/
|
| 165 |
+
|
| 166 |
+
public function massDeleteAction() {
|
| 167 |
+
$flubitlogIds = $this->getRequest()->getParam('flubitlog');
|
| 168 |
+
if (!is_array($flubitlogIds)) {
|
| 169 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
| 170 |
+
} else {
|
| 171 |
+
try {
|
| 172 |
+
foreach ($flubitlogIds as $flubitlogId) {
|
| 173 |
+
$flubitlog = Mage::getModel('flubitlog/flubitlog')->load($flubitlogId);
|
| 174 |
+
$flubitlog->delete();
|
| 175 |
+
}
|
| 176 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 177 |
+
Mage::helper('adminhtml')->__(
|
| 178 |
+
'Total of %d record(s) were successfully deleted', count($flubitlogIds)
|
| 179 |
+
)
|
| 180 |
+
);
|
| 181 |
+
} catch (Exception $e) {
|
| 182 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
$this->_redirect('*/*/index');
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Method for Status Update Multiple Error logging
|
| 190 |
+
*
|
| 191 |
+
* @param string
|
| 192 |
+
* @return string
|
| 193 |
+
*/
|
| 194 |
+
|
| 195 |
+
public function massStatusAction() {
|
| 196 |
+
$flubitlogIds = $this->getRequest()->getParam('flubitlog');
|
| 197 |
+
if (!is_array($flubitlogIds)) {
|
| 198 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
| 199 |
+
} else {
|
| 200 |
+
try {
|
| 201 |
+
foreach ($flubitlogIds as $flubitlogId) {
|
| 202 |
+
$flubitlog = Mage::getSingleton('flubitlog/flubitlog')
|
| 203 |
+
->load($flubitlogId)
|
| 204 |
+
->setStatus($this->getRequest()->getParam('status'))
|
| 205 |
+
->setIsMassupdate(true)
|
| 206 |
+
->save();
|
| 207 |
+
}
|
| 208 |
+
$this->_getSession()->addSuccess(
|
| 209 |
+
$this->__('Total of %d record(s) were successfully updated', count($flubitlogIds))
|
| 210 |
+
);
|
| 211 |
+
} catch (Exception $e) {
|
| 212 |
+
$this->_getSession()->addError($e->getMessage());
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
$this->_redirect('*/*/index');
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
* Method for Export CSV files
|
| 220 |
+
*
|
| 221 |
+
* @param None
|
| 222 |
+
* @return xls
|
| 223 |
+
*/
|
| 224 |
+
public function exportCsvAction() {
|
| 225 |
+
$fileName = 'flubitlog.csv';
|
| 226 |
+
$content = $this->getLayout()->createBlock('flubitlog/adminhtml_flubitlog_grid')
|
| 227 |
+
->getCsv();
|
| 228 |
+
|
| 229 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
/**
|
| 233 |
+
* Method for Export Xml files
|
| 234 |
+
*
|
| 235 |
+
* @param None
|
| 236 |
+
* @return stringxml
|
| 237 |
+
*/
|
| 238 |
+
public function exportXmlAction() {
|
| 239 |
+
$fileName = 'flubitlog.xml';
|
| 240 |
+
$content = $this->getLayout()->createBlock('flubitlog/adminhtml_flubitlog_grid')
|
| 241 |
+
->getXml();
|
| 242 |
+
|
| 243 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
protected function _sendUploadResponse($fileName, $content, $contentType = 'application/octet-stream') {
|
| 247 |
+
$response = $this->getResponse();
|
| 248 |
+
$response->setHeader('HTTP/1.1 200 OK', '');
|
| 249 |
+
$response->setHeader('Pragma', 'public', true);
|
| 250 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
| 251 |
+
$response->setHeader('Content-Disposition', 'attachment; filename=' . $fileName);
|
| 252 |
+
$response->setHeader('Last-Modified', date('r'));
|
| 253 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
| 254 |
+
$response->setHeader('Content-Length', strlen($content));
|
| 255 |
+
$response->setHeader('Content-type', $contentType);
|
| 256 |
+
$response->setBody($content);
|
| 257 |
+
$response->sendResponse();
|
| 258 |
+
die;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
}
|
package.xml
CHANGED
|
@@ -1,29 +1,23 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>sellonflubit</name>
|
| 4 |
-
<version>0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>GPL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
-
<summary>Sell on Flubit extension enables merchants to integrate with WeFlubit API to sell on all Flubit Channels
|
| 10 |
-
<description>The Sell On Flubit extension enables Merchants to integrate into Flubit via our Merchant Web Services API. It allows Merchants to send their inventory and inventory updates. Merchants can assign a global pricing rule to the full/selected Inventory or at a individual SKU level. Orders from Flubit Channels are automatically retrieved from Flubit into Merchant's Magento Sysem. And upon fulfilment and shipment order update status are sent to Flubit.
|
| 11 |
-
|
| 12 |
All controlled by configurable cron jobs or Scheduled Tasks</description>
|
| 13 |
-
<notes
|
| 14 |
-

|
| 15 |
-
Functionalities include:
|
| 16 |

|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
</notes>
|
| 23 |
-
<authors><author><name>Krishna Pallerla</name><user>krishna</user><email>merchantintegrations@flubit.com</email></author></authors>
|
| 24 |
-
<date>2014-09-03</date>
|
| 25 |
-
<time>15:51:40</time>
|
| 26 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Flubit_Flubit.xml" hash="ae41c32db70deae6cea6abefe8687367"/><file name="Flubit_Flubitlog.xml" hash="3c8cca9de2f076f8b548f235f1990de4"/></dir></target><target name="magecommunity"><dir name="Flubit"><dir name="Flubit"><dir name="Block"><dir name="Adminhtml"><file name="Button.php" hash="bd7d1accdb7fa7ac13140e9aad9b3680"/><dir name="Flubit"><file name="Grid.php" hash="49f6ee3abb7bcb8148c00e1331fbd6b6"/></dir><file name="Flubit.php" hash="017c95467ebebfbfc822b17a0e42605d"/><file name="Notification.php" hash="31490332a882d520ab1b2591c9ab56fe"/><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Inline.php" hash="2d457e533017850c5e34525e0d7347f1"/><file name="InlineCheckbox.php" hash="d97ed42053610984136d3c60b8cb129b"/><file name="InlineUpdateButton.php" hash="605fbc308d01b740c06ca94e23dc253a"/></dir></dir></dir></dir></dir><file name="Flubit.php" hash="a4a158f0960150042a4016b93ae33b48"/><dir name="Sales"><dir name="Order"><dir name="View"><file name="Info.php" hash="2b6bb256043efee3d829516f45a0f250"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0839bf8334c3e3014765dd0b48293515"/><dir name="Payment"><file name="Data.php" hash="de7d2aac650b1c120a0eff5727fd5104"/></dir></dir><dir name="Model"><dir name="Carrier"><file name="Flatrate.php" hash="5ba2d161ee8f34786ac23e2de1e61d98"/></dir><file name="Config.php" hash="b65d2ff6b782408c712b7a85e9c6c898"/><file name="Cron.php" hash="9d0ad0b7f226d03b526ed17ffde89f12"/><dir name="Flubit"><file name="Chunk.php" hash="95c3c3a5e8ac39413ad7fae8ccba39a3"/><file name="Logdate.php" hash="c5e6c7c1fdac9784a480dbbdf04f9351"/><file name="Logs.php" hash="a5ec089428d563bc6bdf83826e465656"/><file name="Order.php" hash="d1cfc1da62bd55d82c60e10d5fa750bd"/><file name="Price.php" hash="47cc0b830ea77c26847e9ecc8e87ae55"/><file name="Rcd.php" hash="0c9e20ca8aae030eefe5c28190d979e5"/><file name="Source.php" hash="34fa9d221c1c5d205696843f7d80306b"/></dir><file name="Flubit.php" hash="c025f88adfc214660b690ed8e86beae9"/><file name="Globalproduct.php" hash="451cca7a0e9380b49ebd3a431e99c8e1"/><file name="Logs.php" hash="a9ce72f3ee296a698f2c5e99786cc95a"/><file name="Logtype.php" hash="1cdac7167543f5113ac6f0d726b6e8f0"/><dir name="Mysql4"><dir name="Flubit"><file name="Collection.php" hash="6991ef66959d26338b004160749bf65a"/></dir><file name="Flubit.php" hash="596e3fc791340d973f518a27beb86735"/><dir name="Globalproduct"><file name="Collection.php" hash="d43b62df7f721d02198372843e5687db"/></dir><file name="Globalproduct.php" hash="4859474fcc6d267b48804958f54cf727"/><dir name="Logs"><file name="Collection.php" hash="49c82d55f8b84f97452e29193c358957"/></dir><file name="Logs.php" hash="587b3880fbbd369515fe8ba0bef5f2f6"/><dir name="Order"><file name="Collection.php" hash="5af838cbcfdd5ecd0b2389e48b398a8d"/></dir><file name="Order.php" hash="c1eafd87edde44fd82c354826726e32b"/><dir name="Ordertime"><file name="Collection.php" hash="b28becabcc61210d2000585439c5ee4e"/></dir><file name="Ordertime.php" hash="45136f5e3d734de083aacb911449b652"/></dir><file name="Observer.php" hash="37c9cf883a9136ca69b1b4230e2931be"/><dir name="Order"><dir name="Pdf"><file name="Creditmemo.php" hash="5960dce8d419a37742b778aee3cd3513"/><file name="Invoice.php" hash="0871d94766e4d28229bd46287b4cceb6"/><dir name="Items"><dir name="Creditmemo"><file name="Default.php" hash="a54fef36fa0d76e8c9daf1b3fdc94ef0"/></dir><dir name="Invoice"><file name="Default.php" hash="81659dfd1c28fc6ecb5d29944992cbce"/></dir></dir></dir></dir><file name="Order.php" hash="1aee45050c45a7d4943e26f64dba7d7b"/><file name="Ordertime.php" hash="ba0f0b1a8843ebebc8b077fe0d7be05a"/><dir name="Payment"><dir name="Method"><file name="Flubitterms.php" hash="a3d76be1e9723152e8fa4f49e757b83f"/></dir></dir><dir name="Quote"><file name="Item.php" hash="9ba90dba195f34b686a57ee5ada02d8a"/></dir><file name="Shipping.php" hash="02e9d9ac200cd9faca48647396148817"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FlubitController.php" hash="c0452ccd017432d608aaf053b234d755"/></dir><file name="FlubitController.php" hash="231fe90b8cf6b2dc836ccd1b9d8d05d8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a1b24cb6ef8b0cc83a8f20d3ce8c99f3"/><file name="config.xml" hash="f4aeabfc5c20bb3831f6e9181f2599ba"/><file name="system.xml" hash="a87bbee2c78981498d665d673c43e50d"/></dir><dir name="sql"><dir name="flubit_setup"><file name="mysql4-install-0.1.0.php" hash="c105bc208e4b7ffb1c4cde1d726542c7"/><file name="upgrade-0.1.0-0.1.1.php" hash="accce3c96345b2032ce31dd2bb1e886c"/><file name="upgrade-0.1.1-0.1.2.php" hash="89118cd4bed00af6c5c0879a04ff363f"/><file name="upgrade-0.1.2-0.1.3.php" hash="ab2a3a2c0ee7e284a46c165041ba643a"/><file name="upgrade-0.1.3-0.1.4.php" hash="3386896294f9331477b1772c04f4762d"/><file name="upgrade-0.1.4-0.1.5.php" hash="f4d574013dd817291166999ea6ba409b"/><file name="upgrade-0.1.5-0.1.6.php" hash="4da9c45e8322cc16b2f66b99476d697b"/><file name="upgrade-0.1.6-0.1.7.php" hash="dc25ca67f019126145b1de1752a514f6"/><file name="upgrade-0.1.7-0.1.8.php" hash="a0f803c9dd346b72895b59cc5aad1857"/><file name="upgrade-0.1.8-0.1.9.php" hash="aa3d98b81ffa33407862e7f1ed115f6d"/><file name="upgrade-0.1.9-0.2.0.php" hash="8434874ebfb9e80b328e50d0f214809b"/><file name="upgrade-0.2.0-0.2.1.php" hash="7c2101a65589a1a1235ad0337a991091"/><file name="upgrade-0.2.1-0.2.2.php" hash="390d86eb70780f35b57bf9aa53980653"/><file name="upgrade-0.2.2-0.2.3.php" hash="ed29b47b92ffc3e558d1ce0f24ec9bf9"/><file name="upgrade-0.2.3-0.2.4.php" hash="16186ad4f6cda0bec70f59351c70189a"/><file name="upgrade-0.2.4-0.2.5.php" hash="bc7a28e5dd523dbcc8c8a79e4c28332b"/><file name="upgrade-0.2.5-0.2.6.php" hash="2ec6e2e4ddc7e9db8e8b3cc149948159"/><file name="upgrade-0.2.6-0.2.7.php" hash="f4ac372521d21e039e81d82b417e5786"/><file name="upgrade-0.2.7-0.2.8.php" hash="5eae85c13c2536345dc2a4dcdb103bca"/></dir></dir></dir><dir name="Flubitlog"><dir name="Block"><dir name="Adminhtml"><dir name="Flubitlog"><file name="Detail.php" hash="8821dce99cb54736c565978d6c6319c3"/><dir name="Edit"><file name="Form.php" hash="34676e0dd3b5275ff652210c53d59b27"/><dir name="Tab"><file name="Form.php" hash="6d7bf2de46c04e408dfda67a833ec37c"/></dir><file name="Tabs.php" hash="2cc2ec2e7b53fd5c9731fc3c4feea8e4"/></dir><file name="Edit.php" hash="bee400c4c46485acbcd5d3569106cbe7"/><file name="Grid.php" hash="21d19a4110e7f09ac71b2a2bef94a213"/></dir><file name="Flubitlog.php" hash="68b44c36fadbe935d9de12ac94761edd"/></dir><file name="Flubitlog.php" hash="8ffcb27405a741567d8b5fba8652197c"/></dir><dir name="Helper"><file name="Data.php" hash="f6132f9876e8b3d74e7219ddab4e2cb1"/></dir><dir name="Model"><file name="Flubitlog.php" hash="6e974e00af84a901063ae7f2103cb1f6"/><dir name="Mysql4"><dir name="Flubitlog"><file name="Collection.php" hash="289e3e98586b34557c3aafeaadedaff9"/></dir><file name="Flubitlog.php" hash="e89466ece12379dda1df1dfee99e6fe1"/></dir><file name="Status.php" hash="3d04341124fe491394f2c360c38c3af9"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FlubitlogController.php" hash="f3d26fab3bd230b16ff97c64a71b0f56"/></dir><file name="IndexController.php" hash="642b36eecb00647165998f1278019745"/></dir><dir name="etc"><file name="config.xml" hash="8f2dbe0685292ab75edcdb0f0136a97f"/></dir><dir name="sql"><dir name="flubitlog_setup"><file name="mysql4-install-0.1.0.php" hash="e47201271062fcd6fc4782f73c4f7465"/><file name="upgrade-0.1.0-0.2.0.php" hash="a6bb6782367e42882956dbc4b6fe915f"/><file name="upgrade-0.2.0-0.2.1.php" hash="0d44dd6b9ee6b656b5fdd988acde6722"/><file name="upgrade-0.2.1-0.2.2.php" hash="f56b2c43f82d09fdc08cf5366475b3d8"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="flubit.xml" hash="e66fcc7eb223a792c2c3a544218266d0"/><file name="flubitlog.xml" hash="9855a7d3b1ddda0ecac0d40b6022cbdb"/></dir><dir name="template"><dir name="flubit"><file name="cronnotofocation.phtml" hash="eba5f295aaecd72f34715af61718184b"/><file name="inline-edit.phtml" hash="448aa714b7c04da5d70332d78fb4f753"/><dir name="sales"><dir name="order"><dir name="creditmemo"><dir name="create"><dir name="items"><dir name="renderer"><file name="defaultflubit.phtml" hash="18b84e17657ed127fb09c4a54417bcdc"/></dir></dir><file name="items.phtml" hash="30998bc19afb64ec2169e0c9a58c3002"/><dir name="totals"><file name="adjustmentsflubit.phtml" hash="b0cff67be4fd84a04dc7e2e5d4f57833"/></dir></dir><dir name="view"><dir name="items"><dir name="renderer"><file name="default.phtml" hash="fa5cb9c64a3268be1376277863e2765b"/></dir></dir><file name="items.phtml" hash="7fea332d385bb54edf8e8d57a17aee3c"/></dir></dir><file name="flubittotals.phtml" hash="7401e649acb9b07e535cc92ba4bce0df"/><dir name="invoice"><dir name="view"><dir name="items"><dir name="renderer"><file name="default.phtml" hash="f51d5ca19b441446d038bbe535182d23"/></dir></dir><file name="items.phtml" hash="d31a04e8eb6e02a638a16e9025a902e2"/></dir></dir><dir name="shipment"><dir name="create"><file name="items.phtml" hash="a1dcb296799332d397906587439058fc"/></dir></dir><dir name="view"><file name="flubititems.phtml" hash="3d99ea1fafbf5bf6eedbd7dbe751eaef"/><file name="info.phtml" hash="a5bb96c5523189049c1962e77c264864"/><dir name="items"><dir name="renderer"><file name="flubitdefault.phtml" hash="3fd223afd8b5750ae5ced8d657d95173"/></dir></dir></dir></dir></dir></dir><dir name="flubitlog"><file name="logdetails.phtml" hash="c2695224dec521bdab65997677cab2ca"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="flubit"><file name="logo.png" hash="b9476c105dbc159b72e3c31757a483c1"/><file name="pushonlogo.png" hash="eb7c1259d554bb75a6f2a64ae82a7b9f"/></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="Flubit"><dir name="Flubit"><file name="Client.php" hash="d3530c543795bdec026f8db388ef6f6a"/><file name="ClientInterface.php" hash="ce1a6d84e186962b4f3ee14ac58f7d06"/><file name="ClientX.php" hash="78b9b30afaf04c23b10a7b7f4c8cc2d3"/><file name="MWSClient.php" hash="4ef815203140354df51da360558e183a"/></dir></dir></target></contents>
|
| 27 |
<compatible/>
|
| 28 |
-
<dependencies><required><php><min>5.2.
|
| 29 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>sellonflubit</name>
|
| 4 |
+
<version>0.3.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>GPL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
+
<summary>Sell on Flubit extension enables merchants to integrate with WeFlubit API to sell on all Flubit Channels</summary>
|
| 10 |
+
<description>The Sell On Flubit extension enables Merchants to integrate into Flubit via our Merchant Web Services API. It allows Merchants to send their inventory and inventory updates. Merchants can assign a global pricing rule to the full/selected Inventory or at a individual SKU level. Orders from Flubit Channels are automatically retrieved from Flubit into Merchant's Magento Sysem. And upon fulfilment and shipment order update status are sent to Flubit. &amp;#xD;&#xD;
|
| 11 |
+
&amp;#xD;&#xD;
|
| 12 |
All controlled by configurable cron jobs or Scheduled Tasks</description>
|
| 13 |
+
<notes>This release addresses
|
|
|
|
|
|
|
| 14 |

|
| 15 |
+
Price lookup change.
|
| 16 |
+
Label change to address the same.</notes>
|
| 17 |
+
<authors><author><name>Krishna</name><user>Krishna</user><email>merchantrelations@flubit.com</email></author></authors>
|
| 18 |
+
<date>2014-10-08</date>
|
| 19 |
+
<time>11:24:34</time>
|
| 20 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Flubit_Flubit.xml" hash="ae41c32db70deae6cea6abefe8687367"/><file name="Flubit_Flubitlog.xml" hash="3c8cca9de2f076f8b548f235f1990de4"/></dir></target><target name="magecommunity"><dir name="Flubit"><dir name="Flubit"><dir name="Block"><dir name="Adminhtml"><file name="Button.php" hash="bd7d1accdb7fa7ac13140e9aad9b3680"/><dir name="Flubit"><file name="Grid.php" hash="49f6ee3abb7bcb8148c00e1331fbd6b6"/></dir><file name="Flubit.php" hash="017c95467ebebfbfc822b17a0e42605d"/><file name="Notification.php" hash="31490332a882d520ab1b2591c9ab56fe"/><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Inline.php" hash="2d457e533017850c5e34525e0d7347f1"/><file name="InlineCheckbox.php" hash="d97ed42053610984136d3c60b8cb129b"/><file name="InlineUpdateButton.php" hash="605fbc308d01b740c06ca94e23dc253a"/></dir></dir></dir></dir></dir><file name="Flubit.php" hash="a4a158f0960150042a4016b93ae33b48"/><dir name="Sales"><dir name="Order"><dir name="View"><file name="Info.php" hash="2b6bb256043efee3d829516f45a0f250"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0839bf8334c3e3014765dd0b48293515"/><dir name="Payment"><file name="Data.php" hash="de7d2aac650b1c120a0eff5727fd5104"/></dir></dir><dir name="Model"><dir name="Carrier"><file name="Flatrate.php" hash="5ba2d161ee8f34786ac23e2de1e61d98"/></dir><file name="Config.php" hash="b65d2ff6b782408c712b7a85e9c6c898"/><file name="Cron.php" hash="9d0ad0b7f226d03b526ed17ffde89f12"/><dir name="Flubit"><file name="Chunk.php" hash="95c3c3a5e8ac39413ad7fae8ccba39a3"/><file name="Logdate.php" hash="c5e6c7c1fdac9784a480dbbdf04f9351"/><file name="Logs.php" hash="a5ec089428d563bc6bdf83826e465656"/><file name="Order.php" hash="d1cfc1da62bd55d82c60e10d5fa750bd"/><file name="Price.php" hash="7022dded505fe3981bca6066285a2f79"/><file name="Rcd.php" hash="0c9e20ca8aae030eefe5c28190d979e5"/><file name="Source.php" hash="34fa9d221c1c5d205696843f7d80306b"/></dir><file name="Flubit.php" hash="c2f4d9864fb15631105ec8e9727e06b3"/><file name="Globalproduct.php" hash="451cca7a0e9380b49ebd3a431e99c8e1"/><file name="Logs.php" hash="a9ce72f3ee296a698f2c5e99786cc95a"/><file name="Logtype.php" hash="1cdac7167543f5113ac6f0d726b6e8f0"/><dir name="Mysql4"><dir name="Flubit"><file name="Collection.php" hash="6991ef66959d26338b004160749bf65a"/></dir><file name="Flubit.php" hash="596e3fc791340d973f518a27beb86735"/><dir name="Globalproduct"><file name="Collection.php" hash="d43b62df7f721d02198372843e5687db"/></dir><file name="Globalproduct.php" hash="4859474fcc6d267b48804958f54cf727"/><dir name="Logs"><file name="Collection.php" hash="49c82d55f8b84f97452e29193c358957"/></dir><file name="Logs.php" hash="587b3880fbbd369515fe8ba0bef5f2f6"/><dir name="Order"><file name="Collection.php" hash="5af838cbcfdd5ecd0b2389e48b398a8d"/></dir><file name="Order.php" hash="c1eafd87edde44fd82c354826726e32b"/><dir name="Ordertime"><file name="Collection.php" hash="b28becabcc61210d2000585439c5ee4e"/></dir><file name="Ordertime.php" hash="45136f5e3d734de083aacb911449b652"/></dir><file name="Observer.php" hash="37c9cf883a9136ca69b1b4230e2931be"/><dir name="Order"><dir name="Pdf"><file name="Creditmemo.php" hash="5960dce8d419a37742b778aee3cd3513"/><file name="Invoice.php" hash="0871d94766e4d28229bd46287b4cceb6"/><dir name="Items"><dir name="Creditmemo"><file name="Default.php" hash="a54fef36fa0d76e8c9daf1b3fdc94ef0"/></dir><dir name="Invoice"><file name="Default.php" hash="81659dfd1c28fc6ecb5d29944992cbce"/></dir></dir></dir></dir><file name="Order.php" hash="1aee45050c45a7d4943e26f64dba7d7b"/><file name="Ordertime.php" hash="ba0f0b1a8843ebebc8b077fe0d7be05a"/><dir name="Payment"><dir name="Method"><file name="Flubitterms.php" hash="a3d76be1e9723152e8fa4f49e757b83f"/></dir></dir><dir name="Quote"><file name="Item.php" hash="9ba90dba195f34b686a57ee5ada02d8a"/></dir><file name="Shipping.php" hash="02e9d9ac200cd9faca48647396148817"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FlubitController.php" hash="20ef7c9d10e8ac11106d658f54da385a"/></dir><file name="FlubitController.php" hash="231fe90b8cf6b2dc836ccd1b9d8d05d8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a1b24cb6ef8b0cc83a8f20d3ce8c99f3"/><file name="config.xml" hash="f4aeabfc5c20bb3831f6e9181f2599ba"/><file name="system.xml" hash="ae1c1662616e3a3912b2728f82d3dc78"/></dir><dir name="sql"><dir name="flubit_setup"><file name="mysql4-install-0.1.0.php" hash="c105bc208e4b7ffb1c4cde1d726542c7"/><file name="upgrade-0.1.0-0.1.1.php" hash="accce3c96345b2032ce31dd2bb1e886c"/><file name="upgrade-0.1.1-0.1.2.php" hash="89118cd4bed00af6c5c0879a04ff363f"/><file name="upgrade-0.1.2-0.1.3.php" hash="ab2a3a2c0ee7e284a46c165041ba643a"/><file name="upgrade-0.1.3-0.1.4.php" hash="3386896294f9331477b1772c04f4762d"/><file name="upgrade-0.1.4-0.1.5.php" hash="f4d574013dd817291166999ea6ba409b"/><file name="upgrade-0.1.5-0.1.6.php" hash="4da9c45e8322cc16b2f66b99476d697b"/><file name="upgrade-0.1.6-0.1.7.php" hash="dc25ca67f019126145b1de1752a514f6"/><file name="upgrade-0.1.7-0.1.8.php" hash="a0f803c9dd346b72895b59cc5aad1857"/><file name="upgrade-0.1.8-0.1.9.php" hash="aa3d98b81ffa33407862e7f1ed115f6d"/><file name="upgrade-0.1.9-0.2.0.php" hash="8434874ebfb9e80b328e50d0f214809b"/><file name="upgrade-0.2.0-0.2.1.php" hash="7c2101a65589a1a1235ad0337a991091"/><file name="upgrade-0.2.1-0.2.2.php" hash="390d86eb70780f35b57bf9aa53980653"/><file name="upgrade-0.2.2-0.2.3.php" hash="ed29b47b92ffc3e558d1ce0f24ec9bf9"/><file name="upgrade-0.2.3-0.2.4.php" hash="16186ad4f6cda0bec70f59351c70189a"/><file name="upgrade-0.2.4-0.2.5.php" hash="bc7a28e5dd523dbcc8c8a79e4c28332b"/><file name="upgrade-0.2.5-0.2.6.php" hash="2ec6e2e4ddc7e9db8e8b3cc149948159"/><file name="upgrade-0.2.6-0.2.7.php" hash="f4ac372521d21e039e81d82b417e5786"/><file name="upgrade-0.2.7-0.2.8.php" hash="5eae85c13c2536345dc2a4dcdb103bca"/></dir></dir></dir><dir name="Flubitlog"><dir name="Block"><dir name="Adminhtml"><dir name="Flubitlog"><file name="Detail.php" hash="8821dce99cb54736c565978d6c6319c3"/><dir name="Edit"><file name="Form.php" hash="34676e0dd3b5275ff652210c53d59b27"/><dir name="Tab"><file name="Form.php" hash="6d7bf2de46c04e408dfda67a833ec37c"/></dir><file name="Tabs.php" hash="2cc2ec2e7b53fd5c9731fc3c4feea8e4"/></dir><file name="Edit.php" hash="bee400c4c46485acbcd5d3569106cbe7"/><file name="Grid.php" hash="21d19a4110e7f09ac71b2a2bef94a213"/></dir><file name="Flubitlog.php" hash="68b44c36fadbe935d9de12ac94761edd"/></dir><file name="Flubitlog.php" hash="8ffcb27405a741567d8b5fba8652197c"/></dir><dir name="Helper"><file name="Data.php" hash="f6132f9876e8b3d74e7219ddab4e2cb1"/></dir><dir name="Model"><file name="Flubitlog.php" hash="6e974e00af84a901063ae7f2103cb1f6"/><dir name="Mysql4"><dir name="Flubitlog"><file name="Collection.php" hash="289e3e98586b34557c3aafeaadedaff9"/></dir><file name="Flubitlog.php" hash="e89466ece12379dda1df1dfee99e6fe1"/></dir><file name="Status.php" hash="3d04341124fe491394f2c360c38c3af9"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FlubitlogController.php" hash="a71047a03d360ae35b2dffc7291fe6dc"/></dir><file name="IndexController.php" hash="642b36eecb00647165998f1278019745"/></dir><dir name="etc"><file name="config.xml" hash="8f2dbe0685292ab75edcdb0f0136a97f"/></dir><dir name="sql"><dir name="flubitlog_setup"><file name="mysql4-install-0.1.0.php" hash="e47201271062fcd6fc4782f73c4f7465"/><file name="upgrade-0.1.0-0.2.0.php" hash="a6bb6782367e42882956dbc4b6fe915f"/><file name="upgrade-0.2.0-0.2.1.php" hash="0d44dd6b9ee6b656b5fdd988acde6722"/><file name="upgrade-0.2.1-0.2.2.php" hash="f56b2c43f82d09fdc08cf5366475b3d8"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="flubit.xml" hash="e66fcc7eb223a792c2c3a544218266d0"/><file name="flubitlog.xml" hash="9855a7d3b1ddda0ecac0d40b6022cbdb"/></dir><dir name="template"><dir name="flubit"><file name="cronnotofocation.phtml" hash="eba5f295aaecd72f34715af61718184b"/><file name="inline-edit.phtml" hash="448aa714b7c04da5d70332d78fb4f753"/><dir name="sales"><dir name="order"><dir name="creditmemo"><dir name="create"><dir name="items"><dir name="renderer"><file name="defaultflubit.phtml" hash="18b84e17657ed127fb09c4a54417bcdc"/></dir></dir><file name="items.phtml" hash="30998bc19afb64ec2169e0c9a58c3002"/><dir name="totals"><file name="adjustmentsflubit.phtml" hash="b0cff67be4fd84a04dc7e2e5d4f57833"/></dir></dir><dir name="view"><dir name="items"><dir name="renderer"><file name="default.phtml" hash="fa5cb9c64a3268be1376277863e2765b"/></dir></dir><file name="items.phtml" hash="7fea332d385bb54edf8e8d57a17aee3c"/></dir></dir><file name="flubittotals.phtml" hash="7401e649acb9b07e535cc92ba4bce0df"/><dir name="invoice"><dir name="view"><dir name="items"><dir name="renderer"><file name="default.phtml" hash="f51d5ca19b441446d038bbe535182d23"/></dir></dir><file name="items.phtml" hash="d31a04e8eb6e02a638a16e9025a902e2"/></dir></dir><dir name="shipment"><dir name="create"><file name="items.phtml" hash="a1dcb296799332d397906587439058fc"/></dir></dir><dir name="view"><file name="flubititems.phtml" hash="3d99ea1fafbf5bf6eedbd7dbe751eaef"/><file name="info.phtml" hash="a5bb96c5523189049c1962e77c264864"/><dir name="items"><dir name="renderer"><file name="flubitdefault.phtml" hash="3fd223afd8b5750ae5ced8d657d95173"/></dir></dir></dir></dir></dir></dir><dir name="flubitlog"><file name="logdetails.phtml" hash="c2695224dec521bdab65997677cab2ca"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="flubit"><file name="logo.png" hash="b9476c105dbc159b72e3c31757a483c1"/><file name="pushonlogo.png" hash="eb7c1259d554bb75a6f2a64ae82a7b9f"/></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="Flubit"><dir name="Flubit"><file name="Client.php" hash="d3530c543795bdec026f8db388ef6f6a"/><file name="ClientInterface.php" hash="ce1a6d84e186962b4f3ee14ac58f7d06"/><file name="ClientX.php" hash="78b9b30afaf04c23b10a7b7f4c8cc2d3"/><file name="MWSClient.php" hash="4ef815203140354df51da360558e183a"/></dir></dir></target></contents>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
<compatible/>
|
| 22 |
+
<dependencies><required><php><min>5.2.1</min><max>5.5.20</max></php></required></dependencies>
|
| 23 |
</package>
|
