Version Notes
Supporting v2 type of unbxd field
Download this release
Release Info
Developer | ananthesh |
Extension | unbxd_feedconnector |
Version | 1.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.4 to 1.0.5
- app/code/local/Unbxd/Datafeeder/Helper/AnalyticsHelper.php +13 -0
- app/code/local/Unbxd/Datafeeder/Helper/Data.php +1 -3
- app/code/local/Unbxd/Datafeeder/Helper/UnbxdIndexingHelper.php +15 -9
- app/code/local/Unbxd/Datafeeder/Model/Feed/Feedcreator.php +227 -0
- app/code/local/Unbxd/Datafeeder/Model/Feed/Feedmanager.php +159 -0
- app/code/local/Unbxd/Datafeeder/Model/Feed/Filemanager.php +74 -0
- app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Jsonbuilder.php +9 -0
- app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Productbuilder.php +188 -0
- app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Schemabuilder.php +42 -0
- app/code/local/Unbxd/Datafeeder/Model/Mysql4/Field.php +109 -29
- app/code/local/Unbxd/Datafeeder/controllers/FieldController.php +27 -7
- app/code/local/Unbxd/Datafeeder/controllers/IndexController.php +3 -3
- app/code/local/Unbxd/Datafeeder/etc/config.xml +2 -2
- app/code/local/Unbxd/Datafeeder/sql/datafeeder_setup/mysql4-install-0.1.0.php +0 -36
- app/code/local/Unbxd/Datafeeder/sql/datafeeder_setup/mysql4-install-1.0.5.php +39 -0
- app/code/local/Unbxd/Datafeeder/sql/datafeeder_setup/mysql4-upgrade-0.1.0-1.0.5.php +39 -0
- app/design/adminhtml/base/default/template/datafeeder/conf.phtml +237 -63
- package.xml +5 -5
app/code/local/Unbxd/Datafeeder/Helper/AnalyticsHelper.php
CHANGED
@@ -88,5 +88,18 @@ class Unbxd_Datafeeder_Helper_AnalyticsHelper extends Mage_Core_Helper_Abstract{
|
|
88 |
}
|
89 |
return 'unbxdattr="order" unbxdparam_sku="'.$product->getData('store_id').'"';
|
90 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
}
|
92 |
?>
|
88 |
}
|
89 |
return 'unbxdattr="order" unbxdparam_sku="'.$product->getData('store_id').'"';
|
90 |
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Checks whether request is a navigation
|
94 |
+
*
|
95 |
+
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
|
96 |
+
* @return bool
|
97 |
+
*/
|
98 |
+
public function isNavigation() {
|
99 |
+
if(Mage::app()->getRequest()->getControllerName() == "category") {
|
100 |
+
return true;
|
101 |
+
}
|
102 |
+
return false;
|
103 |
+
}
|
104 |
}
|
105 |
?>
|
app/code/local/Unbxd/Datafeeder/Helper/Data.php
CHANGED
@@ -7,8 +7,6 @@ class Unbxd_Datafeeder_Helper_Data extends Mage_Core_Helper_Abstract
|
|
7 |
{
|
8 |
$params=$this->_getRequest()->getParams();
|
9 |
return $params;
|
10 |
-
}
|
11 |
-
|
12 |
-
|
13 |
|
14 |
}
|
7 |
{
|
8 |
$params=$this->_getRequest()->getParams();
|
9 |
return $params;
|
10 |
+
}
|
|
|
|
|
11 |
|
12 |
}
|
app/code/local/Unbxd/Datafeeder/Helper/UnbxdIndexingHelper.php
CHANGED
@@ -28,6 +28,7 @@
|
|
28 |
$this->file = Mage::getBaseDir('tmp').DS.'unbxdFeed.xml';
|
29 |
$this-log("calling setfeilds method");
|
30 |
$this->fields = [];
|
|
|
31 |
}
|
32 |
|
33 |
public function setFields($site) {
|
@@ -156,7 +157,7 @@
|
|
156 |
*/
|
157 |
private function writeXmlProductContents($fromdate,$todate,$site,$operation,$ids){
|
158 |
|
159 |
-
|
160 |
$collection=$this->getCatalogCollection($fromdate,$todate,$site,$operation,$ids);
|
161 |
// get total size
|
162 |
//set the time limit to infinite
|
@@ -168,6 +169,7 @@
|
|
168 |
$collection->clear();
|
169 |
$collection->getSelect()->limit($this->PAGE_SIZE, ($pageNum++) * $this->PAGE_SIZE);
|
170 |
$collection->load();
|
|
|
171 |
if(count($collection) == 0){
|
172 |
if($pageNum == 1){
|
173 |
$this->log("No products found");
|
@@ -214,9 +216,6 @@
|
|
214 |
if($operation != "add"){
|
215 |
return $this->getAttributesInXML('uniqueId',$product->getData('entity_id'));
|
216 |
}
|
217 |
-
$spsPrice = $product->getData('special_price');
|
218 |
-
$spsPrice = isset($spsPrice)? $spsPrice :0;
|
219 |
-
$content = $content.$this->getAttributesInXML('saving',(int)$product->getData('price') - (int)$spsPrice);
|
220 |
|
221 |
foreach($product->getData('') as $columnHeader=>$columndata){
|
222 |
|
@@ -291,12 +290,20 @@
|
|
291 |
* This is optimized method, where it doesn't make a database call to get fieldType
|
292 |
* where it fetches from the local variable, which holds the information of field to fieldType mapping
|
293 |
*/
|
294 |
-
|
295 |
if($this->getFieldType($attributeName) == "select" || $this->getFieldType($attributeName) == "multiselect" ){
|
296 |
return true;
|
297 |
}
|
298 |
return false;
|
299 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
|
301 |
/**
|
302 |
* function to get Category from the category id,
|
@@ -360,7 +367,6 @@
|
|
360 |
$content='';
|
361 |
|
362 |
foreach($columndata as $element){
|
363 |
-
|
364 |
$content=$content.$this->getAttributesInXML($columnHeader,$element);
|
365 |
}
|
366 |
|
@@ -432,7 +438,7 @@
|
|
432 |
if ($operation == "add") {
|
433 |
// select all the attributes
|
434 |
$website =Mage::getModel("core/website")->setName($site);
|
435 |
-
$visiblityCondition = array('in' => array(
|
436 |
|
437 |
$collection = Mage::getResourceModel('catalog/product_collection')
|
438 |
->addWebsiteFilter($this->validateSite($site))
|
@@ -449,7 +455,7 @@
|
|
449 |
$collection = Mage::getResourceModel('catalog/product_collection');
|
450 |
if(sizeof($ids) > 0) {
|
451 |
$condition = array('in' => $ids);
|
452 |
-
$collection= $collection->addAttributeToFilter('entity_id',$condition)->addAttributeToSelect('entity_id');
|
453 |
}
|
454 |
}
|
455 |
|
@@ -500,7 +506,7 @@
|
|
500 |
/**
|
501 |
* method to create the feed
|
502 |
**/
|
503 |
-
public function createFeed($fromdate,$todate,$site,$operation,$ids){
|
504 |
if($this->createXmlFile()){
|
505 |
$this->log("started writing header");
|
506 |
if(!$this->writeXmlHeaderContents($operation)){
|
28 |
$this->file = Mage::getBaseDir('tmp').DS.'unbxdFeed.xml';
|
29 |
$this-log("calling setfeilds method");
|
30 |
$this->fields = [];
|
31 |
+
$this-> setFieldType();
|
32 |
}
|
33 |
|
34 |
public function setFields($site) {
|
157 |
*/
|
158 |
private function writeXmlProductContents($fromdate,$todate,$site,$operation,$ids){
|
159 |
|
160 |
+
|
161 |
$collection=$this->getCatalogCollection($fromdate,$todate,$site,$operation,$ids);
|
162 |
// get total size
|
163 |
//set the time limit to infinite
|
169 |
$collection->clear();
|
170 |
$collection->getSelect()->limit($this->PAGE_SIZE, ($pageNum++) * $this->PAGE_SIZE);
|
171 |
$collection->load();
|
172 |
+
echo "<pre>";print_r($collection);echo "</pre>";
|
173 |
if(count($collection) == 0){
|
174 |
if($pageNum == 1){
|
175 |
$this->log("No products found");
|
216 |
if($operation != "add"){
|
217 |
return $this->getAttributesInXML('uniqueId',$product->getData('entity_id'));
|
218 |
}
|
|
|
|
|
|
|
219 |
|
220 |
foreach($product->getData('') as $columnHeader=>$columndata){
|
221 |
|
290 |
* This is optimized method, where it doesn't make a database call to get fieldType
|
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;
|
298 |
}
|
299 |
+
|
300 |
+
|
301 |
+
public function isImage($attributeName = "") {
|
302 |
+
if($this->getFieldType($attributeName) == "media_image") {
|
303 |
+
return true;
|
304 |
+
}
|
305 |
+
return false;
|
306 |
+
}
|
307 |
|
308 |
/**
|
309 |
* function to get Category from the category id,
|
367 |
$content='';
|
368 |
|
369 |
foreach($columndata as $element){
|
|
|
370 |
$content=$content.$this->getAttributesInXML($columnHeader,$element);
|
371 |
}
|
372 |
|
438 |
if ($operation == "add") {
|
439 |
// select all the attributes
|
440 |
$website =Mage::getModel("core/website")->setName($site);
|
441 |
+
$visiblityCondition = array('in' => array(4));
|
442 |
|
443 |
$collection = Mage::getResourceModel('catalog/product_collection')
|
444 |
->addWebsiteFilter($this->validateSite($site))
|
455 |
$collection = Mage::getResourceModel('catalog/product_collection');
|
456 |
if(sizeof($ids) > 0) {
|
457 |
$condition = array('in' => $ids);
|
458 |
+
$collection = $collection->addAttributeToFilter('entity_id',$condition)->addAttributeToSelect('entity_id');
|
459 |
}
|
460 |
}
|
461 |
|
506 |
/**
|
507 |
* method to create the feed
|
508 |
**/
|
509 |
+
public function createFeed($fromdate,$todate,$site,$operation,$ids){
|
510 |
if($this->createXmlFile()){
|
511 |
$this->log("started writing header");
|
512 |
if(!$this->writeXmlHeaderContents($operation)){
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Feedcreator.php
ADDED
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Unbxd_Datafeeder_Model_Feed_Feedcreator {
|
4 |
+
|
5 |
+
var $fileName;
|
6 |
+
|
7 |
+
var $fields;
|
8 |
+
|
9 |
+
const STATUS = 'status';
|
10 |
+
const DATA_TYPE = 'data_type';
|
11 |
+
const AUTOSUGGEST = 'autosuggest';
|
12 |
+
|
13 |
+
|
14 |
+
const PAGE_SIZE = 500;
|
15 |
+
public function __construct(){
|
16 |
+
}
|
17 |
+
|
18 |
+
public function init($site, $fileName) {
|
19 |
+
Mage::getSingleton('unbxd_datafeeder/feed_filemanager')->setLog(str_replace(' ', '_',$site)."_Datafeeder.log");
|
20 |
+
$this->setFields($site);
|
21 |
+
$this->fileName = $fileName;
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* method to create the feed
|
27 |
+
**/
|
28 |
+
public function createFeed($fileName, $fromdate,$todate,$site,$operation,$ids){
|
29 |
+
$this->init($site, $fileName);
|
30 |
+
if($this->createFile()){
|
31 |
+
$this->log("started writing header");
|
32 |
+
|
33 |
+
if(!$this->writeFeedContent($fromdate,$todate,$site,$operation,$ids)){
|
34 |
+
return false;
|
35 |
+
}
|
36 |
+
|
37 |
+
} else {
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
return true;
|
41 |
+
}
|
42 |
+
|
43 |
+
private function writeFeedContent($fromdate,$todate,$site,$operation,$ids) {
|
44 |
+
if(!$this->appendTofile('{"feed":')) {
|
45 |
+
$this->log("Error writing feed tag");
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
|
49 |
+
if(!$this->writeCatalogContent($fromdate,$todate,$site,$operation,$ids)) {
|
50 |
+
$this->log("Error writing catalog tag");
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
|
54 |
+
if(!$this->appendTofile("}")) {
|
55 |
+
$this->log("Error writing closing feed tag");
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
|
59 |
+
return true;
|
60 |
+
}
|
61 |
+
|
62 |
+
private function writeCatalogContent($fromdate,$todate,$site,$operation,$ids) {
|
63 |
+
if(!$this->appendTofile('{"catalog":{')) {
|
64 |
+
$this->log("Error writing closing catalog tag");
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
if(!$this->writeSchemaContent()) {
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
|
71 |
+
if(!$this->appendTofile(",")) {
|
72 |
+
$this->log("Error while adding comma in catalog");
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
|
76 |
+
if(!$this->writeProductsContent($fromdate,$todate,$site,$operation,$ids)) {
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
if(!$this->appendTofile("}}")) {
|
81 |
+
$this->log("Error writing closing catalog tag");
|
82 |
+
return false;
|
83 |
+
}
|
84 |
+
return true;
|
85 |
+
}
|
86 |
+
|
87 |
+
private function writeSchemaContent() {
|
88 |
+
return $this->appendTofile('"schema":'.Mage::getSingleton('unbxd_datafeeder/feed_jsonbuilder_schemabuilder')->getSchema($this->fields));
|
89 |
+
}
|
90 |
+
|
91 |
+
private function writeProductsContent($fromdate,$todate,$site,$operation,$ids) {
|
92 |
+
|
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');
|
99 |
+
|
100 |
+
if(!$this->appendTofile('"'. $operation . '":{ "items":[')) {
|
101 |
+
$this->log("Error while adding items tag");
|
102 |
+
return false;
|
103 |
+
}
|
104 |
+
|
105 |
+
$firstLoop = true;
|
106 |
+
|
107 |
+
while(true){
|
108 |
+
$collection->clear();
|
109 |
+
$collection->getSelect()->limit(self::PAGE_SIZE, ($pageNum++) * self::PAGE_SIZE);
|
110 |
+
$collection->load();
|
111 |
+
if(count($collection) == 0){
|
112 |
+
if($pageNum == 1){
|
113 |
+
$this->log("No products found");
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
break;
|
117 |
+
}
|
118 |
+
|
119 |
+
if(!$firstLoop) {
|
120 |
+
if(!$this->appendTofile( ',')) {
|
121 |
+
$this->log("Error while addings items separator");
|
122 |
+
return false;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
$content=Mage::getSingleton('unbxd_datafeeder/feed_jsonbuilder_productbuilder')->getProducts($collection, $this->fields);
|
126 |
+
$status=$this->appendTofile($content);
|
127 |
+
if(!$status){
|
128 |
+
$this->log("Error while addings items");
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
$this->log('Added '.($pageNum) * $pageSize.' products');
|
132 |
+
$firstLoop = false;
|
133 |
+
}
|
134 |
+
|
135 |
+
if(!$this->appendTofile("]}")) {
|
136 |
+
$this->log("Error writing closing items tag");
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
$this->log('Added all products');
|
142 |
+
return true;
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
private function setFields($site) {
|
147 |
+
$this->fields = Mage::getResourceSingleton('datafeeder/field')->getFieldMapping($site, true);
|
148 |
+
$this->log("fields are set" );
|
149 |
+
$this->fields["type_id"] = array(self::STATUS => 1,
|
150 |
+
self::DATA_TYPE => "longText",
|
151 |
+
self::AUTOSUGGEST => 0 );
|
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 |
+
|
158 |
+
/**
|
159 |
+
* method to get the catalog collection
|
160 |
+
*
|
161 |
+
*/
|
162 |
+
public function getCatalogCollection($fromdate,$todate,$site,$operation,$ids) {
|
163 |
+
try{
|
164 |
+
if ($operation == "add") {
|
165 |
+
// select all the attributes
|
166 |
+
$website =Mage::getModel("core/website")->setName($site);
|
167 |
+
$visiblityCondition = array('in' => array(4));
|
168 |
+
|
169 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
170 |
+
->addWebsiteFilter($this->validateSite($site))
|
171 |
+
->addAttributeToFilter('status',1)
|
172 |
+
->joinField("qty", "cataloginventory_stock_item", 'qty', 'product_id=entity_id', null, 'left')
|
173 |
+
->addAttributeToSelect('*')
|
174 |
+
->addAttributeToFilter('visibility',$visiblityCondition);
|
175 |
+
|
176 |
+
if(sizeof($ids) > 0){
|
177 |
+
$condition = array('in' => $ids);
|
178 |
+
$collection=$collection->addAttributeToFilter('entity_id',$condition);
|
179 |
+
}
|
180 |
+
} else {
|
181 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
182 |
+
if(sizeof($ids) > 0) {
|
183 |
+
$condition = array('in' => $ids);
|
184 |
+
$collection= $collection->addAttributeToFilter('entity_id',$condition)->addAttributeToSelect('entity_id');
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
$this->log($collection->getSelect());
|
189 |
+
return $collection;
|
190 |
+
} catch(Exception $e) {
|
191 |
+
$this->log($e->getMessage());
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Function to initialize to feed creation process
|
198 |
+
*/
|
199 |
+
private function createFile(){
|
200 |
+
return Mage::getSingleton('unbxd_datafeeder/feed_filemanager')->createFile($this->fileName);
|
201 |
+
}
|
202 |
+
|
203 |
+
private function appendTofile($data){
|
204 |
+
return Mage::getSingleton('unbxd_datafeeder/feed_filemanager')->appendTofile($this->fileName, $data);
|
205 |
+
}
|
206 |
+
|
207 |
+
public function log($message) {
|
208 |
+
Mage::getSingleton('unbxd_datafeeder/feed_filemanager')->log($message);
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* method to validate whether the site exists or not
|
213 |
+
**/
|
214 |
+
public function validateSite($site){
|
215 |
+
$sites=Mage::app()->getWebsites();
|
216 |
+
if( !isset($site) || $site == "") {
|
217 |
+
return false;
|
218 |
+
}
|
219 |
+
foreach( $sites as $eachSite){
|
220 |
+
if(strcasecmp ( $eachSite->getName(), $site ) == 0 ){
|
221 |
+
return $eachSite->getWebsiteId();
|
222 |
+
}
|
223 |
+
}
|
224 |
+
return -1;
|
225 |
+
}
|
226 |
+
}
|
227 |
+
?>
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Feedmanager.php
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Unbxd_Datafeeder_Model_Feed_Feedmanager {
|
4 |
+
|
5 |
+
|
6 |
+
/**
|
7 |
+
* method to push the feed to the Unbxd server
|
8 |
+
**/
|
9 |
+
public function pushFeed($site){
|
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);
|
17 |
+
curl_setopt($ch, CURLOPT_POST,true);
|
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){
|
25 |
+
$this->log($Ex->getMessage());
|
26 |
+
return false;
|
27 |
+
}
|
28 |
+
$this->log(json_encode($response));
|
29 |
+
curl_close($ch);
|
30 |
+
return true;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function exec($ch)
|
34 |
+
{
|
35 |
+
$response = curl_exec($ch);
|
36 |
+
$error = curl_error($ch);
|
37 |
+
$result = array( 'header' => '',
|
38 |
+
'body' => '',
|
39 |
+
'curl_error' => '',
|
40 |
+
'http_code' => '',
|
41 |
+
'last_url' => '');
|
42 |
+
if ( $error != "" )
|
43 |
+
{
|
44 |
+
$result['curl_error'] = $error;
|
45 |
+
return $result;
|
46 |
+
}
|
47 |
+
|
48 |
+
$header_size = curl_getinfo($ch,CURLINFO_HEADER_SIZE);
|
49 |
+
$result['header'] = substr($response, 0, $header_size);
|
50 |
+
$result['body'] = substr( $response, $header_size );
|
51 |
+
$result['http_code'] = curl_getinfo($this -> ch,CURLINFO_HTTP_CODE);
|
52 |
+
$result['last_url'] = curl_getinfo($this -> ch,CURLINFO_EFFECTIVE_URL);
|
53 |
+
return $result;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* method to set the feedName, log, apikey based on site Name
|
58 |
+
**/
|
59 |
+
public function init($site)
|
60 |
+
{
|
61 |
+
$this->fileName = Mage::getBaseDir('tmp').DS.str_replace(' ', '_',$site). "_Feed.json";
|
62 |
+
$this->key = Mage::getResourceSingleton("datafeeder/conf")->getValue("apiKey");
|
63 |
+
$this->siteName = Mage::getResourceSingleton("datafeeder/conf")->getValue($site."/siteName");
|
64 |
+
if(!isset($this->key) || $this->key == "" || $this->key == "empty"){
|
65 |
+
$this->log("api key not set");
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
if(!isset($this->siteName) || $this->siteName == "" || $this->siteName == "empty"){
|
69 |
+
$this->log("site Name not set");
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
return true;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* method to validate whether the site exists or not
|
77 |
+
**/
|
78 |
+
public function validateSite($site){
|
79 |
+
$sites=Mage::app()->getWebsites();
|
80 |
+
if( !isset($site) || $site == "") {
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
foreach( $sites as $eachSite){
|
84 |
+
if(strcasecmp ( $eachSite->getName(), $site ) == 0 ){
|
85 |
+
return $eachSite->getWebsiteId();
|
86 |
+
}
|
87 |
+
}
|
88 |
+
return -1;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* method to initiate feed uploading to the unbxd servers
|
93 |
+
**/
|
94 |
+
public function process($fromdate,$site,$operation = "add", $ids=array()){
|
95 |
+
|
96 |
+
$this->log('unbxd Datafeeder initiated');
|
97 |
+
// validatest the site
|
98 |
+
if($this->validateSite($site) == -1){
|
99 |
+
$this->log("Invalid site Name".$site);
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
// set the basic
|
103 |
+
if(! $this->init($site)){
|
104 |
+
return;
|
105 |
+
}
|
106 |
+
$todate =date('Y-m-d H:i:s');
|
107 |
+
|
108 |
+
// check the lock, that if already indexing is happening
|
109 |
+
if($this->checkSiteLock($site)){
|
110 |
+
$this->log('site '. $site.' has been locked');
|
111 |
+
$action=$site.'/status';
|
112 |
+
// lock the feed
|
113 |
+
Mage::getResourceSingleton("datafeeder/conf")->updateAction($action,'1');
|
114 |
+
// create the feed
|
115 |
+
|
116 |
+
$status=Mage::getSingleton('unbxd_datafeeder/feed_feedcreator')
|
117 |
+
->createFeed($this->fileName, $fromdate,$todate,$site,$operation,$ids);
|
118 |
+
$this->log('unbxd Datafeeder finished creating file');
|
119 |
+
|
120 |
+
if($status){
|
121 |
+
try{
|
122 |
+
// if successful push it to unbxd servers
|
123 |
+
$status=$this->pushFeed($site);
|
124 |
+
}catch(Exception $e){
|
125 |
+
$this->log($e->getMessage());
|
126 |
+
|
127 |
+
}
|
128 |
+
if($status){
|
129 |
+
Mage::getResourceSingleton("datafeeder/conf")->updateAction('Lastindex',$todate);
|
130 |
+
}
|
131 |
+
}
|
132 |
+
// unlock the feed once everything is completed
|
133 |
+
Mage::getResourceSingleton("datafeeder/conf")->updateAction($action,'0');
|
134 |
+
$this->log('site '. $site.' has been unlocked');
|
135 |
+
} else {
|
136 |
+
$this->log('Feed Uploading failed because site has been locked');
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* method to check the status of the uploading
|
142 |
+
**/
|
143 |
+
public function checkSiteLock($site)
|
144 |
+
{
|
145 |
+
$value = Mage::getResourceSingleton("datafeeder/conf")->getValue($site."/status");
|
146 |
+
if($value == '0' || $value == 'empty'){
|
147 |
+
$this->log("true");
|
148 |
+
return true;
|
149 |
+
}else{
|
150 |
+
$this->log("false". $value);
|
151 |
+
return false;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
public function log($message) {
|
156 |
+
Mage::getSingleton('unbxd_datafeeder/feed_filemanager')->log($message);
|
157 |
+
}
|
158 |
+
}
|
159 |
+
?>
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Filemanager.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Unbxd_Datafeeder_Model_Feed_Filemanager {
|
4 |
+
|
5 |
+
|
6 |
+
var $logFileName;
|
7 |
+
|
8 |
+
public function __construct(){
|
9 |
+
$this->logFileName = Mage::getBaseDir('log').DS.'generic.log';
|
10 |
+
}
|
11 |
+
|
12 |
+
public function setLog($logFileName) {
|
13 |
+
$this->logFileName = Mage::getBaseDir('log').DS.$logFileName;
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Function to create a file
|
18 |
+
*/
|
19 |
+
public function createFile($file){
|
20 |
+
try{
|
21 |
+
$f=fopen($file,'w');
|
22 |
+
|
23 |
+
fclose($f);
|
24 |
+
if(!file_exists($file)) {
|
25 |
+
$this->log("UNBXD_MODULE:Couldn't create the file");
|
26 |
+
return false;
|
27 |
+
}
|
28 |
+
$this->log("UNBXD_MODULE: created the file");
|
29 |
+
return true;
|
30 |
+
} catch (Exception $ex) {
|
31 |
+
$this->log("UNBXD_MODULE:Error while creating the file");
|
32 |
+
$this->log($ex->getMessage());
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Function to append the contents to the file
|
39 |
+
*/
|
40 |
+
public function appendTofile($fileName, $content){
|
41 |
+
try {
|
42 |
+
if(file_put_contents($fileName, $content, FILE_APPEND)) {
|
43 |
+
return true;
|
44 |
+
} else {
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
} catch(Exception $ex) {
|
48 |
+
$this->log("UNBXD_MODULE:Error while appending the contents to feed file");
|
49 |
+
$this->log($ex->getMessage());
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Function to appened the contents to the file
|
56 |
+
*/
|
57 |
+
public function log($content){
|
58 |
+
try{
|
59 |
+
$resp = file_put_contents($this->logFileName, date('Y-m-d H:i:s').$content."\n", FILE_APPEND);
|
60 |
+
if($resp){
|
61 |
+
return true;
|
62 |
+
} else {
|
63 |
+
error_log("UNBXD_MODULE:Error while appending the contents to log file");
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
return true;
|
67 |
+
}catch(Exception $ex) {
|
68 |
+
error_log("UNBXD_MODULE:Error while appending the contents to log file");
|
69 |
+
Mage::throwException($ex->getMessage());
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
?>
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Jsonbuilder.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Jsonbuilder {
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
}
|
8 |
+
|
9 |
+
?>
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Productbuilder.php
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Productbuilder extends Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Jsonbuilder {
|
4 |
+
|
5 |
+
const DATA_TYPE = "dataType";
|
6 |
+
const MULTIVALUED = "multiValued";
|
7 |
+
const NUMBER = "number";
|
8 |
+
const DECIMAL = "decimal";
|
9 |
+
const DATE = "date";
|
10 |
+
const IMAGE_HEIGHT = "image_height";
|
11 |
+
const IMAGE_WIDTH = "image_width";
|
12 |
+
const GENERATE_IMAGE = "generate_image";
|
13 |
+
|
14 |
+
public function getProducts($collection, $fields) {
|
15 |
+
$content='';
|
16 |
+
$firstLoop = true;
|
17 |
+
foreach($collection as $product) {
|
18 |
+
if(!$firstLoop) {
|
19 |
+
$content = $content . ",";
|
20 |
+
}
|
21 |
+
|
22 |
+
$productArray = $this->getProduct($product, $fields);
|
23 |
+
$productArray = $this->postProcessProduct($productArray, $fields, false);
|
24 |
+
$content=$content.json_encode($productArray);
|
25 |
+
|
26 |
+
$firstLoop = false;
|
27 |
+
}
|
28 |
+
|
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 |
+
if($childProduct) {
|
39 |
+
$unbxdFieldName = $columnHeader . "Associated";
|
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 |
+
|
53 |
+
if($columnHeader=="entity_id"){
|
54 |
+
$productArray['uniqueId'] = $columndata;
|
55 |
+
}
|
56 |
+
|
57 |
+
if($columnHeader=="url_path"){
|
58 |
+
// handling the url
|
59 |
+
$productArray['url_path'.($childProduct?"Associated":"")] = Mage::getUrl('').$columndata;
|
60 |
+
} else if (Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->isImage($columnHeader)) {
|
61 |
+
if($fields[$unbxdFieldName][self::GENERATE_IMAGE] == "1") {
|
62 |
+
try {
|
63 |
+
$productArray[$unbxdFieldName] = (string)Mage::helper('catalog/image')->init($product, $columnHeader)
|
64 |
+
->resize($fields[$unbxdFieldName][self::IMAGE_WIDTH],$fields[$unbxdFieldName][self::IMAGE_HEIGHT]);
|
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 |
+
$data = explode(",", $columndata);
|
75 |
+
$attributeModel = Mage::getResourceSingleton("datafeeder/attribute");
|
76 |
+
foreach( $data as $eachdata){
|
77 |
+
$attributeValue = $attributeModel ->getAttributeValue($columnHeader, trim($eachdata), $product);
|
78 |
+
$valueArray = array();;
|
79 |
+
$valueArray[] = $attributeModel ->getAttributeValue($columnHeader, trim($eachdata), $product);
|
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 |
+
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
|
112 |
+
foreach ($simple_collection as $sp)
|
113 |
+
{
|
114 |
+
$childProduct = $this->getProduct($sp, $fields, true);
|
115 |
+
$childProduct = $this->postProcessProduct($childProduct, $fields, true);
|
116 |
+
$associatedProducts[] = $childProduct;
|
117 |
+
}
|
118 |
+
|
119 |
+
$productArray["associatedProducts"] = $associatedProducts;
|
120 |
+
return $productArray;
|
121 |
+
} else {
|
122 |
+
return $productArray;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
public function postProcessProduct($product, $fields, $childExists=false) {
|
127 |
+
if($childExists) {
|
128 |
+
$product = $this->convertMultivalued($product);
|
129 |
+
} else {
|
130 |
+
$product = $this->convertMultivalued($product, $fields);
|
131 |
+
}
|
132 |
+
$product = $this->convertDataType($product, $fields, $childExists);
|
133 |
+
return $product;
|
134 |
+
}
|
135 |
+
|
136 |
+
public function convertDataType($product, $fields, $childExists) {
|
137 |
+
foreach($product as $field => $value) {
|
138 |
+
if($field != "associatedProducts") {
|
139 |
+
$product[$field] = $this->convertDataTypeByValue($fields[$field], $fieldName, $value);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
return $product;
|
143 |
+
}
|
144 |
+
|
145 |
+
public function convertDataTypeByValue($data_type, $fieldName, $value) {
|
146 |
+
if($data_type[self::DATA_TYPE] == self::DECIMAL) {
|
147 |
+
if(is_array($value)) {
|
148 |
+
$valueAsAnArray = array();
|
149 |
+
foreach ($value as $eachValue) {
|
150 |
+
$valueAsAnArray[] = floatval($eachValue);
|
151 |
+
}
|
152 |
+
return $valueAsAnArray;
|
153 |
+
} else {
|
154 |
+
return floatval($value);
|
155 |
+
}
|
156 |
+
} else if ($data_type[self::DATA_TYPE] == self::NUMBER) {
|
157 |
+
if(is_array($value)) {
|
158 |
+
$valueAsAnArray = array();
|
159 |
+
foreach ($value as $eachValue) {
|
160 |
+
$valueAsAnArray[] = intval($eachValue);
|
161 |
+
}
|
162 |
+
return $valueAsAnArray;
|
163 |
+
} else {
|
164 |
+
return intval($value);
|
165 |
+
}
|
166 |
+
} else if ($data_type[self::DATA_TYPE] == self::DATE) {
|
167 |
+
$tokens = explode(" ",$value);
|
168 |
+
$value = $tokens[0].'T'.$tokens[1].'Z';
|
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]))
|
177 |
+
&& !is_array($value) && ($field != "associatedProducts")) {
|
178 |
+
$valueAsAnArray = array();
|
179 |
+
$valueAsAnArray[] = $value;
|
180 |
+
$product[$field] = $valueAsAnArray;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
return $product;
|
184 |
+
}
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
?>
|
app/code/local/Unbxd/Datafeeder/Model/Feed/Jsonbuilder/Schemabuilder.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Schemabuilder extends Unbxd_Datafeeder_Model_Feed_Jsonbuilder_Jsonbuilder {
|
4 |
+
|
5 |
+
|
6 |
+
const SCHEMA = 'schema';
|
7 |
+
const FIELD_NAME = "fieldName";
|
8 |
+
const DATA_TYPE = "dataType";
|
9 |
+
const MULTIVALUED = "multiValued";
|
10 |
+
const AUTOSUGGEST = "autoSuggest";
|
11 |
+
const TRUE = "true";
|
12 |
+
const FALSE = "false";
|
13 |
+
|
14 |
+
const FIELD_STATUS = 'status';
|
15 |
+
const FIELD_DATA_TYPE = 'data_type';
|
16 |
+
const FIELD_AUTOSUGGEST = 'autosuggest';
|
17 |
+
|
18 |
+
public function getSchema($fields) {
|
19 |
+
$jsonString = "";
|
20 |
+
$fieldList = array();
|
21 |
+
$featuredFields = Mage::getResourceSingleton("datafeeder/field")->getFeaturedFields();
|
22 |
+
foreach($fields as $fieldName=>$values ) {
|
23 |
+
if($values[self::FIELD_STATUS] == 1 || !array_key_exists($fieldName, $featuredFields) ) {
|
24 |
+
$fieldList[] = array(self::FIELD_NAME => $fieldName,
|
25 |
+
self::DATA_TYPE => $values[self::FIELD_DATA_TYPE],
|
26 |
+
self::MULTIVALUED => ($this->endsWith($fieldName, "Associated")?self::TRUE:(Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->isMultiSelect(($fieldName == "_gender")?"gender":$fieldName)?
|
27 |
+
self::TRUE:self::FALSE)),
|
28 |
+
self::AUTOSUGGEST => ($values[self::FIELD_AUTOSUGGEST] == 1?
|
29 |
+
self::TRUE: self::FALSE));
|
30 |
+
}
|
31 |
+
}
|
32 |
+
return json_encode($fieldList);
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
function endsWith($haystack, $needle)
|
37 |
+
{
|
38 |
+
return $needle === "" || substr($haystack, -strlen($needle)) === $needle;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
?>
|
app/code/local/Unbxd/Datafeeder/Model/Mysql4/Field.php
CHANGED
@@ -2,6 +2,18 @@
|
|
2 |
|
3 |
class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstract
|
4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
protected function _construct()
|
6 |
{
|
7 |
$this->_init('datafeeder/field', 'field_id');
|
@@ -10,19 +22,29 @@ class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstrac
|
|
10 |
/*
|
11 |
* Method to get Unbxd Fields Configuration as Mapping give the site
|
12 |
*/
|
13 |
-
public function getFieldMapping($site) {
|
14 |
-
$results = Mage::getModel('datafeeder/field')->getCollection()->addFieldToFilter(
|
15 |
$fieldMapping = [];
|
16 |
$_reader = Mage::getSingleton('core/resource')->getConnection('core_read');
|
17 |
-
$table = $_reader->getTableName(
|
18 |
$select = $_reader->select();
|
19 |
$select->from($table);
|
20 |
-
$
|
|
|
|
|
|
|
21 |
|
|
|
22 |
$results = $_reader->fetchAll($select);
|
23 |
|
24 |
foreach($results as $eachResult) {
|
25 |
-
$fieldMapping[$eachResult[
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
return $fieldMapping;
|
28 |
}
|
@@ -35,10 +57,28 @@ class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstrac
|
|
35 |
$deltaUpdate =[];
|
36 |
$attributes = Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->getAttributes();
|
37 |
foreach($attributes as $attribute){
|
38 |
-
|
39 |
-
|
40 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
if(sizeof($deltaUpdate) > 0) {
|
44 |
$this->saveField($deltaUpdate, $site);
|
@@ -51,8 +91,20 @@ class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstrac
|
|
51 |
*/
|
52 |
public function updateFields($fieldMapping, $site) {
|
53 |
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
54 |
-
foreach($fieldMapping as $fieldName=>$
|
55 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
}
|
58 |
|
@@ -64,31 +116,59 @@ class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstrac
|
|
64 |
$insertingRequestArray = [];
|
65 |
foreach($fieldMapping as $field=>$value) {
|
66 |
$insertingRequest = [];
|
67 |
-
$insertingRequest[
|
68 |
-
$insertingRequest[
|
69 |
-
$insertingRequest[
|
|
|
|
|
|
|
|
|
|
|
70 |
$insertingRequestArray[] = $insertingRequest;
|
71 |
}
|
72 |
|
73 |
-
$write->insertMultiple($write->getTableName(
|
74 |
}
|
75 |
|
76 |
/*
|
77 |
-
* method to get
|
78 |
*/
|
79 |
-
public function
|
80 |
-
$
|
81 |
-
$
|
82 |
-
$
|
83 |
-
$
|
84 |
-
$
|
85 |
-
$
|
86 |
-
$
|
87 |
-
$
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
}
|
93 |
}
|
94 |
-
?>
|
2 |
|
3 |
class Unbxd_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstract
|
4 |
{
|
5 |
+
|
6 |
+
const STATUS = 'status';
|
7 |
+
const DATA_TYPE = 'data_type';
|
8 |
+
const SITE = 'site';
|
9 |
+
const FIELD_NAME = "name";
|
10 |
+
const TABLE_NAME = 'unbxd_field';
|
11 |
+
const AUTOSUGGEST = 'autosuggest';
|
12 |
+
const MULTIVALUED = 'multiValued';
|
13 |
+
const IMAGE_HEIGHT = "image_height";
|
14 |
+
const IMAGE_WIDTH = "image_width";
|
15 |
+
const GENERATE_IMAGE = "generate_image";
|
16 |
+
|
17 |
protected function _construct()
|
18 |
{
|
19 |
$this->_init('datafeeder/field', 'field_id');
|
22 |
/*
|
23 |
* Method to get Unbxd Fields Configuration as Mapping give the site
|
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 |
+
$table = $_reader->getTableName(self::TABLE_NAME);
|
30 |
$select = $_reader->select();
|
31 |
$select->from($table);
|
32 |
+
$filterCond = self::SITE . " = '" . $site . "'";
|
33 |
+
if($enabledFields) {
|
34 |
+
$filterCond = $filterCond . " AND " . self::STATUS ."='1'";
|
35 |
+
}
|
36 |
|
37 |
+
$select->where($filterCond);
|
38 |
$results = $_reader->fetchAll($select);
|
39 |
|
40 |
foreach($results as $eachResult) {
|
41 |
+
$fieldMapping[$eachResult[self::FIELD_NAME]] = array(self::STATUS => $eachResult[self::STATUS],
|
42 |
+
self::DATA_TYPE => $eachResult[self::DATA_TYPE],
|
43 |
+
self::AUTOSUGGEST => $eachResult[self::AUTOSUGGEST],
|
44 |
+
self::IMAGE_HEIGHT =>$eachResult[self::IMAGE_HEIGHT],
|
45 |
+
self::IMAGE_WIDTH => $eachResult[self::IMAGE_WIDTH],
|
46 |
+
self::GENERATE_IMAGE =>$eachResult[self::GENERATE_IMAGE]
|
47 |
+
);
|
48 |
}
|
49 |
return $fieldMapping;
|
50 |
}
|
57 |
$deltaUpdate =[];
|
58 |
$attributes = Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->getAttributes();
|
59 |
foreach($attributes as $attribute){
|
60 |
+
$fieldName = $attribute->getAttributeCode();
|
61 |
+
if ($fieldName == "gender") {
|
62 |
+
$fieldName = "_gender";
|
63 |
+
}
|
64 |
+
if (!array_key_exists($fieldName, $fieldMapping)) {
|
65 |
+
$deltaUpdate[$fieldName] = array(self::STATUS => 1, self::DATA_TYPE => 'longText');
|
66 |
+
$fieldMapping[$fieldName] = array(self::STATUS => 1,
|
67 |
+
self::DATA_TYPE => 'longText',
|
68 |
+
self::AUTOSUGGEST => 1,
|
69 |
+
self::IMAGE_HEIGHT => 0,
|
70 |
+
self::IMAGE_WIDTH =>0,
|
71 |
+
self::GENERATE_IMAGE =>0);
|
72 |
}
|
73 |
+
if(!array_key_exists($fieldName."Associated", $fieldMapping)) {
|
74 |
+
$deltaUpdate[$fieldName."Associated"] = array(self::STATUS => 0, self::DATA_TYPE => 'longText');
|
75 |
+
$fieldMapping[$fieldName."Associated"] = array(self::STATUS => 0,
|
76 |
+
self::DATA_TYPE => 'longText',
|
77 |
+
self::AUTOSUGGEST => 1,
|
78 |
+
self::IMAGE_HEIGHT => 0,
|
79 |
+
self::IMAGE_WIDTH =>0,
|
80 |
+
self::GENERATE_IMAGE =>0);
|
81 |
+
}
|
82 |
}
|
83 |
if(sizeof($deltaUpdate) > 0) {
|
84 |
$this->saveField($deltaUpdate, $site);
|
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 |
+
$write->update($write->getTableName(self::TABLE_NAME),
|
101 |
+
array(self::STATUS => $values[self::STATUS],
|
102 |
+
self::DATA_TYPE => $values[self::DATA_TYPE],
|
103 |
+
self::AUTOSUGGEST => $values[self::AUTOSUGGEST],
|
104 |
+
self::IMAGE_HEIGHT => $values[self::IMAGE_HEIGHT],
|
105 |
+
self::IMAGE_WIDTH =>$values[self::IMAGE_WIDTH],
|
106 |
+
self::GENERATE_IMAGE =>$values[self::GENERATE_IMAGE]),
|
107 |
+
self::SITE . "='". $site . "' AND " . self::FIELD_NAME . "='".$fieldName."'");
|
108 |
}
|
109 |
}
|
110 |
|
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;
|
122 |
+
$insertingRequest[self::DATA_TYPE] = $value[self::DATA_TYPE];
|
123 |
+
$insertingRequest[self::AUTOSUGGEST] = $value[self::AUTOSUGGEST];
|
124 |
+
$insertingRequest[self::IMAGE_HEIGHT] = $value[self::IMAGE_HEIGHT];
|
125 |
+
$insertingRequest[self::IMAGE_WIDTH] = $value[self::IMAGE_WIDTH];
|
126 |
+
$insertingRequest[self::GENERATE_IMAGE] = $value[self::GENERATE_IMAGE];
|
127 |
$insertingRequestArray[] = $insertingRequest;
|
128 |
}
|
129 |
|
130 |
+
$write->insertMultiple($write->getTableName(self::TABLE_NAME), $insertingRequestArray);
|
131 |
}
|
132 |
|
133 |
/*
|
134 |
+
* method to get the featured fields
|
135 |
*/
|
136 |
+
public function getFeaturedFields() {
|
137 |
+
$featuredFields = array();
|
138 |
+
$featuredFields["uniqueId"]=$this->getField("text", "false", "false");
|
139 |
+
$featuredFields["sellingPrice"]=$this->getField("decimal", "false", "false");
|
140 |
+
$featuredFields["discount"]=$this->getField("decimal", "false", "false");
|
141 |
+
$featuredFields["rating"]=$this->getField("decimal", "false", "false");
|
142 |
+
$featuredFields["brandId"]=$this->getField("text", "false", "false");
|
143 |
+
$featuredFields["catlevel1Name"]=$this->getField("text", "false", "false");
|
144 |
+
$featuredFields["catlevel2Name"]=$this->getField("text", "false", "false");
|
145 |
+
$featuredFields["catlevel3Name"]=$this->getField("text", "false", "false");
|
146 |
+
$featuredFields["catlevel4Name"]=$this->getField("text", "false", "false");
|
147 |
+
$featuredFields["catlevel1Id"]=$this->getField("text", "false", "false");
|
148 |
+
$featuredFields["catlevel2Id"]=$this->getField("text", "false", "false");
|
149 |
+
$featuredFields["catlevel3Id"]=$this->getField("text", "false", "false");
|
150 |
+
$featuredFields["catlevel4Id"]=$this->getField("text", "false", "false");
|
151 |
+
$featuredFields["category"]=$this->getField("text", "true", "true");
|
152 |
+
$featuredFields["subCategory"]=$this->getField("text", "true", "true");
|
153 |
+
$featuredFields["color"]=$this->getField("text", "true", "false");
|
154 |
+
$featuredFields["size"]=$this->getField("text", "true", "false");
|
155 |
+
$featuredFields["availability"]=$this->getField("bool", "false", "false");
|
156 |
+
$featuredFields["description"]=$this->getField("longText", "false", "false");
|
157 |
+
$featuredFields["imageUrl"]=$this->getField("link", "true", "false");
|
158 |
+
$featuredFields["productUrl"]=$this->getField("link", "false", "false");
|
159 |
+
$featuredFields["brand"]=$this->getField("text", "false", "true");
|
160 |
+
$featuredFields["price"]=$this->getField("decimal", "false", "false");
|
161 |
+
$featuredFields["title"]=$this->getField("text", "false", "true");
|
162 |
+
$featuredFields["gender"]=$this->getField("text", "false", "false");
|
163 |
+
$featuredFields["unbxdVisibility"]=$this->getField("text", "false", "false");
|
164 |
+
return $featuredFields;
|
165 |
+
}
|
166 |
+
|
167 |
+
private function getField($dataType, $multiValued, $autosuggest) {
|
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 |
+
?>
|
app/code/local/Unbxd/Datafeeder/controllers/FieldController.php
CHANGED
@@ -8,23 +8,43 @@ class Unbxd_Datafeeder_FieldController extends Mage_Core_Controller_Front_Actio
|
|
8 |
public function configAction() {
|
9 |
$site=$this->getRequest()->getParam("site");
|
10 |
if(!isset($site)){
|
11 |
-
|
|
|
12 |
}
|
13 |
$fields = Mage::getResourceSingleton(self::FIELD_MODEL)->getFields($site);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
echo json_encode($fields);
|
15 |
}
|
16 |
|
17 |
public function saveAction()
|
18 |
{
|
19 |
$params=$this->getRequest()->getParams();
|
20 |
-
if(!isset($params
|
21 |
-
echo json_encode(array("success"=>"false", "message"=>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
return;
|
23 |
}
|
24 |
-
$site = $params["site_name"];
|
25 |
-
unset($params["site_name"]);
|
26 |
-
unset($params["form_key"]);
|
27 |
-
$fields = Mage::getResourceSingleton(self::FIELD_MODEL)->updateFields($params,$site);
|
28 |
echo json_encode(array("success"=>"true"));
|
29 |
}
|
30 |
}
|
8 |
public function configAction() {
|
9 |
$site=$this->getRequest()->getParam("site");
|
10 |
if(!isset($site)){
|
11 |
+
echo '{"failed": "no site sent"}';
|
12 |
+
return;
|
13 |
}
|
14 |
$fields = Mage::getResourceSingleton(self::FIELD_MODEL)->getFields($site);
|
15 |
+
foreach ($fields as $field => $value) {
|
16 |
+
if (Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper')->isImage($field)) {
|
17 |
+
|
18 |
+
$value["is_image"] = "true";
|
19 |
+
$fields[$field] = $value;
|
20 |
+
}
|
21 |
+
}
|
22 |
echo json_encode($fields);
|
23 |
}
|
24 |
|
25 |
public function saveAction()
|
26 |
{
|
27 |
$params=$this->getRequest()->getParams();
|
28 |
+
if(!isset($params) || count($params) == 0) {
|
29 |
+
echo json_encode(array("success"=>"false", "message"=>"No Fields Passed"));
|
30 |
+
return;
|
31 |
+
}
|
32 |
+
$singleProductData = json_decode(reset($params), true);
|
33 |
+
if(!isset($singleProductData)) {
|
34 |
+
echo json_encode(array("success"=>"false", "message"=>"Improper Data format"));
|
35 |
+
return;
|
36 |
+
}
|
37 |
+
$site = $singleProductData["site_name"];
|
38 |
+
if (!isset($site)) {
|
39 |
+
echo json_encode(array("success"=>"false", "message"=>"site needed"));
|
40 |
+
return;
|
41 |
+
}
|
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 |
}
|
|
|
|
|
|
|
|
|
48 |
echo json_encode(array("success"=>"true"));
|
49 |
}
|
50 |
}
|
app/code/local/Unbxd/Datafeeder/controllers/IndexController.php
CHANGED
@@ -27,7 +27,6 @@ class Unbxd_Datafeeder_IndexController extends Mage_Adminhtml_Controller_Action
|
|
27 |
|
28 |
public function indexAction()
|
29 |
{
|
30 |
-
error_log("index actions");
|
31 |
$this->loadLayout();
|
32 |
$this->_addContent($this->getLayout()->createBlock('unbxd_datafeeder/index')->setTemplate('datafeeder/conf.phtml'));
|
33 |
$this->renderLayout();
|
@@ -37,7 +36,8 @@ class Unbxd_Datafeeder_IndexController extends Mage_Adminhtml_Controller_Action
|
|
37 |
$_helper=Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper');
|
38 |
$fromdate="1970-01-01 00:00:00";
|
39 |
$site=$this->getRequest()->getPost("site");
|
40 |
-
|
|
|
41 |
echo "Done";
|
42 |
}
|
43 |
|
@@ -58,4 +58,4 @@ class Unbxd_Datafeeder_IndexController extends Mage_Adminhtml_Controller_Action
|
|
58 |
$_helper->indexUnbxdFeed($fromdate,$site);
|
59 |
echo "Done";
|
60 |
}
|
61 |
-
} ?>
|
27 |
|
28 |
public function indexAction()
|
29 |
{
|
|
|
30 |
$this->loadLayout();
|
31 |
$this->_addContent($this->getLayout()->createBlock('unbxd_datafeeder/index')->setTemplate('datafeeder/conf.phtml'));
|
32 |
$this->renderLayout();
|
36 |
$_helper=Mage::helper('unbxd_datafeeder/UnbxdIndexingHelper');
|
37 |
$fromdate="1970-01-01 00:00:00";
|
38 |
$site=$this->getRequest()->getPost("site");
|
39 |
+
//$_helper->indexUnbxdFeed($fromdate,$site);
|
40 |
+
Mage::getSingleton('unbxd_datafeeder/feed_feedmanager')->process($fromdate,$site);
|
41 |
echo "Done";
|
42 |
}
|
43 |
|
58 |
$_helper->indexUnbxdFeed($fromdate,$site);
|
59 |
echo "Done";
|
60 |
}
|
61 |
+
} ?>
|
app/code/local/Unbxd/Datafeeder/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Unbxd_Datafeeder>
|
5 |
-
<version>
|
6 |
</Unbxd_Datafeeder>
|
7 |
</modules>
|
8 |
<frontend>
|
@@ -90,7 +90,7 @@
|
|
90 |
<table>unbxd_datafeeder_conf</table>
|
91 |
</conf>
|
92 |
<field>
|
93 |
-
<table>
|
94 |
</field>
|
95 |
</entities>
|
96 |
</datafeeder_mysql4>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Unbxd_Datafeeder>
|
5 |
+
<version>1.0.5</version>
|
6 |
</Unbxd_Datafeeder>
|
7 |
</modules>
|
8 |
<frontend>
|
90 |
<table>unbxd_datafeeder_conf</table>
|
91 |
</conf>
|
92 |
<field>
|
93 |
+
<table>unbxd_field</table>
|
94 |
</field>
|
95 |
</entities>
|
96 |
</datafeeder_mysql4>
|
app/code/local/Unbxd/Datafeeder/sql/datafeeder_setup/mysql4-install-0.1.0.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
$installer = $this;
|
5 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
6 |
-
|
7 |
-
$installer->startSetup();
|
8 |
-
|
9 |
-
$installer->run("
|
10 |
-
|
11 |
-
DROP TABLE IF EXISTS `{$installer->getTable('unbxd_search_field')}`;
|
12 |
-
|
13 |
-
CREATE TABLE `{$installer->getTable('unbxd_search_field')}` (
|
14 |
-
`field_id` int(10) unsigned NOT NULL auto_increment,
|
15 |
-
`name` varchar(255) NOT NULL default '',
|
16 |
-
`status` varchar(255),
|
17 |
-
`site` varchar(255) NOT NULL default '',
|
18 |
-
PRIMARY KEY (`field_id`)
|
19 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
DROP TABLE IF EXISTS `{$installer->getTable('unbxd_datafeeder_conf')}`;
|
24 |
-
|
25 |
-
CREATE TABLE `{$installer->getTable('unbxd_datafeeder_conf')}` (
|
26 |
-
`uconfig_id` int(10) unsigned NOT NULL auto_increment,
|
27 |
-
`action` varchar(255) NOT NULL default '',
|
28 |
-
`value` varchar(255),
|
29 |
-
PRIMARY KEY (`uconfig_id`)
|
30 |
-
|
31 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
32 |
-
|
33 |
-
");
|
34 |
-
$installer->endSetup();
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Unbxd/Datafeeder/sql/datafeeder_setup/mysql4-install-1.0.5.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
$installer = $this;
|
5 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
6 |
+
|
7 |
+
$installer->startSetup();
|
8 |
+
|
9 |
+
$installer->run("
|
10 |
+
|
11 |
+
DROP TABLE IF EXISTS `{$installer->getTable('unbxd_field')}`;
|
12 |
+
|
13 |
+
CREATE TABLE `{$installer->getTable('unbxd_field')}` (
|
14 |
+
`field_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
15 |
+
`name` varchar(100) NOT NULL DEFAULT '',
|
16 |
+
`status` int(1) NOT NULL DEFAULT '1',
|
17 |
+
`site` varchar(100) NOT NULL DEFAULT '',
|
18 |
+
`data_type` varchar(20) NOT NULL DEFAULT 'longText',
|
19 |
+
`autosuggest` int(1) NOT NULL DEFAULT '0',
|
20 |
+
`image_height` int(5) NOT NULL DEFAULT '0',
|
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 AUTO_INCREMENT=1670 DEFAULT CHARSET=utf8;
|
25 |
+
|
26 |
+
DROP TABLE IF EXISTS `{$installer->getTable('unbxd_datafeeder_conf')}`;
|
27 |
+
|
28 |
+
CREATE TABLE `{$installer->getTable('unbxd_datafeeder_conf')}` (
|
29 |
+
`uconfig_id` int(10) unsigned NOT NULL auto_increment,
|
30 |
+
`action` varchar(255) NOT NULL default '',
|
31 |
+
`value` varchar(255),
|
32 |
+
PRIMARY KEY (`uconfig_id`)
|
33 |
+
|
34 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
35 |
+
|
36 |
+
");
|
37 |
+
$installer->endSetup();
|
38 |
+
|
39 |
+
|
app/code/local/Unbxd/Datafeeder/sql/datafeeder_setup/mysql4-upgrade-0.1.0-1.0.5.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
$installer = $this;
|
5 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
6 |
+
|
7 |
+
$installer->startSetup();
|
8 |
+
|
9 |
+
$installer->run("
|
10 |
+
|
11 |
+
DROP TABLE IF EXISTS `{$installer->getTable('unbxd_field')}`;
|
12 |
+
|
13 |
+
CREATE TABLE `{$installer->getTable('unbxd_field')}` (
|
14 |
+
`field_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
15 |
+
`name` varchar(100) NOT NULL DEFAULT '',
|
16 |
+
`status` int(1) NOT NULL DEFAULT '1',
|
17 |
+
`site` varchar(100) NOT NULL DEFAULT '',
|
18 |
+
`data_type` varchar(20) NOT NULL DEFAULT 'longText',
|
19 |
+
`autosuggest` int(1) NOT NULL DEFAULT '0',
|
20 |
+
`image_height` int(5) NOT NULL DEFAULT '0',
|
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 AUTO_INCREMENT=1670 DEFAULT CHARSET=utf8;
|
25 |
+
|
26 |
+
DROP TABLE IF EXISTS `{$installer->getTable('unbxd_datafeeder_conf')}`;
|
27 |
+
|
28 |
+
CREATE TABLE `{$installer->getTable('unbxd_datafeeder_conf')}` (
|
29 |
+
`uconfig_id` int(10) unsigned NOT NULL auto_increment,
|
30 |
+
`action` varchar(255) NOT NULL default '',
|
31 |
+
`value` varchar(255),
|
32 |
+
PRIMARY KEY (`uconfig_id`)
|
33 |
+
|
34 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
35 |
+
|
36 |
+
");
|
37 |
+
$installer->endSetup();
|
38 |
+
|
39 |
+
|
app/design/adminhtml/base/default/template/datafeeder/conf.phtml
CHANGED
@@ -10,6 +10,40 @@
|
|
10 |
.datafeeder-form input[type="text"] {
|
11 |
width: 300px;
|
12 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
</style>
|
14 |
<script type="text/javascript">
|
15 |
var $jq = jQuery.noConflict();
|
@@ -36,19 +70,10 @@
|
|
36 |
</p>
|
37 |
|
38 |
|
39 |
-
<table class="form-list" onload="allset()" id="form-
|
40 |
<div class="datafeeder-form" width="parent" style="background:none repeat scroll 0 0 #6F8992;padding:5px 10px; color: white;">
|
41 |
FEED CONFIGURATION
|
42 |
</div>
|
43 |
-
<tr>
|
44 |
-
<td class="label">
|
45 |
-
<b>Unbxd Site Name: </b>
|
46 |
-
</td>
|
47 |
-
<td class="value">
|
48 |
-
<input type="text" id="feedName" name="feedName" value="" disabled/>
|
49 |
-
</td>
|
50 |
-
</tr>
|
51 |
-
</tr>
|
52 |
<tr>
|
53 |
<td class="label">
|
54 |
<b>Unbxd Site Key: </b>
|
@@ -106,7 +131,6 @@
|
|
106 |
}
|
107 |
|
108 |
function newajaxcall(ajaxurl){
|
109 |
-
//createTable('<?php echo $this->getEditUrl();?>');
|
110 |
$jq.ajax({
|
111 |
|
112 |
url: ajaxurl,
|
@@ -121,8 +145,6 @@
|
|
121 |
|
122 |
if(data.feed !== "empty") $jq('[name=feedName]').val(data.feed); else $jq('[name=feedName]').val("");
|
123 |
if(data.feed !== "empty") $jq('[name=siteName]').val(data.siteName); else $jq('[name=siteName]').val("");
|
124 |
-
|
125 |
-
|
126 |
},
|
127 |
|
128 |
fail: function(XMLHttpRequest, textStatus, errorThrown) {
|
@@ -155,21 +177,214 @@
|
|
155 |
});
|
156 |
}
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
setInterval(progressbar,10000);
|
159 |
</script>
|
160 |
|
161 |
|
162 |
-
<table class="form-list" width="parent" id="form-
|
163 |
<div class="datafeeder-form" width="parent" style="background:none repeat scroll 0 0 #6F8992;padding:5px 10px;color: white;">
|
164 |
<div class="refreshDiv" style="float: right;"><span id="ProgressBar"></span><input type="button" id="refresh" onclick="progressbar()" value="REFRESH" style="margin-left: 10px;vertical-align: top;"></div>
|
165 |
<b>UPLOAD & INDEX (manual)</b>
|
166 |
</div>
|
167 |
-
|
168 |
-
<tr>
|
169 |
-
<td class="label"><b>TAXONOMY UPLOAD: </b></td>
|
170 |
-
<td class="value"><input type="button" id="taxonomyupload" onclick="makeajaxcall('<?php echo $this->getTaxonomyUploadFormAction(); ?>')" value="START"/></td>
|
171 |
-
</tr>
|
172 |
-
|
173 |
|
174 |
<tr>
|
175 |
<td class="label"><b>PRODUCT FEED UPLOAD: </b></td>
|
@@ -185,47 +400,6 @@
|
|
185 |
<frame name="login_frame"></frame>
|
186 |
</frameset>
|
187 |
|
188 |
-
<!-- FIELD CONFIGURATION -->
|
189 |
-
<script type="text/javascript">
|
190 |
-
$jq('#config_edit_form').ready(function(){
|
191 |
-
createTable('<?php echo $this->getEditUrl();?>');
|
192 |
-
});
|
193 |
-
|
194 |
-
function formSubmit()
|
195 |
-
{
|
196 |
-
$jq('[name=site_name]').val($jq('[name=site]').val());
|
197 |
-
$jq('#config_edit_form').ajaxSubmit();
|
198 |
-
}
|
199 |
-
|
200 |
-
function createTable(ajaxurl)
|
201 |
-
{
|
202 |
-
site= $jq("#site").val();
|
203 |
-
$jq.ajax({
|
204 |
-
url: ajaxurl,
|
205 |
-
type:"POST",
|
206 |
-
data:{"site":site},
|
207 |
-
}).done( function(data) {
|
208 |
-
jarray = $jq.parseJSON(data);
|
209 |
-
tableString="<tbody>";
|
210 |
-
$jq("#field-list").find("tr").remove();
|
211 |
-
$jq.each(jarray, function(key, value) {
|
212 |
-
tableString+='<tr><td class="label">'+key+"</td>"+'<td class="value">'+'<select name="'+key+'">'+"<option";
|
213 |
-
if(value=="0"){
|
214 |
-
tableString+=' selected="selected"';
|
215 |
-
}
|
216 |
-
tableString+=' value="0">Disabled</option><option';
|
217 |
-
if(value!="0"){
|
218 |
-
tableString+=' selected="selected"';
|
219 |
-
}
|
220 |
-
tableString+=' value="1">Enabled</option></select></td>';
|
221 |
-
tableString+='<td class="scope-label"></td><td class=""></td></tr>'
|
222 |
-
});
|
223 |
-
tableString+="</tbody>";
|
224 |
-
$jq('#field-list').append(tableString)
|
225 |
-
});
|
226 |
-
}
|
227 |
-
</script>
|
228 |
-
|
229 |
<div class="editconfig">
|
230 |
<div class="content-header">
|
231 |
<table cellspacing="0">
|
@@ -237,7 +411,7 @@
|
|
237 |
</h3>
|
238 |
</td>
|
239 |
<td class="form-buttons">
|
240 |
-
<input type="button" style='background:url("images/btn_bg.gif") repeat-x scroll 0 100% #FFAC47;border-color:#ED6502 #A04300 #A04300 #ED6502;border-style:solid;border-width:1px;color:#FFFFFF;font:bold 12px arial,helvetica,sans-serif;text-align:center !important;white-space:nowrap;padding: 3px;' onclick="
|
241 |
</td>
|
242 |
</tr>
|
243 |
</table>
|
@@ -253,7 +427,7 @@
|
|
253 |
</p>
|
254 |
|
255 |
<table class="form-list" id="field-list" name="form-list" cellspacing="0" style="color: #2F2F2F;
|
256 |
-
font: 12px/1.5em Arial,Helvetica,sans-serif; margin-left:
|
257 |
</table>
|
258 |
|
259 |
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
10 |
.datafeeder-form input[type="text"] {
|
11 |
width: 300px;
|
12 |
}
|
13 |
+
|
14 |
+
.fieldRowSelected {
|
15 |
+
background-color: #45b5c1;
|
16 |
+
}
|
17 |
+
|
18 |
+
.text_td {
|
19 |
+
padding-top: 6px;
|
20 |
+
width: 117px;
|
21 |
+
}
|
22 |
+
|
23 |
+
.plus {
|
24 |
+
background:url('http://unbxd.com/img/CircledPlus.png') no-repeat;
|
25 |
+
height: 24px;
|
26 |
+
width: 24px;
|
27 |
+
}
|
28 |
+
|
29 |
+
.minus {
|
30 |
+
background:url('http://unbxd.com/img/CircledMinus.png') no-repeat;
|
31 |
+
height: 24px;
|
32 |
+
width: 24px;
|
33 |
+
}
|
34 |
+
|
35 |
+
.hidden_image_textBox {
|
36 |
+
display: none;
|
37 |
+
}
|
38 |
+
|
39 |
+
.form-list td.value select {
|
40 |
+
width: 110px;
|
41 |
+
}
|
42 |
+
|
43 |
+
#field-list td {
|
44 |
+
width: 120px;
|
45 |
+
}
|
46 |
+
|
47 |
</style>
|
48 |
<script type="text/javascript">
|
49 |
var $jq = jQuery.noConflict();
|
70 |
</p>
|
71 |
|
72 |
|
73 |
+
<table class="form-list" onload="allset()" id="form-list1" name="form-list" cellspacing="0" style="background:none repeat scroll 0 0 #FAFAFA;border=1px solid #D6D6D6;width: 100%;" width="5000px">
|
74 |
<div class="datafeeder-form" width="parent" style="background:none repeat scroll 0 0 #6F8992;padding:5px 10px; color: white;">
|
75 |
FEED CONFIGURATION
|
76 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
<tr>
|
78 |
<td class="label">
|
79 |
<b>Unbxd Site Key: </b>
|
131 |
}
|
132 |
|
133 |
function newajaxcall(ajaxurl){
|
|
|
134 |
$jq.ajax({
|
135 |
|
136 |
url: ajaxurl,
|
145 |
|
146 |
if(data.feed !== "empty") $jq('[name=feedName]').val(data.feed); else $jq('[name=feedName]').val("");
|
147 |
if(data.feed !== "empty") $jq('[name=siteName]').val(data.siteName); else $jq('[name=siteName]').val("");
|
|
|
|
|
148 |
},
|
149 |
|
150 |
fail: function(XMLHttpRequest, textStatus, errorThrown) {
|
177 |
});
|
178 |
}
|
179 |
|
180 |
+
$jq('#config_edit_form').ready(function(){
|
181 |
+
createTable('<?php echo $this->getEditUrl();?>');
|
182 |
+
});
|
183 |
+
|
184 |
+
function saveFieldConf()
|
185 |
+
{
|
186 |
+
site = $jq('[name=site]').val();
|
187 |
+
fields = {}
|
188 |
+
$jq("#field-list").find("tr").each( function() {
|
189 |
+
var field = {};
|
190 |
+
if ($jq(this).find(".label").text() != "") {
|
191 |
+
field["status"] = ($jq(this).find('[name=status]').find(":selected").text() == "Enabled") ? 1 :0;
|
192 |
+
field["autosuggest"] = ($jq(this).find('[name=autosuggest]').find(":selected").text() == "Enabled") ? 1 :0;
|
193 |
+
field["data_type"] = $jq(this).find('[name=dataType]').find(":selected").text();
|
194 |
+
field["site_name"] = $jq('[name=site]').val();
|
195 |
+
field["generate_image"] = $jq(this).find('[id=generate_image]').is(':checked')?1:0;
|
196 |
+
element = this.querySelector('#image_height');
|
197 |
+
if(element) {
|
198 |
+
field["image_height"] = element.value;
|
199 |
+
}
|
200 |
+
element = this.querySelector('#image_width') ;
|
201 |
+
if (element) {
|
202 |
+
field["image_width"] = element.value;
|
203 |
+
}
|
204 |
+
fields[$jq(this).find(".label").text()] = JSON.stringify(field);
|
205 |
+
|
206 |
+
childProductField = {};
|
207 |
+
if (this.className == "fieldRowSelected"){
|
208 |
+
childProductField["status"] = field["status"];
|
209 |
+
} else {
|
210 |
+
childProductField["status"] = 0;
|
211 |
+
}
|
212 |
+
childProductField["autosuggest"] = field["autosuggest"];
|
213 |
+
childProductField["data_type"] = field["data_type"];
|
214 |
+
childProductField["site_name"] = field["site_name"];
|
215 |
+
childProductField["generate_image"] = field["generate_image"];
|
216 |
+
childProductField["image_width"] = field["image_width"];
|
217 |
+
childProductField["image_height"] = field["image_height"];
|
218 |
+
fields[$jq(this).find(".label").text() + "Associated"] = JSON.stringify(childProductField);
|
219 |
+
|
220 |
+
}
|
221 |
+
});
|
222 |
+
$jq.ajax({
|
223 |
+
url: "<?php echo $this->getSaveFieldUrl();?>",
|
224 |
+
timeout:3000,
|
225 |
+
type:"POST",
|
226 |
+
dataType: "json",
|
227 |
+
data:fields
|
228 |
+
});
|
229 |
+
createTable('<?php echo $this->getEditUrl();?>');
|
230 |
+
}
|
231 |
+
|
232 |
+
function createTable(ajaxurl)
|
233 |
+
{
|
234 |
+
site= $jq("#site").val();
|
235 |
+
$jq.ajax({
|
236 |
+
url: ajaxurl,
|
237 |
+
type:"POST",
|
238 |
+
data:{"site":site},
|
239 |
+
}).done( function(data) {
|
240 |
+
jarray = $jq.parseJSON(data);
|
241 |
+
tableHtml="<tbody>";
|
242 |
+
$jq("#field-list").find("tr").remove();
|
243 |
+
tableHtml += addFieldConfTableHeader();
|
244 |
+
$jq.each(jarray, function(key, value) {
|
245 |
+
childExists = false;
|
246 |
+
if ((key + "Associated") in jarray && jarray[key + "Associated"]["status"] == "1") {
|
247 |
+
childExists = true
|
248 |
+
}
|
249 |
+
if( key.substr(-10) != "Associated" ) {
|
250 |
+
tableHtml += constructRow(key, value, childExists);
|
251 |
+
}
|
252 |
+
});
|
253 |
+
tableHtml+="</tbody>";
|
254 |
+
$jq('#field-list').append(tableHtml)
|
255 |
+
});
|
256 |
+
}
|
257 |
+
|
258 |
+
function addFieldConfTableHeader() {
|
259 |
+
return "<tr>" +
|
260 |
+
"<th>Field Name</th>" +
|
261 |
+
"<th>Status</th>" +
|
262 |
+
"<th>Data Type</th>" +
|
263 |
+
"<th>Autosuggest</th>" +
|
264 |
+
"<th>Add to configurable product</th>" +
|
265 |
+
"<th>Image configuration</th>" +
|
266 |
+
'<td class="scope-label"></td>' +
|
267 |
+
"</tr>";
|
268 |
+
}
|
269 |
+
|
270 |
+
function constructRow(key, value, childExists) {
|
271 |
+
tableString = "";
|
272 |
+
tableString += '<tr ' + (childExists?'class="fieldRowSelected"':"") + '>';
|
273 |
+
tableString += '<td class="label" name="fieldName"><div class="text_td">'+key+"</div></td>";
|
274 |
+
tableString += constructBooleanSelect("status", value);
|
275 |
+
tableString += constructDataType(key, value);
|
276 |
+
tableString += constructBooleanSelect("autosuggest", value);
|
277 |
+
tableString += constructAddToConfigurableFieldList(childExists);
|
278 |
+
tableString += constructImageConf(key, value);
|
279 |
+
tableString +='</tr>';
|
280 |
+
return tableString;
|
281 |
+
}
|
282 |
+
|
283 |
+
function constructImageConf(key, value) {
|
284 |
+
if(!("is_image" in value) || value["is_image"] != "true") {
|
285 |
+
return "";
|
286 |
+
}
|
287 |
+
tableString = "";
|
288 |
+
tableString += '<td><input type="button" value="EDIT" onclick="editImageConf(this)"/>'
|
289 |
+
tableString += '<div class="hidden_image_textBox">';
|
290 |
+
image_generation_enabled = (value["generate_image"] == 1)? true : false;
|
291 |
+
tableString += '<input id="generate_image" onchange="toggleTextBox(this)" type="checkbox" ' + ((image_generation_enabled)?'checked':'')+'/>';
|
292 |
+
tableString += '<input id="image_height" type="text" value="' + value["image_height"]+ '" '+ (image_generation_enabled? '':'disabled')+'"/>';
|
293 |
+
tableString += '<input id="image_width" type="text" value="' + value["image_width"]+ '" '+ (image_generation_enabled? '':'disabled')+'"/>';
|
294 |
+
tableString += '<input value = "update" type="button" onclick="hideDiv(this);"/>';
|
295 |
+
tableString += '</div>';
|
296 |
+
tableString += '</td>';
|
297 |
+
return tableString;
|
298 |
+
}
|
299 |
+
|
300 |
+
function toggleTextBox(element) {
|
301 |
+
active = element.checked ? false: true;
|
302 |
+
element.parentElement.children[1].disabled = active;
|
303 |
+
element.parentElement.children[2].disabled = active;
|
304 |
+
}
|
305 |
+
|
306 |
+
function hideDiv(element) {
|
307 |
+
element.parentElement.parentElement.children[1].className = "hidden_image_textBox";
|
308 |
+
element.parentElement.parentElement.children[0].className = "";
|
309 |
+
}
|
310 |
+
|
311 |
+
function editImageConf(element) {
|
312 |
+
element.parentElement.children[1].className = "";
|
313 |
+
element.className = "hidden_image_textBox";
|
314 |
+
}
|
315 |
+
|
316 |
+
function getRowSelected(element) {
|
317 |
+
if(element.parentElement.parentElement.className == "fieldRowSelected") {
|
318 |
+
element.parentElement.parentElement.className = "";
|
319 |
+
element.children[0].className = "plus";
|
320 |
+
return;
|
321 |
+
}
|
322 |
+
if($jq.find(".fieldRowSelected").length > 10) {
|
323 |
+
alert("Cant select more than 10 fields");
|
324 |
+
return;
|
325 |
+
}
|
326 |
+
element.children[0].className = "minus";
|
327 |
+
element.parentElement.parentElement.addClassName("fieldRowSelected");
|
328 |
+
}
|
329 |
+
|
330 |
+
function constructAddToConfigurableFieldList(childExists) {
|
331 |
+
tableString = '<td><a href="javascript:void(0)" onclick="getRowSelected(this)" title="Add this field in configurable/grouped product">';
|
332 |
+
tableString += '<div ';
|
333 |
+
if(!childExists) {
|
334 |
+
tableString += 'class="plus"';
|
335 |
+
} else {
|
336 |
+
tableString += 'class="minus"';
|
337 |
+
}
|
338 |
+
tableString += "/></a></td>";
|
339 |
+
return tableString;
|
340 |
+
}
|
341 |
+
|
342 |
+
function constructBooleanSelect(key, value) {
|
343 |
+
tableString = '<td class="value"><div class="text_td"><select name=' + key + '>'+"<option";
|
344 |
+
if(value[key]=="0"){
|
345 |
+
tableString +=' selected="selected"';
|
346 |
+
}
|
347 |
+
tableString+=' value="0">Disabled</option><option';
|
348 |
+
if(value[key]!="0"){
|
349 |
+
tableString +=' selected="selected"';
|
350 |
+
}
|
351 |
+
tableString +=' value="1">Enabled</option></select></div></td>';
|
352 |
+
return tableString;
|
353 |
+
}
|
354 |
+
|
355 |
+
function constructDataTypeOption(data_type, compare_data_type) {
|
356 |
+
tableString = "<option";
|
357 |
+
|
358 |
+
if(data_type == compare_data_type){
|
359 |
+
tableString +=' selected="selected"';
|
360 |
+
}
|
361 |
+
tableString+=' value="' + compare_data_type + '">' + compare_data_type + '</option>';
|
362 |
+
return tableString;
|
363 |
+
}
|
364 |
+
|
365 |
+
function constructDataType(key, value) {
|
366 |
+
tableString = '<td class="value"><div class="text_td"><select name="dataType">';
|
367 |
+
tableString += constructDataTypeOption(value["data_type"], "text");
|
368 |
+
tableString += constructDataTypeOption(value["data_type"], "longText");
|
369 |
+
tableString += constructDataTypeOption(value["data_type"], "link");
|
370 |
+
tableString += constructDataTypeOption(value["data_type"], "decimal");
|
371 |
+
tableString += constructDataTypeOption(value["data_type"], "number");
|
372 |
+
tableString += constructDataTypeOption(value["data_type"], "date");
|
373 |
+
//tableString += constructDataTypeOption(value["data_type"], "bool");
|
374 |
+
|
375 |
+
tableString +='</select></div></td>';
|
376 |
+
return tableString;
|
377 |
+
}
|
378 |
+
|
379 |
setInterval(progressbar,10000);
|
380 |
</script>
|
381 |
|
382 |
|
383 |
+
<table class="form-list" width="parent" id="form-list2" name="form-list" cellspacing="0" style="background:none repeat scroll 0 0 #FAFAFA;border=1px solid #D6D6D6;width: 100%;">
|
384 |
<div class="datafeeder-form" width="parent" style="background:none repeat scroll 0 0 #6F8992;padding:5px 10px;color: white;">
|
385 |
<div class="refreshDiv" style="float: right;"><span id="ProgressBar"></span><input type="button" id="refresh" onclick="progressbar()" value="REFRESH" style="margin-left: 10px;vertical-align: top;"></div>
|
386 |
<b>UPLOAD & INDEX (manual)</b>
|
387 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
|
389 |
<tr>
|
390 |
<td class="label"><b>PRODUCT FEED UPLOAD: </b></td>
|
400 |
<frame name="login_frame"></frame>
|
401 |
</frameset>
|
402 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
<div class="editconfig">
|
404 |
<div class="content-header">
|
405 |
<table cellspacing="0">
|
411 |
</h3>
|
412 |
</td>
|
413 |
<td class="form-buttons">
|
414 |
+
<input type="button" style='background:url("images/btn_bg.gif") repeat-x scroll 0 100% #FFAC47;border-color:#ED6502 #A04300 #A04300 #ED6502;border-style:solid;border-width:1px;color:#FFFFFF;font:bold 12px arial,helvetica,sans-serif;text-align:center !important;white-space:nowrap;padding: 3px;' onclick="saveFieldConf()" value="SAVE"/>
|
415 |
</td>
|
416 |
</tr>
|
417 |
</table>
|
427 |
</p>
|
428 |
|
429 |
<table class="form-list" id="field-list" name="form-list" cellspacing="0" style="color: #2F2F2F;
|
430 |
+
font: 12px/1.5em Arial,Helvetica,sans-serif; margin-left: 1%;">
|
431 |
</table>
|
432 |
|
433 |
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
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>
|
8 |
<extends/>
|
9 |
<summary>pushes the products from the magento to unbxd servers</summary>
|
10 |
<description>pushes the products from the magento to unbxd servers</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>ananthesh</name><user>ananthesh</user><email>ananthesh@unbxd.com</email></author></authors>
|
13 |
-
<date>2014-
|
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="AnalyticsHelper.php" hash="
|
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.5</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>
|
8 |
<extends/>
|
9 |
<summary>pushes the products from the magento to unbxd servers</summary>
|
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-03</date>
|
14 |
+
<time>19:23:15</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="2ede09269c6a5dc4125d06207e740402"/><file name="Data.php" hash="cc32188ca72c365a3177b8439188f4b0"/><file name="UnbxdIndexingHelper.php" hash="116982d19c4dfb3e295a795ad2773a02"/><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="3535e6104be33d541011b2b89597199e"/><file name="Feedmanager.php" hash="7480e546e88038163624e61459124848"/><file name="Filemanager.php" hash="5200abf7349679edec7e617619c8d8b3"/><dir name="Jsonbuilder"><file name="Jsonbuilder.php" hash="7e0b5958dd814a7b204317ef4bd487f3"/><file name="Productbuilder.php" hash="e2323a8de707e12c58b1a87c00aeb8b9"/><file name="Schemabuilder.php" hash="57be152e56d6ed90332aaf1350d4b398"/></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="5429c26e0a0955595a72a05b49069641"/><dir name="Resource"><file name="Attribute.php" hash="9353baa4f14eeb342de93d20c566bfee"/></dir></dir></dir><dir name="controllers"><file name="ConfigController.php" hash="1ebf102b9a8a97f16e4e57a3d345632d"/><file name="FieldController.php" hash="675af9d5a98acc39e80a1bd0919b2393"/><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="f489e0f632f103f372e83b710c810157"/><file name="mysql4-upgrade-0.1.0-1.0.5.php" hash="f489e0f632f103f372e83b710c810157"/></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="d187b3adc64569d84034ffb2c388bad6"/></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>
|