Version Notes
Supporting v2 type of unbxd field
Download this release
Release Info
| Developer | ananthesh |
| Extension | unbxd_feedconnector |
| Version | 1.0.6 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.5 to 1.0.6
- app/code/local/Unbxd/Datafeeder/Helper/{AnalyticsHelper.php → Analyticshelper.php} +4 -4
- app/code/local/Unbxd/Datafeeder/Helper/UnbxdIndexingHelper.php +3 -3
- app/code/local/Unbxd/Datafeeder/Model/Feed/Feedcreator.php +5 -0
- app/code/local/Unbxd/Datafeeder/Model/Feed/Feedmanager.php +2 -2
- app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Jsonbuilder.php +1 -1
- app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Productbuilder.php +198 -86
- app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Schemabuilder.php +1 -1
- app/code/local/Unbxd/Datafeeder/Model/Mysql4/Field.php +35 -15
- app/code/local/Unbxd/Datafeeder/Model/Mysql4/Upgrade.php +37 -0
- app/code/local/Unbxd/Datafeeder/controllers/ConfigController.php +5 -0
- app/code/local/Unbxd/Datafeeder/controllers/FieldController.php +1 -0
- app/code/local/Unbxd/Datafeeder/sql/datafeeder_setup/mysql4-install-1.0.5.php +1 -1
- app/code/local/Unbxd/Datafeeder/sql/datafeeder_setup/mysql4-upgrade-0.1.0-1.0.5.php +1 -1
- app/design/adminhtml/base/default/template/datafeeder/conf.phtml +12 -10
- package.xml +4 -4
app/code/local/Unbxd/Datafeeder/Helper/{AnalyticsHelper.php → Analyticshelper.php}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
<?php
|
| 2 |
-
class
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Returns unbxd script tag
|
|
@@ -74,7 +74,7 @@ class Unbxd_Datafeeder_Helper_AnalyticsHelper extends Mage_Core_Helper_Abstract{
|
|
| 74 |
if (!$product instanceof Mage_Catalog_Model_Product ) {
|
| 75 |
Mage::throwException("$product parameter to getProductClickAttributes method should be of type Mage_Catalog_Model_Product");
|
| 76 |
}
|
| 77 |
-
return 'unbxdattr="AddToCart" unbxdparam_sku="'.$product->getData('
|
| 78 |
}
|
| 79 |
|
| 80 |
/**
|
|
@@ -86,7 +86,7 @@ class Unbxd_Datafeeder_Helper_AnalyticsHelper extends Mage_Core_Helper_Abstract{
|
|
| 86 |
if (!$product instanceof Mage_Catalog_Model_Product ) {
|
| 87 |
Mage::throwException("$product parameter to getProductClickAttributes method should be of type Mage_Catalog_Model_Product");
|
| 88 |
}
|
| 89 |
-
return 'unbxdattr="order" unbxdparam_sku="'.$product->getData('
|
| 90 |
}
|
| 91 |
|
| 92 |
/**
|
|
@@ -102,4 +102,4 @@ class Unbxd_Datafeeder_Helper_AnalyticsHelper extends Mage_Core_Helper_Abstract{
|
|
| 102 |
return false;
|
| 103 |
}
|
| 104 |
}
|
| 105 |
-
?>
|
| 1 |
<?php
|
| 2 |
+
class Unbxd_Datafeeder_Helper_Analyticshelper extends Mage_Core_Helper_Abstract{
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Returns unbxd script tag
|
| 74 |
if (!$product instanceof Mage_Catalog_Model_Product ) {
|
| 75 |
Mage::throwException("$product parameter to getProductClickAttributes method should be of type Mage_Catalog_Model_Product");
|
| 76 |
}
|
| 77 |
+
return 'unbxdattr="AddToCart" unbxdparam_sku="'.$product->getData('entity_id').'"';
|
| 78 |
}
|
| 79 |
|
| 80 |
/**
|
| 86 |
if (!$product instanceof Mage_Catalog_Model_Product ) {
|
| 87 |
Mage::throwException("$product parameter to getProductClickAttributes method should be of type Mage_Catalog_Model_Product");
|
| 88 |
}
|
| 89 |
+
return 'unbxdattr="order" unbxdparam_sku="'.$product->getData('entity_id').'"';
|
| 90 |
}
|
| 91 |
|
| 92 |
/**
|
| 102 |
return false;
|
| 103 |
}
|
| 104 |
}
|
| 105 |
+
?>
|
app/code/local/Unbxd/Datafeeder/Helper/UnbxdIndexingHelper.php
CHANGED
|
@@ -27,7 +27,7 @@
|
|
| 27 |
$this->logFile = Mage::getBaseDir('log').DS.'generic.log';
|
| 28 |
$this->file = Mage::getBaseDir('tmp').DS.'unbxdFeed.xml';
|
| 29 |
$this-log("calling setfeilds method");
|
| 30 |
-
$this->fields =
|
| 31 |
$this-> setFieldType();
|
| 32 |
}
|
| 33 |
|
|
@@ -291,7 +291,7 @@
|
|
| 291 |
* where it fetches from the local variable, which holds the information of field to fieldType mapping
|
| 292 |
*/
|
| 293 |
public function isMultiSelect($attributeName = ""){
|
| 294 |
-
if($this->getFieldType($attributeName) == "select" || $this->getFieldType($attributeName) == "multiselect" ){
|
| 295 |
return true;
|
| 296 |
}
|
| 297 |
return false;
|
|
@@ -310,7 +310,7 @@
|
|
| 310 |
* This checks it present in the global array 'categoryMap', if it is not there fetches from db
|
| 311 |
* So that once it gets one category, it doesn't make db call again for the same category
|
| 312 |
*/
|
| 313 |
-
|
| 314 |
if(!isset($this->categoryMap[$category_id])){
|
| 315 |
$category = Mage::getModel('catalog/category')->load($category_id);
|
| 316 |
$this->categoryMap[$category_id] = $category;
|
| 27 |
$this->logFile = Mage::getBaseDir('log').DS.'generic.log';
|
| 28 |
$this->file = Mage::getBaseDir('tmp').DS.'unbxdFeed.xml';
|
| 29 |
$this-log("calling setfeilds method");
|
| 30 |
+
$this->fields = array();
|
| 31 |
$this-> setFieldType();
|
| 32 |
}
|
| 33 |
|
| 291 |
* where it fetches from the local variable, which holds the information of field to fieldType mapping
|
| 292 |
*/
|
| 293 |
public function isMultiSelect($attributeName = ""){
|
| 294 |
+
if($this->getFieldType($attributeName) == "select" || $this->getFieldType($attributeName) == "multiselect" || $attributeName == "categoryIds"){
|
| 295 |
return true;
|
| 296 |
}
|
| 297 |
return false;
|
| 310 |
* This checks it present in the global array 'categoryMap', if it is not there fetches from db
|
| 311 |
* So that once it gets one category, it doesn't make db call again for the same category
|
| 312 |
*/
|
| 313 |
+
public function getCategory($category_id = ""){
|
| 314 |
if(!isset($this->categoryMap[$category_id])){
|
| 315 |
$category = Mage::getModel('catalog/category')->load($category_id);
|
| 316 |
$this->categoryMap[$category_id] = $category;
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Feedcreator.php
CHANGED
|
@@ -93,6 +93,7 @@ class Unbxd_Datafeeder_Model_Feed_Feedcreator {
|
|
| 93 |
$collection=$this->getCatalogCollection($fromdate,$todate,$site,$operation,$ids);
|
| 94 |
// get total size
|
| 95 |
//set the time limit to infinite
|
|
|
|
| 96 |
set_time_limit(0);
|
| 97 |
$pageNum = 0;
|
| 98 |
$this->log('started writing products');
|
|
@@ -152,6 +153,10 @@ class Unbxd_Datafeeder_Model_Feed_Feedcreator {
|
|
| 152 |
$this->fields["entity_id"] = array(self::STATUS => 1,
|
| 153 |
self::DATA_TYPE => "text",
|
| 154 |
self::AUTOSUGGEST => 0 );
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
$this->fields = array_merge($this->fields, Mage::getResourceSingleton("datafeeder/field")->getFeaturedFields());
|
| 156 |
}
|
| 157 |
|
| 93 |
$collection=$this->getCatalogCollection($fromdate,$todate,$site,$operation,$ids);
|
| 94 |
// get total size
|
| 95 |
//set the time limit to infinite
|
| 96 |
+
ignore_user_abort(true);
|
| 97 |
set_time_limit(0);
|
| 98 |
$pageNum = 0;
|
| 99 |
$this->log('started writing products');
|
| 153 |
$this->fields["entity_id"] = array(self::STATUS => 1,
|
| 154 |
self::DATA_TYPE => "text",
|
| 155 |
self::AUTOSUGGEST => 0 );
|
| 156 |
+
$this->fields["categoryIds"] = array(self::STATUS => 1,
|
| 157 |
+
self::DATA_TYPE => "text",
|
| 158 |
+
self::AUTOSUGGEST => 0 );
|
| 159 |
+
|
| 160 |
$this->fields = array_merge($this->fields, Mage::getResourceSingleton("datafeeder/field")->getFeaturedFields());
|
| 161 |
}
|
| 162 |
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Feedmanager.php
CHANGED
|
@@ -10,7 +10,7 @@ class Unbxd_Datafeeder_Model_Feed_Feedmanager {
|
|
| 10 |
$fields=array('file'=>'@'.$this->fileName.';filename=unbxdFeedRenamed.json');
|
| 11 |
$header = array('Content-Type: multipart/form-data');
|
| 12 |
|
| 13 |
-
$url="http://feed.unbxdapi.com/upload/v2/".$this->key."/".$this->siteName;
|
| 14 |
|
| 15 |
$ch = curl_init();
|
| 16 |
curl_setopt($ch, CURLOPT_URL,$url);
|
|
@@ -18,7 +18,7 @@ class Unbxd_Datafeeder_Model_Feed_Feedmanager {
|
|
| 18 |
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields);
|
| 19 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
| 20 |
try{
|
| 21 |
-
$this->log('pushing the feed');
|
| 22 |
// push the feed to the server
|
| 23 |
$response = $this->exec($ch);
|
| 24 |
}catch(Exception $Ex){
|
| 10 |
$fields=array('file'=>'@'.$this->fileName.';filename=unbxdFeedRenamed.json');
|
| 11 |
$header = array('Content-Type: multipart/form-data');
|
| 12 |
|
| 13 |
+
$url="http://feed.unbxdapi.com/upload/v2/".$this->key."/".$this->siteName."?fullimport=true";
|
| 14 |
|
| 15 |
$ch = curl_init();
|
| 16 |
curl_setopt($ch, CURLOPT_URL,$url);
|
| 18 |
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields);
|
| 19 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
| 20 |
try{
|
| 21 |
+
$this->log('pushing the feed to '.$url);
|
| 22 |
// push the feed to the server
|
| 23 |
$response = $this->exec($ch);
|
| 24 |
}catch(Exception $Ex){
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Jsonbuilder.php
CHANGED
|
@@ -6,4 +6,4 @@ class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Jsonbuilder {
|
|
| 6 |
|
| 7 |
}
|
| 8 |
|
| 9 |
-
?>
|
| 6 |
|
| 7 |
}
|
| 8 |
|
| 9 |
+
?>
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Productbuilder.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Productbuilder extends Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Jsonbuilder {
|
| 4 |
|
| 5 |
-
const DATA_TYPE = "
|
| 6 |
const MULTIVALUED = "multiValued";
|
| 7 |
const NUMBER = "number";
|
| 8 |
const DECIMAL = "decimal";
|
|
@@ -11,6 +11,9 @@ class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Productbuilder extends Unbxd_Dataf
|
|
| 11 |
const IMAGE_WIDTH = "image_width";
|
| 12 |
const GENERATE_IMAGE = "generate_image";
|
| 13 |
|
|
|
|
|
|
|
|
|
|
| 14 |
public function getProducts($collection, $fields) {
|
| 15 |
$content='';
|
| 16 |
$firstLoop = true;
|
|
@@ -29,24 +32,18 @@ class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Productbuilder extends Unbxd_Dataf
|
|
| 29 |
return rtrim($content, ",");
|
| 30 |
}
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
public function getProduct($product, $fields, $childProduct = false) {
|
| 33 |
|
| 34 |
$productArray =array();
|
| 35 |
|
| 36 |
foreach($product->getData('') as $columnHeader=>$columndata){
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
if ($columnHeader == "gender") {
|
| 41 |
-
$unbxdFieldName = "_gender";
|
| 42 |
-
}
|
| 43 |
-
} else {
|
| 44 |
-
$unbxdFieldName = $columnHeader;
|
| 45 |
-
if ($columnHeader == "gender") {
|
| 46 |
-
$unbxdFieldName = "_gender";
|
| 47 |
-
}
|
| 48 |
-
}
|
| 49 |
-
if(!array_key_exists($unbxdFieldName, $fields)) {
|
| 50 |
continue;
|
| 51 |
}
|
| 52 |
|
|
@@ -56,75 +53,152 @@ class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Productbuilder extends Unbxd_Dataf
|
|
| 56 |
|
| 57 |
if($columnHeader=="url_path"){
|
| 58 |
// handling the url
|
| 59 |
-
$productArray[
|
| 60 |
} else if (Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->isImage($columnHeader)) {
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
} catch (Exception $e) {
|
| 66 |
-
|
| 67 |
-
error_log("Error while fetching the image" . $e->getTraceAsString());
|
| 68 |
-
}
|
| 69 |
-
} else {
|
| 70 |
-
$productArray[$unbxdFieldName] = $columndata;
|
| 71 |
}
|
|
|
|
| 72 |
} else if( Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->isMultiSelect($columnHeader)){
|
| 73 |
-
// handling the array
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
$productArray[$unbxdFieldName] = $valueArray;
|
| 81 |
-
}
|
| 82 |
-
} else if($columnHeader == "category_id"){
|
| 83 |
-
if(!isset($columndata)){
|
| 84 |
-
continue;
|
| 85 |
-
}
|
| 86 |
-
$categoryIds = explode(",",$columndata);
|
| 87 |
-
foreach($categoryIds as $categoryId){
|
| 88 |
-
$productArray[$unbxdFieldName] = trim($categoryId);
|
| 89 |
-
$productArray["category".($childProduct?"Associated":"")] = $this->getCategoryName(trim($categoryId));
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
} else if (is_array($columndata)){
|
| 93 |
-
$productArray[$unbxdFieldName] = $columndata;
|
| 94 |
-
} else if ($columndata instanceof Varien_Object){
|
| 95 |
-
$productArray[$unbxdFieldName] = $columndata->getData();
|
| 96 |
-
} else {
|
| 97 |
$productArray[$unbxdFieldName] = $columndata;
|
| 98 |
}
|
| 99 |
}
|
| 100 |
if(!$childProduct) {
|
|
|
|
| 101 |
$productArray = $this->addChildrens($product, $fields, $productArray);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
}
|
| 103 |
return $productArray;
|
| 104 |
}
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
public function addChildrens($product, $fields, $productArray) {
|
| 107 |
$type = $product->getData('type_id');
|
| 108 |
if ($type == "configurable" || $type == "grouped" ) {
|
| 109 |
-
$associatedProducts =
|
| 110 |
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
|
| 111 |
-
$
|
| 112 |
-
|
|
|
|
|
|
|
| 113 |
{
|
| 114 |
-
$childProduct = $this->getProduct($
|
| 115 |
-
$childProduct
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
}
|
| 118 |
-
|
| 119 |
-
$productArray["associatedProducts"] = $associatedProducts;
|
| 120 |
return $productArray;
|
| 121 |
} else {
|
| 122 |
return $productArray;
|
| 123 |
}
|
| 124 |
}
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
| 128 |
$product = $this->convertMultivalued($product);
|
| 129 |
} else {
|
| 130 |
$product = $this->convertMultivalued($product, $fields);
|
|
@@ -133,44 +207,83 @@ class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Productbuilder extends Unbxd_Dataf
|
|
| 133 |
return $product;
|
| 134 |
}
|
| 135 |
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
| 140 |
}
|
| 141 |
}
|
| 142 |
return $product;
|
| 143 |
}
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
} else {
|
| 154 |
-
return floatval($value);
|
| 155 |
}
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
} else if ($data_type[self::DATA_TYPE] == self::DATE) {
|
| 167 |
-
$
|
| 168 |
-
|
| 169 |
-
return $value;
|
| 170 |
-
}
|
| 171 |
return $value;
|
| 172 |
}
|
| 173 |
|
|
|
|
|
|
|
|
|
|
| 174 |
public function convertMultivalued($product, $fields = null) {
|
| 175 |
foreach($product as $field=>$value) {
|
| 176 |
if((is_null($fields) || ($fields[$field][self::MULTIVALUED] && $fields[$field][self::MULTIVALUED]))
|
|
@@ -182,7 +295,6 @@ class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Productbuilder extends Unbxd_Dataf
|
|
| 182 |
}
|
| 183 |
return $product;
|
| 184 |
}
|
| 185 |
-
|
| 186 |
}
|
| 187 |
|
| 188 |
?>
|
| 2 |
|
| 3 |
class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Productbuilder extends Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Jsonbuilder {
|
| 4 |
|
| 5 |
+
const DATA_TYPE = "data_type";
|
| 6 |
const MULTIVALUED = "multiValued";
|
| 7 |
const NUMBER = "number";
|
| 8 |
const DECIMAL = "decimal";
|
| 11 |
const IMAGE_WIDTH = "image_width";
|
| 12 |
const GENERATE_IMAGE = "generate_image";
|
| 13 |
|
| 14 |
+
/*
|
| 15 |
+
* method to get the products in json
|
| 16 |
+
*/
|
| 17 |
public function getProducts($collection, $fields) {
|
| 18 |
$content='';
|
| 19 |
$firstLoop = true;
|
| 32 |
return rtrim($content, ",");
|
| 33 |
}
|
| 34 |
|
| 35 |
+
|
| 36 |
+
/*
|
| 37 |
+
* method to get the product in json
|
| 38 |
+
*/
|
| 39 |
public function getProduct($product, $fields, $childProduct = false) {
|
| 40 |
|
| 41 |
$productArray =array();
|
| 42 |
|
| 43 |
foreach($product->getData('') as $columnHeader=>$columndata){
|
| 44 |
|
| 45 |
+
$unbxdFieldName = $this->getUnbxdFieldName($columnHeader, $childProduct);
|
| 46 |
+
if(isset($unbxdFieldName) && $unbxdFieldName != "" && !array_key_exists($unbxdFieldName, $fields)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
continue;
|
| 48 |
}
|
| 49 |
|
| 53 |
|
| 54 |
if($columnHeader=="url_path"){
|
| 55 |
// handling the url
|
| 56 |
+
$productArray[$unbxdFieldName] = Mage::getUrl('').$columndata;
|
| 57 |
} else if (Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->isImage($columnHeader)) {
|
| 58 |
+
// handling tthe images
|
| 59 |
+
$attributeValue = $this->getImage($columnHeader, $unbxdFieldName, $product, $fields);
|
| 60 |
+
if(!is_null($attributeValue)) {
|
| 61 |
+
$productArray[$unbxdFieldName] = $attributeValue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
}
|
| 63 |
+
|
| 64 |
} else if( Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->isMultiSelect($columnHeader)){
|
| 65 |
+
// handling the array/ multiselect attribute
|
| 66 |
+
$attributeValue = $this->getMultiSelectAttribute($columnHeader, $product);
|
| 67 |
+
if(!is_null($attributeValue)) {
|
| 68 |
+
$productArray[$unbxdFieldName] = $attributeValue;
|
| 69 |
+
}
|
| 70 |
+
} else if (!is_null($columndata) && $columndata != ""){
|
| 71 |
+
//adding the normal attribute
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
$productArray[$unbxdFieldName] = $columndata;
|
| 73 |
}
|
| 74 |
}
|
| 75 |
if(!$childProduct) {
|
| 76 |
+
// adding the childProduct
|
| 77 |
$productArray = $this->addChildrens($product, $fields, $productArray);
|
| 78 |
+
|
| 79 |
+
$category = $this->getCategoryAttribute($product);
|
| 80 |
+
// adding the category
|
| 81 |
+
$productArray = $category + $productArray;
|
| 82 |
}
|
| 83 |
return $productArray;
|
| 84 |
}
|
| 85 |
|
| 86 |
+
/**
|
| 87 |
+
* method to get category content in xml given the product object
|
| 88 |
+
*/
|
| 89 |
+
private function getCategoryAttribute($product){
|
| 90 |
+
$cats = $product->getCategoryIds();
|
| 91 |
+
$categoryIds = array();
|
| 92 |
+
$category = array();
|
| 93 |
+
$categoryData = array();
|
| 94 |
+
$index = 0;
|
| 95 |
+
foreach ($cats as $categoryId) {
|
| 96 |
+
$_cat = Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->getCategory($categoryId);
|
| 97 |
+
$categoryName = $_cat->getName();
|
| 98 |
+
if($index++ < 4) {
|
| 99 |
+
$categoryData['catlevel' . $index . 'Id'] = (string)$categoryId;
|
| 100 |
+
$categoryData['catlevel' . $index . 'Name'] = $categoryName;
|
| 101 |
+
}
|
| 102 |
+
$categoryIds[] = (string)$categoryId;
|
| 103 |
+
$category[] = $categoryName;
|
| 104 |
+
}
|
| 105 |
+
$categoryData['categoryIds'] = $categoryIds;
|
| 106 |
+
$categoryData['category'] = $category;
|
| 107 |
+
return $categoryData;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/*
|
| 111 |
+
* method to returns as an array of values given the fieldName and the product
|
| 112 |
+
*/
|
| 113 |
+
private function getMultiSelectAttribute($fieldName, $product) {
|
| 114 |
+
$data = explode(",", $product->getData($fieldName));
|
| 115 |
+
$valueAsAnArray = array();
|
| 116 |
+
foreach($data as $eachdata){
|
| 117 |
+
$attributeValue = Mage::getResourceSingleton("datafeeder/attribute")
|
| 118 |
+
->getAttributeValue($fieldName, trim($eachdata), $product);
|
| 119 |
+
if(!is_null($attributeValue) && $attributeValue != "") {
|
| 120 |
+
$valueAsAnArray[] = $attributeValue;
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
if(sizeof($valueAsAnArray) > 0) {
|
| 124 |
+
return $valueAsAnArray;
|
| 125 |
+
}
|
| 126 |
+
return null;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/*
|
| 130 |
+
* generates the image
|
| 131 |
+
*/
|
| 132 |
+
private function getImage($fieldName, $unbxdFieldName, $product, $fields) {
|
| 133 |
+
|
| 134 |
+
if($fields[$unbxdFieldName][self::GENERATE_IMAGE] == "1") {
|
| 135 |
+
try {
|
| 136 |
+
return (string)Mage::helper('catalog/image')->init($product, $fieldName)
|
| 137 |
+
->resize($fields[$unbxdFieldName][self::IMAGE_WIDTH],
|
| 138 |
+
$fields[$unbxdFieldName][self::IMAGE_HEIGHT]);
|
| 139 |
+
} catch (Exception $e) {
|
| 140 |
+
|
| 141 |
+
error_log("Error while fetching the image" . $e->getTraceAsString());
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
return $product->getData($fieldName);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
/*
|
| 148 |
+
* get unbxd specfic field name for the magento field name
|
| 149 |
+
*/
|
| 150 |
+
private function getUnbxdFieldName($columnHeader, $isChild) {
|
| 151 |
+
if($isChild) {
|
| 152 |
+
$unbxdFieldName = $columnHeader . "Associated";
|
| 153 |
+
} else {
|
| 154 |
+
$unbxdFieldName = $columnHeader;
|
| 155 |
+
}
|
| 156 |
+
return $this->renameConflictedFeatureFields($unbxdFieldName);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/*
|
| 160 |
+
* Renaming the conflicted unbxd feature fields eg: gender to _gender
|
| 161 |
+
*/
|
| 162 |
+
private function renameConflictedFeatureFields($unbxdFieldName) {
|
| 163 |
+
if (in_array($unbxdFieldName, Mage::getResourceSingleton('datafeeder/field')->getConflictedFeatureFieldLust())) {
|
| 164 |
+
return "_" . $unbxdFieldName;
|
| 165 |
+
}
|
| 166 |
+
return $unbxdFieldName;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
* gives the children in form of array
|
| 171 |
+
*/
|
| 172 |
public function addChildrens($product, $fields, $productArray) {
|
| 173 |
$type = $product->getData('type_id');
|
| 174 |
if ($type == "configurable" || $type == "grouped" ) {
|
| 175 |
+
$associatedProducts = array();
|
| 176 |
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
|
| 177 |
+
$childrens = $conf->getUsedProductCollection()
|
| 178 |
+
->addAttributeToSelect('*')
|
| 179 |
+
->addFilterByRequiredOptions();
|
| 180 |
+
foreach ($childrens as $children)
|
| 181 |
{
|
| 182 |
+
$childProduct = $this->getProduct($children, $fields, true);
|
| 183 |
+
if(isset($childProduct) && sizeof($childProduct) > 0 ) {
|
| 184 |
+
$childProduct = $this->postProcessProduct($childProduct, $fields, true);
|
| 185 |
+
$associatedProducts[] = $childProduct;
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
if( sizeof($associatedProducts) > 0) {
|
| 189 |
+
$productArray["associatedProducts"] = $associatedProducts;
|
| 190 |
}
|
|
|
|
|
|
|
| 191 |
return $productArray;
|
| 192 |
} else {
|
| 193 |
return $productArray;
|
| 194 |
}
|
| 195 |
}
|
| 196 |
|
| 197 |
+
/**
|
| 198 |
+
* process the prodcut
|
| 199 |
+
*/
|
| 200 |
+
public function postProcessProduct($product, $fields, $isChild=false) {
|
| 201 |
+
if($isChild) {
|
| 202 |
$product = $this->convertMultivalued($product);
|
| 203 |
} else {
|
| 204 |
$product = $this->convertMultivalued($product, $fields);
|
| 207 |
return $product;
|
| 208 |
}
|
| 209 |
|
| 210 |
+
/*
|
| 211 |
+
* convert the data type according to the dashboard setup
|
| 212 |
+
*/
|
| 213 |
+
public function convertDataType($product, $fields) {
|
| 214 |
+
foreach($product as $fieldName => $value) {
|
| 215 |
+
if($fieldName != "associatedProducts") {
|
| 216 |
+
$product[$fieldName] = $this->convertDataTypeByValue($fields[$fieldName], $value);
|
| 217 |
}
|
| 218 |
}
|
| 219 |
return $product;
|
| 220 |
}
|
| 221 |
|
| 222 |
+
/*
|
| 223 |
+
* method to get the float values
|
| 224 |
+
*/
|
| 225 |
+
private function getFloatValues($value) {
|
| 226 |
+
if(is_array($value)) {
|
| 227 |
+
$valueAsAnArray = array();
|
| 228 |
+
foreach ($value as $eachValue) {
|
| 229 |
+
$valueAsAnArray[] = floatval($eachValue);
|
|
|
|
|
|
|
| 230 |
}
|
| 231 |
+
return $valueAsAnArray;
|
| 232 |
+
} else {
|
| 233 |
+
return floatval($value);
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
/*
|
| 239 |
+
* returns the array as number
|
| 240 |
+
*/
|
| 241 |
+
private function getNumberValues($value) {
|
| 242 |
+
if(is_array($value)) {
|
| 243 |
+
$valueAsAnArray = array();
|
| 244 |
+
foreach ($value as $eachValue) {
|
| 245 |
+
$valueAsAnArray[] = intval($eachValue);
|
| 246 |
+
}
|
| 247 |
+
return $valueAsAnArray;
|
| 248 |
+
} else {
|
| 249 |
+
return intval($value);
|
| 250 |
+
}
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
/*
|
| 254 |
+
* returns the date value
|
| 255 |
+
*/
|
| 256 |
+
private function getDateValues($value) {
|
| 257 |
+
if(is_array($value)) {
|
| 258 |
+
$tempValue = array();
|
| 259 |
+
foreach ($value as $eachValue) {
|
| 260 |
+
$tokens = explode(" ",$eachValue);
|
| 261 |
+
$tempValue[] = $tokens[0].'T'.$tokens[1].'Z';
|
| 262 |
}
|
| 263 |
+
return $tempValue;
|
| 264 |
+
}
|
| 265 |
+
$tokens = explode(" ",$value);
|
| 266 |
+
$value = $tokens[0].'T'.$tokens[1].'Z';
|
| 267 |
+
return $value;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
/*
|
| 271 |
+
* returns the data type value
|
| 272 |
+
*/
|
| 273 |
+
private function convertDataTypeByValue($data_type, $value) {
|
| 274 |
+
if($data_type[self::DATA_TYPE] == self::DECIMAL) {
|
| 275 |
+
return $this->getFloatValues($value);
|
| 276 |
+
} else if ($data_type[self::DATA_TYPE] == self::NUMBER) {
|
| 277 |
+
return $this->getNumberValues($value);
|
| 278 |
} else if ($data_type[self::DATA_TYPE] == self::DATE) {
|
| 279 |
+
return $this->getDateValues($value);
|
| 280 |
+
}
|
|
|
|
|
|
|
| 281 |
return $value;
|
| 282 |
}
|
| 283 |
|
| 284 |
+
/*
|
| 285 |
+
* returns the product by changing it to multivalued after checking its data type
|
| 286 |
+
*/
|
| 287 |
public function convertMultivalued($product, $fields = null) {
|
| 288 |
foreach($product as $field=>$value) {
|
| 289 |
if((is_null($fields) || ($fields[$field][self::MULTIVALUED] && $fields[$field][self::MULTIVALUED]))
|
| 295 |
}
|
| 296 |
return $product;
|
| 297 |
}
|
|
|
|
| 298 |
}
|
| 299 |
|
| 300 |
?>
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Schemabuilder.php
CHANGED
|
@@ -39,4 +39,4 @@ class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Schemabuilder extends Unbxd_Datafe
|
|
| 39 |
}
|
| 40 |
}
|
| 41 |
|
| 42 |
-
?>
|
| 39 |
}
|
| 40 |
}
|
| 41 |
|
| 42 |
+
?>
|
app/code/local/Unbxd/Datafeeder/Model/Mysql4/Field.php
CHANGED
|
@@ -24,9 +24,13 @@ class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstrac
|
|
| 24 |
*/
|
| 25 |
public function getFieldMapping($site, $enabledFields = false) {
|
| 26 |
$results = Mage::getModel('datafeeder/field')->getCollection()->addFieldToFilter(self::SITE, $site);
|
| 27 |
-
$fieldMapping =
|
| 28 |
$_reader = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 29 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
$select = $_reader->select();
|
| 31 |
$select->from($table);
|
| 32 |
$filterCond = self::SITE . " = '" . $site . "'";
|
|
@@ -54,7 +58,7 @@ class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstrac
|
|
| 54 |
**/
|
| 55 |
public function getFields($site) {
|
| 56 |
$fieldMapping = $this->getFieldMapping($site);
|
| 57 |
-
$deltaUpdate =
|
| 58 |
$attributes = Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->getAttributes();
|
| 59 |
foreach($attributes as $attribute){
|
| 60 |
$fieldName = $attribute->getAttributeCode();
|
|
@@ -91,20 +95,26 @@ class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstrac
|
|
| 91 |
*/
|
| 92 |
public function updateFields($fieldMapping, $site) {
|
| 93 |
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
foreach($fieldMapping as $fieldName=>$values) {
|
| 95 |
$values = json_decode($values, true);
|
| 96 |
if (!isset($values[self::STATUS]) || !isset($values[self::DATA_TYPE]) ||
|
| 97 |
!($values[self::STATUS] == 0 || $values[self::STATUS] == 1)) {
|
| 98 |
throw new Exception("Invalid data with field " . $fieldName);
|
| 99 |
}
|
| 100 |
-
$
|
| 101 |
-
|
| 102 |
-
self::DATA_TYPE
|
| 103 |
-
self::AUTOSUGGEST
|
| 104 |
-
self::IMAGE_HEIGHT
|
| 105 |
-
self::IMAGE_WIDTH
|
| 106 |
-
self::GENERATE_IMAGE
|
| 107 |
-
|
|
|
|
| 108 |
}
|
| 109 |
}
|
| 110 |
|
|
@@ -113,9 +123,9 @@ class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstrac
|
|
| 113 |
*/
|
| 114 |
public function saveField($fieldMapping, $site) {
|
| 115 |
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 116 |
-
$insertingRequestArray =
|
| 117 |
foreach($fieldMapping as $field=>$value) {
|
| 118 |
-
$insertingRequest =
|
| 119 |
$insertingRequest[self::FIELD_NAME] = $field;
|
| 120 |
$insertingRequest[self::STATUS] = $value[self::STATUS];
|
| 121 |
$insertingRequest[self::SITE] = $site;
|
|
@@ -126,8 +136,13 @@ class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstrac
|
|
| 126 |
$insertingRequest[self::GENERATE_IMAGE] = $value[self::GENERATE_IMAGE];
|
| 127 |
$insertingRequestArray[] = $insertingRequest;
|
| 128 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
-
$write->insertMultiple($
|
| 131 |
}
|
| 132 |
|
| 133 |
/*
|
|
@@ -164,11 +179,16 @@ class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstrac
|
|
| 164 |
return $featuredFields;
|
| 165 |
}
|
| 166 |
|
| 167 |
-
|
| 168 |
return array( self::DATA_TYPE => $dataType,
|
| 169 |
self::MULTIVALUED => ($multiValued=="true")?1:0,
|
| 170 |
self::AUTOSUGGEST => ($autosuggest=="true")?1:0 );
|
| 171 |
|
| 172 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
}
|
| 174 |
?>
|
| 24 |
*/
|
| 25 |
public function getFieldMapping($site, $enabledFields = false) {
|
| 26 |
$results = Mage::getModel('datafeeder/field')->getCollection()->addFieldToFilter(self::SITE, $site);
|
| 27 |
+
$fieldMapping = array();
|
| 28 |
$_reader = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 29 |
+
if(method_exists($write, 'getTableName')) {
|
| 30 |
+
$table = $write->getTableName(self::TABLE_NAME);
|
| 31 |
+
} else {
|
| 32 |
+
$table = self::TABLE_NAME;
|
| 33 |
+
}
|
| 34 |
$select = $_reader->select();
|
| 35 |
$select->from($table);
|
| 36 |
$filterCond = self::SITE . " = '" . $site . "'";
|
| 58 |
**/
|
| 59 |
public function getFields($site) {
|
| 60 |
$fieldMapping = $this->getFieldMapping($site);
|
| 61 |
+
$deltaUpdate = array();
|
| 62 |
$attributes = Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->getAttributes();
|
| 63 |
foreach($attributes as $attribute){
|
| 64 |
$fieldName = $attribute->getAttributeCode();
|
| 95 |
*/
|
| 96 |
public function updateFields($fieldMapping, $site) {
|
| 97 |
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 98 |
+
if(method_exists($write, 'getTableName')) {
|
| 99 |
+
$table = $write->getTableName(self::TABLE_NAME);
|
| 100 |
+
} else {
|
| 101 |
+
$table = self::TABLE_NAME;
|
| 102 |
+
}
|
| 103 |
foreach($fieldMapping as $fieldName=>$values) {
|
| 104 |
$values = json_decode($values, true);
|
| 105 |
if (!isset($values[self::STATUS]) || !isset($values[self::DATA_TYPE]) ||
|
| 106 |
!($values[self::STATUS] == 0 || $values[self::STATUS] == 1)) {
|
| 107 |
throw new Exception("Invalid data with field " . $fieldName);
|
| 108 |
}
|
| 109 |
+
$updateQuery = 'UPDATE `'. $table .'` set '.
|
| 110 |
+
self::STATUS ." = '".$values[self::STATUS]."' , ".
|
| 111 |
+
self::DATA_TYPE." = '". $values[self::DATA_TYPE]."' , ".
|
| 112 |
+
self::AUTOSUGGEST." = '". $values[self::AUTOSUGGEST]."' , ".
|
| 113 |
+
self::IMAGE_HEIGHT." = '". (is_int($values[self::IMAGE_HEIGHT])?$values[self::IMAGE_HEIGHT]:0) ."' , ".
|
| 114 |
+
self::IMAGE_WIDTH ." = '". (is_int($values[self::IMAGE_WIDTH])?$values[self::IMAGE_WIDTH]:0)."' , ".
|
| 115 |
+
self::GENERATE_IMAGE." = '".$values[self::GENERATE_IMAGE]."' ".
|
| 116 |
+
' where '.self::SITE . "='". $site . "' AND " . self::FIELD_NAME . "='".$fieldName."'";
|
| 117 |
+
$write->query($updateQuery);
|
| 118 |
}
|
| 119 |
}
|
| 120 |
|
| 123 |
*/
|
| 124 |
public function saveField($fieldMapping, $site) {
|
| 125 |
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 126 |
+
$insertingRequestArray = array();
|
| 127 |
foreach($fieldMapping as $field=>$value) {
|
| 128 |
+
$insertingRequest = array();
|
| 129 |
$insertingRequest[self::FIELD_NAME] = $field;
|
| 130 |
$insertingRequest[self::STATUS] = $value[self::STATUS];
|
| 131 |
$insertingRequest[self::SITE] = $site;
|
| 136 |
$insertingRequest[self::GENERATE_IMAGE] = $value[self::GENERATE_IMAGE];
|
| 137 |
$insertingRequestArray[] = $insertingRequest;
|
| 138 |
}
|
| 139 |
+
if(method_exists($write, 'getTableName')) {
|
| 140 |
+
$table = $write->getTableName(self::TABLE_NAME);
|
| 141 |
+
} else {
|
| 142 |
+
$table = self::TABLE_NAME;
|
| 143 |
+
}
|
| 144 |
|
| 145 |
+
$write->insertMultiple($table, $insertingRequestArray);
|
| 146 |
}
|
| 147 |
|
| 148 |
/*
|
| 179 |
return $featuredFields;
|
| 180 |
}
|
| 181 |
|
| 182 |
+
public function getField($dataType, $multiValued, $autosuggest) {
|
| 183 |
return array( self::DATA_TYPE => $dataType,
|
| 184 |
self::MULTIVALUED => ($multiValued=="true")?1:0,
|
| 185 |
self::AUTOSUGGEST => ($autosuggest=="true")?1:0 );
|
| 186 |
|
| 187 |
}
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
public function getConflictedFeatureFieldLust() {
|
| 191 |
+
return array('gender');
|
| 192 |
+
}
|
| 193 |
}
|
| 194 |
?>
|
app/code/local/Unbxd/Datafeeder/Model/Mysql4/Upgrade.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Unbxd_Datafeeder_Model_Mysql4_Upgrade {
|
| 3 |
+
|
| 4 |
+
public function upgrade010To105() {
|
| 5 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 6 |
+
$unbxdFieldTable = $write->getTableName('unbxd_field');
|
| 7 |
+
$unbxdConfTable = $write->getTableName('unbxd_datafeeder_conf');
|
| 8 |
+
$write->query("
|
| 9 |
+
DROP TABLE IF EXISTS `{$unbxdFieldTable}`;
|
| 10 |
+
|
| 11 |
+
CREATE TABLE `{$unbxdFieldTable}` (
|
| 12 |
+
`field_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
| 13 |
+
`name` varchar(100) NOT NULL DEFAULT '',
|
| 14 |
+
`status` int(1) NOT NULL DEFAULT '1',
|
| 15 |
+
`site` varchar(100) NOT NULL DEFAULT '',
|
| 16 |
+
`data_type` varchar(20) NOT NULL DEFAULT 'longText',
|
| 17 |
+
`autosuggest` int(1) NOT NULL DEFAULT '0',
|
| 18 |
+
`image_height` int(5) NOT NULL DEFAULT '0',
|
| 19 |
+
`image_width` int(5) NOT NULL DEFAULT '0',
|
| 20 |
+
`generate_image` int(1) NOT NULL DEFAULT '0',
|
| 21 |
+
PRIMARY KEY (`field_id`)
|
| 22 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 23 |
+
|
| 24 |
+
DROP TABLE IF EXISTS `{$unbxdConfTable}`;
|
| 25 |
+
|
| 26 |
+
CREATE TABLE `{$unbxdConfTable}` (
|
| 27 |
+
`uconfig_id` int(10) unsigned NOT NULL auto_increment,
|
| 28 |
+
`action` varchar(255) NOT NULL default '',
|
| 29 |
+
`value` varchar(255),
|
| 30 |
+
PRIMARY KEY (`uconfig_id`)
|
| 31 |
+
|
| 32 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 33 |
+
");
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
}
|
| 37 |
+
?>
|
app/code/local/Unbxd/Datafeeder/controllers/ConfigController.php
CHANGED
|
@@ -63,6 +63,11 @@ class Unbxd_Datafeeder_ConfigController extends Mage_Core_Controller_Front_Act
|
|
| 63 |
echo json_encode($response);
|
| 64 |
}
|
| 65 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
}
|
| 67 |
?>
|
| 68 |
|
| 63 |
echo json_encode($response);
|
| 64 |
}
|
| 65 |
}
|
| 66 |
+
|
| 67 |
+
public function upgradedbAction() {
|
| 68 |
+
Mage::getResourceSingleton("datafeeder/upgrade")->upgrade010To105();
|
| 69 |
+
echo json_encode( array('success' => 'true' ));
|
| 70 |
+
}
|
| 71 |
}
|
| 72 |
?>
|
| 73 |
|
app/code/local/Unbxd/Datafeeder/controllers/FieldController.php
CHANGED
|
@@ -42,6 +42,7 @@ class Unbxd_Datafeeder_FieldController extends Mage_Core_Controller_Front_Actio
|
|
| 42 |
try {
|
| 43 |
$fields = Mage::getResourceSingleton(self::FIELD_MODEL)->updateFields($params,$site);
|
| 44 |
} catch(Exception $ex) {
|
|
|
|
| 45 |
echo json_encode(array("success"=>"false", "message" => $ex));
|
| 46 |
return;
|
| 47 |
}
|
| 42 |
try {
|
| 43 |
$fields = Mage::getResourceSingleton(self::FIELD_MODEL)->updateFields($params,$site);
|
| 44 |
} catch(Exception $ex) {
|
| 45 |
+
error_log($ex->getMessage());
|
| 46 |
echo json_encode(array("success"=>"false", "message" => $ex));
|
| 47 |
return;
|
| 48 |
}
|
app/code/local/Unbxd/Datafeeder/sql/datafeeder_setup/mysql4-install-1.0.5.php
CHANGED
|
@@ -21,7 +21,7 @@ CREATE TABLE `{$installer->getTable('unbxd_field')}` (
|
|
| 21 |
`image_width` int(5) NOT NULL DEFAULT '0',
|
| 22 |
`generate_image` int(1) NOT NULL DEFAULT '0',
|
| 23 |
PRIMARY KEY (`field_id`)
|
| 24 |
-
) ENGINE=InnoDB
|
| 25 |
|
| 26 |
DROP TABLE IF EXISTS `{$installer->getTable('unbxd_datafeeder_conf')}`;
|
| 27 |
|
| 21 |
`image_width` int(5) NOT NULL DEFAULT '0',
|
| 22 |
`generate_image` int(1) NOT NULL DEFAULT '0',
|
| 23 |
PRIMARY KEY (`field_id`)
|
| 24 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 25 |
|
| 26 |
DROP TABLE IF EXISTS `{$installer->getTable('unbxd_datafeeder_conf')}`;
|
| 27 |
|
app/code/local/Unbxd/Datafeeder/sql/datafeeder_setup/mysql4-upgrade-0.1.0-1.0.5.php
CHANGED
|
@@ -21,7 +21,7 @@ CREATE TABLE `{$installer->getTable('unbxd_field')}` (
|
|
| 21 |
`image_width` int(5) NOT NULL DEFAULT '0',
|
| 22 |
`generate_image` int(1) NOT NULL DEFAULT '0',
|
| 23 |
PRIMARY KEY (`field_id`)
|
| 24 |
-
) ENGINE=InnoDB
|
| 25 |
|
| 26 |
DROP TABLE IF EXISTS `{$installer->getTable('unbxd_datafeeder_conf')}`;
|
| 27 |
|
| 21 |
`image_width` int(5) NOT NULL DEFAULT '0',
|
| 22 |
`generate_image` int(1) NOT NULL DEFAULT '0',
|
| 23 |
PRIMARY KEY (`field_id`)
|
| 24 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 25 |
|
| 26 |
DROP TABLE IF EXISTS `{$installer->getTable('unbxd_datafeeder_conf')}`;
|
| 27 |
|
app/design/adminhtml/base/default/template/datafeeder/conf.phtml
CHANGED
|
@@ -221,12 +221,14 @@
|
|
| 221 |
});
|
| 222 |
$jq.ajax({
|
| 223 |
url: "<?php echo $this->getSaveFieldUrl();?>",
|
| 224 |
-
timeout:
|
| 225 |
type:"POST",
|
| 226 |
dataType: "json",
|
| 227 |
data:fields
|
|
|
|
|
|
|
| 228 |
});
|
| 229 |
-
|
| 230 |
}
|
| 231 |
|
| 232 |
function createTable(ajaxurl)
|
|
@@ -257,14 +259,14 @@
|
|
| 257 |
|
| 258 |
function addFieldConfTableHeader() {
|
| 259 |
return "<tr>" +
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
}
|
| 269 |
|
| 270 |
function constructRow(key, value, childExists) {
|
| 221 |
});
|
| 222 |
$jq.ajax({
|
| 223 |
url: "<?php echo $this->getSaveFieldUrl();?>",
|
| 224 |
+
timeout:30000,
|
| 225 |
type:"POST",
|
| 226 |
dataType: "json",
|
| 227 |
data:fields
|
| 228 |
+
}).done( function(data) {
|
| 229 |
+
createTable('<?php echo $this->getEditUrl();?>');
|
| 230 |
});
|
| 231 |
+
|
| 232 |
}
|
| 233 |
|
| 234 |
function createTable(ajaxurl)
|
| 259 |
|
| 260 |
function addFieldConfTableHeader() {
|
| 261 |
return "<tr>" +
|
| 262 |
+
"<th>Field Name</th>" +
|
| 263 |
+
"<th>Status</th>" +
|
| 264 |
+
"<th>Data Type</th>" +
|
| 265 |
+
"<th>Autosuggest</th>" +
|
| 266 |
+
"<th>Add to configurable product</th>" +
|
| 267 |
+
"<th>Image configuration</th>" +
|
| 268 |
+
'<td class="scope-label"></td>' +
|
| 269 |
+
"</tr>";
|
| 270 |
}
|
| 271 |
|
| 272 |
function constructRow(key, value, childExists) {
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>unbxd_feedconnector</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -10,9 +10,9 @@
|
|
| 10 |
<description>pushes the products from the magento to unbxd servers</description>
|
| 11 |
<notes>Supporting v2 type of unbxd field</notes>
|
| 12 |
<authors><author><name>ananthesh</name><user>ananthesh</user><email>ananthesh@unbxd.com</email></author></authors>
|
| 13 |
-
<date>2014-07-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magelocal"><dir name="Unbxd"><dir name="Datafeeder"><dir name="Block"><file name="Edit.php" hash="6cc7e0396c298656c2529d2651bc0ae1"/><file name="Index.php" hash="9114009eae54970145fbb849cfc22dfd"/></dir><dir name="Helper"><file name="
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>unbxd_feedconnector</name>
|
| 4 |
+
<version>1.0.6</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 10 |
<description>pushes the products from the magento to unbxd servers</description>
|
| 11 |
<notes>Supporting v2 type of unbxd field</notes>
|
| 12 |
<authors><author><name>ananthesh</name><user>ananthesh</user><email>ananthesh@unbxd.com</email></author></authors>
|
| 13 |
+
<date>2014-07-23</date>
|
| 14 |
+
<time>08:05:49</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="Unbxd"><dir name="Datafeeder"><dir name="Block"><file name="Edit.php" hash="6cc7e0396c298656c2529d2651bc0ae1"/><file name="Index.php" hash="9114009eae54970145fbb849cfc22dfd"/></dir><dir name="Helper"><file name="Analyticshelper.php" hash="9c841be95363d1e100e9a00c7d95f7d6"/><file name="Data.php" hash="cc32188ca72c365a3177b8439188f4b0"/><file name="UnbxdIndexingHelper.php" hash="e4299a181161ba65d80bf579aaea0502"/><file name="UnbxdTaxonomyHelper.php" hash="9c16f370fa44807d8524c549c1ddb017"/><file name=".DS_Store" hash="801d9a1a1f478b210726cfc656cec74f"/></dir><dir name="Model"><file name="Attribute.php" hash="88512f545001b669638f6677b3f8b33a"/><file name="Conf.php" hash="b9a9627d779f473b7ab1696fd44a877b"/><file name="Facet.php" hash="a778acee165d1ff0162be6664f4ecf1a"/><dir name="Feed"><file name="Feedcreator.php" hash="e85c18bca30feb853e4228663a750c4e"/><file name="Feedmanager.php" hash="0bd8bba2762467635e210f8a4eba666a"/><file name="Filemanager.php" hash="5200abf7349679edec7e617619c8d8b3"/><dir name="Jsonbuilder"><file name="Jsonbuilder.php" hash="77635e52b5ec7c39dae78094efed566e"/><file name="Productbuilder.php" hash="663d4695deb72bc139f2441bd7f74417"/><file name="Schemabuilder.php" hash="c2e308dcc1accc0c867d1f313f09ec53"/></dir></dir><file name="Field.php" hash="4206919e3762907aba7d38b39733deba"/><dir name="Mysql4"><file name="Attribute.php" hash="7ec9732a1399db03dec0b6002d1aeb58"/><dir name="Conf"><file name="Collection.php" hash="fa30f58432618d2822ce0e3fe1483efe"/></dir><file name="Conf.php" hash="fc7785946f92585d05005df6ea78cbcb"/><dir name="Field"><file name="Collection.php" hash="5c9a40a3f2df168531c1af18be63bf16"/></dir><file name="Field.php" hash="e7d3b8a5a0ef5d5ac20b429016de097e"/><dir name="Resource"><file name="Attribute.php" hash="9353baa4f14eeb342de93d20c566bfee"/></dir><file name="Upgrade.php" hash="e3e259f32cdcf58d2dca2a21d6262767"/></dir></dir><dir name="controllers"><file name="ConfigController.php" hash="1cbf78cacb2d1292d058b3de160df2f5"/><file name="FieldController.php" hash="0c93a9c339d718179641c0a47cccaa6c"/><file name="IndexController.php" hash="90a2150b94caa81fd598d01f3e0c124b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="243eca656901fd022f8119a3ad46b569"/><file name="config.xml" hash="7c26ae17786870ee2536d68f8d9d868c"/></dir><dir name="scripts"><file name="Cron.php" hash="087a021cf47794f337e4ce0130b2d3b7"/><file name="abstract.php" hash="757e66bc99da02c274a0d9723923329e"/></dir><dir name="sql"><dir name="datafeeder_setup"><file name="mysql4-install-1.0.5.php" hash="27ecb984b7419e2fc58433db370fe43d"/><file name="mysql4-upgrade-0.1.0-1.0.5.php" hash="27ecb984b7419e2fc58433db370fe43d"/></dir></dir><file name=".DS_Store" hash="b4a356bd7741138b66aa79afcc4abd2f"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="datafeeder"><file name="conf.phtml" hash="3d8681947e03b3ad644360123220262a"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="shell"><file name="UnbxdFeed.php" hash="2b70f51b04c4b62b4a51aca0efae7050"/></dir></target><target name="mageetc"><dir name="modules"><file name="Unbxd_Datafeeder.xml" hash="73f1469ef7c4f5c4eef05900302239de"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
