Version Notes
added task status to check the direct SQL update status. No need anymore to check your cron_schedule table:
Status: pending, error, missed or succes
Created At, Scheduled and At Finished At times
Download this release
Release Info
Developer | Magento Core Team |
Extension | Speedup_your_catalog_update_using_our_Direct_SQL_Update_extension |
Version | 1.4.1.2 |
Comparing to | |
See all releases |
Code changes from version 1.4.1.1 to 1.4.1.2
- app/code/community/Ayasoftware/SQLupdate/Model/DBHelper.php +43 -4
- app/code/community/Ayasoftware/SQLupdate/Model/Massimport.php +168 -123
- app/code/community/Ayasoftware/SQLupdate/Model/Observer.php +24 -17
- app/code/community/Ayasoftware/SQLupdate/etc/config.xml +1 -1
- app/code/community/Ayasoftware/SQLupdate/etc/system.xml +42 -0
- app/design/adminhtml/default/default/template/sqlupdate/schedule.phtml +47 -0
- package.xml +5 -4
app/code/community/Ayasoftware/SQLupdate/Model/DBHelper.php
CHANGED
@@ -2,13 +2,12 @@
|
|
2 |
/**
|
3 |
* @category Ayasoftware
|
4 |
* @package Ayasoftware_SQLupdate
|
5 |
-
* @
|
6 |
* website: www.ayasoftware.com/
|
7 |
*/
|
8 |
class Ayasoftware_SQLupdate_Model_DBHelper {
|
9 |
protected $_db;
|
10 |
protected $_debug;
|
11 |
-
|
12 |
/**
|
13 |
* Intializes database connection
|
14 |
* @param string $host : hostname
|
@@ -48,13 +47,15 @@ class Ayasoftware_SQLupdate_Model_DBHelper {
|
|
48 |
|
49 |
}
|
50 |
|
|
|
|
|
51 |
/**
|
52 |
* executes an sql statement
|
53 |
* @param string $sql : sql statement (may include ? placeholders)
|
54 |
* @param array $params : parameters to replace placeholders (can be null)
|
55 |
* @return PDOStatement : statement for further processing if needed
|
56 |
*/
|
57 |
-
|
58 |
{
|
59 |
$stmt=$this->_db->prepare($sql);
|
60 |
if($params!=null)
|
@@ -68,7 +69,6 @@ class Ayasoftware_SQLupdate_Model_DBHelper {
|
|
68 |
}
|
69 |
return $stmt;
|
70 |
}
|
71 |
-
|
72 |
/**
|
73 |
* Perform a delete statement, sql should be "DELETE"
|
74 |
* @param string $sql : DELETE statement sql (placeholders allowed)
|
@@ -79,6 +79,7 @@ class Ayasoftware_SQLupdate_Model_DBHelper {
|
|
79 |
$this->exec_stmt($sql,$params);
|
80 |
}
|
81 |
|
|
|
82 |
/**
|
83 |
* Perform an insert , sql should be "INSERT"
|
84 |
* @param string $sql :INSERT statement SQL (placeholders allowed)
|
@@ -92,6 +93,10 @@ class Ayasoftware_SQLupdate_Model_DBHelper {
|
|
92 |
return $liid;
|
93 |
}
|
94 |
|
|
|
|
|
|
|
|
|
95 |
/**
|
96 |
* Perform a select ,sql should be "SELECT"
|
97 |
* @param string $sql :SELECT statement SQL (placeholders allowed)
|
@@ -152,4 +157,38 @@ class Ayasoftware_SQLupdate_Model_DBHelper {
|
|
152 |
{
|
153 |
$this->_db->rollBack();
|
154 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
}
|
2 |
/**
|
3 |
* @category Ayasoftware
|
4 |
* @package Ayasoftware_SQLupdate
|
5 |
+
* @author EL Hassan Matar <support@ayasoftware.com>
|
6 |
* website: www.ayasoftware.com/
|
7 |
*/
|
8 |
class Ayasoftware_SQLupdate_Model_DBHelper {
|
9 |
protected $_db;
|
10 |
protected $_debug;
|
|
|
11 |
/**
|
12 |
* Intializes database connection
|
13 |
* @param string $host : hostname
|
47 |
|
48 |
}
|
49 |
|
50 |
+
|
51 |
+
|
52 |
/**
|
53 |
* executes an sql statement
|
54 |
* @param string $sql : sql statement (may include ? placeholders)
|
55 |
* @param array $params : parameters to replace placeholders (can be null)
|
56 |
* @return PDOStatement : statement for further processing if needed
|
57 |
*/
|
58 |
+
public function exec_stmt($sql,$params=null)
|
59 |
{
|
60 |
$stmt=$this->_db->prepare($sql);
|
61 |
if($params!=null)
|
69 |
}
|
70 |
return $stmt;
|
71 |
}
|
|
|
72 |
/**
|
73 |
* Perform a delete statement, sql should be "DELETE"
|
74 |
* @param string $sql : DELETE statement sql (placeholders allowed)
|
79 |
$this->exec_stmt($sql,$params);
|
80 |
}
|
81 |
|
82 |
+
|
83 |
/**
|
84 |
* Perform an insert , sql should be "INSERT"
|
85 |
* @param string $sql :INSERT statement SQL (placeholders allowed)
|
93 |
return $liid;
|
94 |
}
|
95 |
|
96 |
+
public function update($sql){
|
97 |
+
$this->exec_stmt($sql);
|
98 |
+
}
|
99 |
+
|
100 |
/**
|
101 |
* Perform a select ,sql should be "SELECT"
|
102 |
* @param string $sql :SELECT statement SQL (placeholders allowed)
|
157 |
{
|
158 |
$this->_db->rollBack();
|
159 |
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Download remote file
|
163 |
+
* @param String : $file
|
164 |
+
* @return true;
|
165 |
+
*/
|
166 |
+
public function downloadRemoteFile($file){
|
167 |
+
|
168 |
+
$host = Mage::getStoreConfig ( 'sqlupdate/ftpSettings/host' );
|
169 |
+
$username = Mage::getStoreConfig ( 'sqlupdate/ftpSettings/username' );
|
170 |
+
$password = Mage::getStoreConfig ( 'sqlupdate/ftpSettings/password' );
|
171 |
+
$directory = Mage::getStoreConfig ( 'sqlupdate/ftpSettings/directory' );
|
172 |
+
|
173 |
+
$csvfile = Mage::getBaseDir() . DS . $file;
|
174 |
+
$conn_id = ftp_connect( $host );
|
175 |
+
$login_result = ftp_login($conn_id, $username, $password );
|
176 |
+
|
177 |
+
if(!$login_result ){
|
178 |
+
die("Unable to connect to the FTP host");
|
179 |
+
}
|
180 |
+
// get the file
|
181 |
+
$local = fopen ( $csvfile, "w" );
|
182 |
+
// change FTP directory to Files
|
183 |
+
if(!ftp_chdir($conn_id, $directory)){
|
184 |
+
die("Unable to cd Files");
|
185 |
+
}
|
186 |
+
if(! ftp_fget($conn_id,$local,$file,FTP_BINARY )){
|
187 |
+
die("Download file failed");
|
188 |
+
} else {
|
189 |
+
echo $file. " has been successfully downloaded\n";
|
190 |
+
}
|
191 |
+
// close the FTP stream
|
192 |
+
ftp_close ( $conn_id );
|
193 |
+
}
|
194 |
}
|
app/code/community/Ayasoftware/SQLupdate/Model/Massimport.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @category Ayasoftware
|
4 |
* @package Ayasoftware_SQLupdate
|
5 |
-
* @
|
6 |
* website: www.ayasoftware.com/
|
7 |
*/
|
8 |
class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model_DBHelper {
|
@@ -16,10 +16,10 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
16 |
public $magdir;
|
17 |
public $imgsourcedir;
|
18 |
public $tprefix;
|
|
|
19 |
public $logfilename;
|
|
|
20 |
public $prod_etype;
|
21 |
-
|
22 |
-
|
23 |
/**
|
24 |
* retrieve property value with default if not found
|
25 |
* @param string $secname section name
|
@@ -48,6 +48,8 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
48 |
*/
|
49 |
public function loadProperties() {
|
50 |
$xmlPath = Mage::getBaseDir () . DS . 'app/etc/local.xml';
|
|
|
|
|
51 |
$xmlObj = new Varien_Simplexml_Config ( $xmlPath );
|
52 |
$this->magdir = Mage::getBaseDir ();
|
53 |
if (Mage::getStoreConfig ( 'sqlupdate/sqlupdateSettings/imgsourcedir' )) {
|
@@ -55,8 +57,12 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
55 |
} else {
|
56 |
$this->imgsourcedir = Mage::getBaseDir () . DS . "media/import";
|
57 |
}
|
|
|
58 |
$this->tprefix = $xmlObj->getNode ( "global/resources/db/table_prefix" );
|
59 |
$this->logfilename = Mage::getBaseDir () . DS . "var/log/" . Mage::getStoreConfig ( 'sqlupdate/sqlupdateSettings/logfilename' );
|
|
|
|
|
|
|
60 |
}
|
61 |
|
62 |
/**
|
@@ -106,20 +112,14 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
106 |
/**
|
107 |
* Initialize attribute infos to be used during import
|
108 |
* @param array $cols : array of attribute names
|
109 |
-
* updated 23 August 2010 - by Dweeves
|
110 |
*/
|
111 |
-
|
112 |
-
public function initAttrInfos($cols)
|
113 |
-
{
|
114 |
-
//Find product entity type
|
115 |
-
$tname=$this->tablename("eav_entity_type");
|
116 |
-
$this->prod_etype=$this->selectone("SELECT entity_type_id FROM $tname WHERE entity_type_code=?","catalog_product","entity_type_id");
|
117 |
//create statement parameter string ?,?,?.....
|
118 |
-
|
119 |
$tname = $this->tablename ( "eav_attribute" );
|
120 |
//SQL for selecting attribute properties for all wanted attributes
|
121 |
$sql = "SELECT `$tname`.* FROM `$tname`
|
122 |
-
WHERE ($tname.attribute_code IN ($qcolstr)) AND (entity_type_id
|
123 |
$stmt = $this->select ( $sql, $cols );
|
124 |
//create an attribute code based array for the wanted columns
|
125 |
while ( $r = $stmt->fetch () ) {
|
@@ -419,15 +419,76 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
419 |
return $ovalue;
|
420 |
}
|
421 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
/**
|
423 |
* Create product attribute from values for a given product id
|
424 |
* @param $pid : product id to create attribute values for
|
425 |
* @param $item : attribute values in an array indexed by attribute_code
|
426 |
*/
|
427 |
-
|
428 |
-
|
429 |
* if we did not wipe all products , delete attribute entries for current product
|
430 |
*/
|
|
|
431 |
if (! $this->reset) {
|
432 |
$tcsi = $this->tablename ( 'cataloginventory_stock_item' );
|
433 |
$tcss = $this->tablename ( 'cataloginventory_stock_status' );
|
@@ -437,7 +498,6 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
437 |
$this->delete ( $sql, $pid );
|
438 |
}
|
439 |
}
|
440 |
-
|
441 |
/* now is the interesring part */
|
442 |
/* iterate on attribute backend type index */
|
443 |
foreach ( $this->attrbytype as $tp => $a ) {
|
@@ -475,7 +535,7 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
475 |
if ($ovalue !== false) {
|
476 |
$inserts [] = "(?,?,?,?,?)";
|
477 |
//entity type id = product (4)
|
478 |
-
$data [] =
|
479 |
$data [] = $attid;
|
480 |
//store_id = 0
|
481 |
$data [] = 0;
|
@@ -492,14 +552,18 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
492 |
//this one taken from mysql log analysis of magento import
|
493 |
//smart one :)
|
494 |
$sql .= " ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)";
|
495 |
-
|
|
|
|
|
|
|
|
|
|
|
496 |
}
|
497 |
}
|
498 |
-
|
499 |
/**
|
500 |
* Clear all products from catalog
|
501 |
*/
|
502 |
-
public function
|
503 |
$sql = "SET FOREIGN_KEY_CHECKS = 0;\n";
|
504 |
$tables = array ("catalog_product_bundle_option", "catalog_product_bundle_option_value", "catalog_product_bundle_selection", "catalog_product_entity_datetime", "catalog_product_entity_decimal", "catalog_product_entity_gallery", "catalog_product_entity_int", "catalog_product_entity_media_gallery", "catalog_product_entity_media_gallery_value", "catalog_product_entity_text", "catalog_product_entity_tier_price", "catalog_product_entity_varchar", "catalog_product_link", "catalog_product_link_attribute", "catalog_product_link_attribute_decimal", "catalog_product_link_attribute_int", "catalog_product_link_attribute_varchar", "catalog_product_link_type", "catalog_product_option", "catalog_product_option_price", "catalog_product_option_title", "catalog_product_option_type_price", "catalog_product_option_type_title", "catalog_product_option_type_value", "catalog_product_super_attribute_label", "catalog_product_super_attribute_pricing", "catalog_product_super_attribute", "catalog_product_super_link", "catalog_product_enabled_index", "catalog_product_website", "catalog_category_product_index", "catalog_category_product", "cataloginventory_stock_item", "mag_cataloginventory_stock_status", "mag_cataloginventory_stock" );
|
505 |
|
@@ -532,6 +596,25 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
532 |
}
|
533 |
}
|
534 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
|
536 |
/**
|
537 |
* update product stock
|
@@ -539,6 +622,7 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
539 |
* @param array $item : attribute values for product indexed by attribute_code
|
540 |
*/
|
541 |
public function updateStock($pid, $item) {
|
|
|
542 |
$csit = $this->tablename ( "cataloginventory_stock_item" );
|
543 |
$sql = "INSERT INTO `$csit`
|
544 |
(`product_id`,
|
@@ -549,7 +633,7 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
549 |
`stock_status_changed_automatically`)
|
550 |
VALUES (?,?,?,?,?,?)";
|
551 |
$data = array ($pid, $this->website_ids [$item ["websites"]], $item ["qty"], $item ["qty"] > 0 ? 1 : 0, null, 1 );
|
552 |
-
$this->insert
|
553 |
}
|
554 |
|
555 |
/**
|
@@ -580,24 +664,10 @@ class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model
|
|
580 |
$this->insert ( $sql, array ($catid, $pid ) );
|
581 |
}
|
582 |
|
583 |
-
public function updateIndexes
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
$idxlist = array("catalog_product_attribute", "catalog_product_price", "catalog_product_flat", "catalog_category_flat", "catalog_category_product", "catalog_url", "catalogsearch_fulltext", "cataloginventory_stock");
|
588 |
-
//reindex using magento command line
|
589 |
-
foreach ($idxlist as $idx) {
|
590 |
-
$tstart = microtime(true);
|
591 |
-
Mage::log("Reindexing $idx....\n");
|
592 |
-
exec("php $indexer --reindex $idx");
|
593 |
-
$tend = microtime(true);
|
594 |
-
Mage::log("done in " . round($tend - $tstart, 2) . " secs \n");
|
595 |
-
flush();
|
596 |
-
}
|
597 |
-
} else {
|
598 |
-
Mage::log("Magento 1.3 indexer not found, you should reindex manually using magento admin \n");
|
599 |
-
}
|
600 |
-
}
|
601 |
/**
|
602 |
* set website of product if not exists
|
603 |
* @param int $pid : product id
|
@@ -613,63 +683,17 @@ public function updateIndexes ()
|
|
613 |
}
|
614 |
}
|
615 |
|
616 |
-
|
617 |
-
/**
|
618 |
-
* Clear all products from catalog
|
619 |
-
*/
|
620 |
-
public function clearProducts()
|
621 |
-
{
|
622 |
-
$sql="SET FOREIGN_KEY_CHECKS = 0";
|
623 |
-
$this->exec_stmt($sql);
|
624 |
-
$tables=array("catalog_product_bundle_option",
|
625 |
-
"catalog_product_bundle_option_value",
|
626 |
-
"catalog_product_bundle_selection",
|
627 |
-
"catalog_product_entity_datetime",
|
628 |
-
"catalog_product_entity_decimal",
|
629 |
-
"catalog_product_entity_gallery",
|
630 |
-
"catalog_product_entity_int",
|
631 |
-
"catalog_product_entity_media_gallery",
|
632 |
-
"catalog_product_entity_media_gallery_value",
|
633 |
-
"catalog_product_entity_text",
|
634 |
-
"catalog_product_entity_tier_price",
|
635 |
-
"catalog_product_entity_varchar",
|
636 |
-
"catalog_product_entity",
|
637 |
-
"catalog_product_option",
|
638 |
-
"catalog_product_option_price",
|
639 |
-
"catalog_product_option_title",
|
640 |
-
"catalog_product_option_type_price",
|
641 |
-
"catalog_product_option_type_title",
|
642 |
-
"catalog_product_option_type_value",
|
643 |
-
"catalog_product_super_attribute_label",
|
644 |
-
"catalog_product_super_attribute_pricing",
|
645 |
-
"catalog_product_super_attribute",
|
646 |
-
"catalog_product_super_link",
|
647 |
-
"catalog_product_relation",
|
648 |
-
"catalog_product_enabled_index",
|
649 |
-
"catalog_product_website",
|
650 |
-
"catalog_category_product_index",
|
651 |
-
"catalog_category_product",
|
652 |
-
"cataloginventory_stock_item",
|
653 |
-
"cataloginventory_stock_status");
|
654 |
-
|
655 |
-
|
656 |
-
foreach($tables as $table)
|
657 |
-
{
|
658 |
-
$this->exec_stmt("TRUNCATE TABLE `".$this->tablename($table)."`");
|
659 |
-
}
|
660 |
-
|
661 |
-
$sql="SET FOREIGN_KEY_CHECKS = 1";
|
662 |
-
|
663 |
-
$this->exec_stmt($sql);
|
664 |
-
}
|
665 |
-
|
666 |
/**
|
667 |
* full import workflow for item
|
668 |
* @param array $item : attribute values for product indexed by attribute_code
|
669 |
*/
|
670 |
-
public function
|
|
|
|
|
671 |
//retrieve sku
|
672 |
$sku = $item ["sku"];
|
|
|
|
|
673 |
$asname = $item ["attribute_set"];
|
674 |
//retrieve attribute set from given name
|
675 |
//if not in cache, add to cache
|
@@ -680,6 +704,7 @@ public function updateIndexes ()
|
|
680 |
$asid = $this->attribute_sets [$asname];
|
681 |
}
|
682 |
|
|
|
683 |
//begin transaction
|
684 |
$this->beginTransaction ();
|
685 |
try {
|
@@ -688,42 +713,61 @@ public function updateIndexes ()
|
|
688 |
$pid = $this->getProductId ( $sku );
|
689 |
//if not found, create new product
|
690 |
if (! isset ( $pid )) {
|
691 |
-
|
692 |
}
|
693 |
-
|
694 |
-
$this->destroyAttributes ( $pid );
|
695 |
-
//create new ones
|
696 |
-
$this->createAttributes ( $pid, $item );
|
697 |
//assign categories
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
$this->
|
704 |
-
|
705 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
706 |
//ok,we're done
|
707 |
-
|
|
|
708 |
} catch ( Exception $e ) {
|
|
|
|
|
709 |
//if anything got wrong, rollback
|
710 |
$this->rollbackTransaction ();
|
711 |
}
|
712 |
}
|
713 |
-
|
714 |
/**
|
715 |
* main import function
|
716 |
* @param string $csvfile : csv file name to import
|
717 |
* @param bool $reset : destroy all products before import
|
718 |
*/
|
719 |
public function import($csvfile, $reset = false) {
|
720 |
-
$stimer = explode( ' ', microtime() );
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
$fp = fopen($this->logfilename, 'a') or die("can't open file: "
|
726 |
-
fwrite($fp,"Update Started ". date("Y-m-d H:i:s") ."\n");
|
727 |
if (! isset ( $csvfile )) {
|
728 |
die ( "No csv file set" );
|
729 |
}
|
@@ -739,7 +783,7 @@ public function updateIndexes ()
|
|
739 |
//if reset
|
740 |
if ($this->reset) {
|
741 |
//clear all products
|
742 |
-
|
743 |
}
|
744 |
//open csv file
|
745 |
$f = fopen ( $csvfile, "r" );
|
@@ -768,18 +812,18 @@ public function updateIndexes ()
|
|
768 |
$item = array_combine ( $this->cols, $row );
|
769 |
if (is_array ( $item )) {
|
770 |
//import item
|
771 |
-
$this->
|
772 |
//intermediary measurement
|
773 |
} else {
|
774 |
-
fwrite($fp,"ERROR - LINE $cnt - INVALID ROW :" . count ( $row ) . "/" . count ( $this->cols ) . " cols found\n");
|
775 |
}
|
776 |
if ($cnt % $mstep == 0) {
|
777 |
$tend = microtime ( true );
|
778 |
-
fwrite($fp
|
779 |
$tdiff = microtime ( true );
|
780 |
}
|
781 |
} catch ( Exception $e ) {
|
782 |
-
fwrite($fp,"ERROR - LINE $cnt - " . $e->getMessage (). "\n");
|
783 |
}
|
784 |
|
785 |
}
|
@@ -787,14 +831,15 @@ public function updateIndexes ()
|
|
787 |
fclose ( $f );
|
788 |
$this->updateIndexes ();
|
789 |
$tend = microtime ( true );
|
790 |
-
fwrite($fp, $cnt . "-");
|
791 |
-
fwrite($fp, " Speed Average ".ceil ( ($cnt * 60) / ($tend - $tstart) ) . " rec/mn" . "\n");
|
792 |
flush ();
|
793 |
-
$etimer = explode( ' ', microtime() );
|
794 |
-
|
795 |
-
|
796 |
-
fwrite($fp, $etimer- $stimer. " Seconds
|
797 |
-
|
798 |
$this->disconnectFromMagento ();
|
799 |
}
|
800 |
}
|
|
2 |
/**
|
3 |
* @category Ayasoftware
|
4 |
* @package Ayasoftware_SQLupdate
|
5 |
+
* @author EL Hassan Matar <support@ayasoftware.com>
|
6 |
* website: www.ayasoftware.com/
|
7 |
*/
|
8 |
class Ayasoftware_SQLupdate_Model_Massimport extends Ayasoftware_SQLupdate_Model_DBHelper {
|
16 |
public $magdir;
|
17 |
public $imgsourcedir;
|
18 |
public $tprefix;
|
19 |
+
public $costId;
|
20 |
public $logfilename;
|
21 |
+
public $fp;
|
22 |
public $prod_etype;
|
|
|
|
|
23 |
/**
|
24 |
* retrieve property value with default if not found
|
25 |
* @param string $secname section name
|
48 |
*/
|
49 |
public function loadProperties() {
|
50 |
$xmlPath = Mage::getBaseDir () . DS . 'app/etc/local.xml';
|
51 |
+
$attributeInfo = Mage::getResourceModel ( 'eav/entity_attribute_collection' )->setCodeFilter ( 'cost' )->getFirstItem ();
|
52 |
+
|
53 |
$xmlObj = new Varien_Simplexml_Config ( $xmlPath );
|
54 |
$this->magdir = Mage::getBaseDir ();
|
55 |
if (Mage::getStoreConfig ( 'sqlupdate/sqlupdateSettings/imgsourcedir' )) {
|
57 |
} else {
|
58 |
$this->imgsourcedir = Mage::getBaseDir () . DS . "media/import";
|
59 |
}
|
60 |
+
$this->costId = $attributeInfo->getAttributeId ();
|
61 |
$this->tprefix = $xmlObj->getNode ( "global/resources/db/table_prefix" );
|
62 |
$this->logfilename = Mage::getBaseDir () . DS . "var/log/" . Mage::getStoreConfig ( 'sqlupdate/sqlupdateSettings/logfilename' );
|
63 |
+
$this->fp = Mage::getBaseDir () . DS . "var/log/" . Mage::getStoreConfig ( 'sqlupdate/sqlupdateSettings/logfilename' );
|
64 |
+
$tname=$this->tablename("eav_entity_type");
|
65 |
+
$this->prod_etype=Mage::getModel('catalog/product')->getResource()->getTypeId();
|
66 |
}
|
67 |
|
68 |
/**
|
112 |
/**
|
113 |
* Initialize attribute infos to be used during import
|
114 |
* @param array $cols : array of attribute names
|
|
|
115 |
*/
|
116 |
+
public function initAttrInfos($cols) {
|
|
|
|
|
|
|
|
|
|
|
117 |
//create statement parameter string ?,?,?.....
|
118 |
+
$qcolstr = substr ( str_repeat ( "?,", count ( $cols ) ), 0, - 1 );
|
119 |
$tname = $this->tablename ( "eav_attribute" );
|
120 |
//SQL for selecting attribute properties for all wanted attributes
|
121 |
$sql = "SELECT `$tname`.* FROM `$tname`
|
122 |
+
WHERE ($tname.attribute_code IN ($qcolstr)) AND (entity_type_id=4)";
|
123 |
$stmt = $this->select ( $sql, $cols );
|
124 |
//create an attribute code based array for the wanted columns
|
125 |
while ( $r = $stmt->fetch () ) {
|
419 |
return $ovalue;
|
420 |
}
|
421 |
|
422 |
+
public function getStoreIdsForWebsiteScope($scodes)
|
423 |
+
{
|
424 |
+
if(!isset($this->_sid_wsscope[$scodes]))
|
425 |
+
{
|
426 |
+
$this->_sid_wsscope[$scodes]=array();
|
427 |
+
$wscarr=csl2arr($scodes);
|
428 |
+
$qcolstr=$this->arr2values($wscarr);
|
429 |
+
$cs=$this->tablename("core_store");
|
430 |
+
$sql="SELECT cs_sec.store_id from $cs as csmain
|
431 |
+
JOIN $cs as cs_sec ON cs_sec.website_id=csmain.website_id AND csmain.code IN ($qcolstr)";
|
432 |
+
$sidrows=$this->selectAll($sql,$wscarr);
|
433 |
+
foreach($sidrows as $sidrow)
|
434 |
+
{
|
435 |
+
$this->_sid_wsscope[$scodes][]=$sidrow["store_id"];
|
436 |
+
}
|
437 |
+
}
|
438 |
+
return $this->_sid_wsscope[$scodes];
|
439 |
+
}
|
440 |
+
|
441 |
+
public function getItemStoreIds($item,$scope)
|
442 |
+
{
|
443 |
+
switch($scope){
|
444 |
+
//global scope
|
445 |
+
case 1:
|
446 |
+
$bstore_ids=$this->getStoreIdsForStoreScope("admin");
|
447 |
+
break;
|
448 |
+
//store scope
|
449 |
+
case 0:
|
450 |
+
$bstore_ids=$this->getStoreIdsForStoreScope($item["store"]);
|
451 |
+
break;
|
452 |
+
//website scope
|
453 |
+
case 2:
|
454 |
+
$bstore_ids=$this->getStoreIdsForWebsiteScope($item["store"]);
|
455 |
+
break;
|
456 |
+
}
|
457 |
+
|
458 |
+
$itemstores=array_unique(array_merge($this->_dstore,$bstore_ids));
|
459 |
+
sort($itemstores);
|
460 |
+
return $itemstores;
|
461 |
+
}
|
462 |
+
|
463 |
+
public function getStoreIdsForStoreScope($scodes)
|
464 |
+
{
|
465 |
+
if(!isset($this->_sid_sscope[$scodes]))
|
466 |
+
{
|
467 |
+
$this->_sid_sscope[$scodes]=array();
|
468 |
+
$scarr=csl2arr($scodes);
|
469 |
+
$qcolstr=$this->arr2values($scarr);
|
470 |
+
$cs=$this->tablename("core_store");
|
471 |
+
$sql="SELECT csmain.store_id from $cs as csmain WHERE csmain.code IN ($qcolstr)";
|
472 |
+
$sidrows=$this->selectAll($sql,$scarr);
|
473 |
+
foreach($sidrows as $sidrow)
|
474 |
+
{
|
475 |
+
$this->_sid_sscope[$scodes][]=$sidrow["store_id"];
|
476 |
+
}
|
477 |
+
|
478 |
+
}
|
479 |
+
return $this->_sid_sscope[$scodes];
|
480 |
+
}
|
481 |
+
|
482 |
/**
|
483 |
* Create product attribute from values for a given product id
|
484 |
* @param $pid : product id to create attribute values for
|
485 |
* @param $item : attribute values in an array indexed by attribute_code
|
486 |
*/
|
487 |
+
public function createAttributes($pid, $item) {
|
488 |
+
/*
|
489 |
* if we did not wipe all products , delete attribute entries for current product
|
490 |
*/
|
491 |
+
|
492 |
if (! $this->reset) {
|
493 |
$tcsi = $this->tablename ( 'cataloginventory_stock_item' );
|
494 |
$tcss = $this->tablename ( 'cataloginventory_stock_status' );
|
498 |
$this->delete ( $sql, $pid );
|
499 |
}
|
500 |
}
|
|
|
501 |
/* now is the interesring part */
|
502 |
/* iterate on attribute backend type index */
|
503 |
foreach ( $this->attrbytype as $tp => $a ) {
|
535 |
if ($ovalue !== false) {
|
536 |
$inserts [] = "(?,?,?,?,?)";
|
537 |
//entity type id = product (4)
|
538 |
+
$data [] = $this->prod_etype;
|
539 |
$data [] = $attid;
|
540 |
//store_id = 0
|
541 |
$data [] = 0;
|
552 |
//this one taken from mysql log analysis of magento import
|
553 |
//smart one :)
|
554 |
$sql .= " ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)";
|
555 |
+
try {
|
556 |
+
$this->insert ( $sql, $data );
|
557 |
+
} catch ( Exception $e ) {
|
558 |
+
fwrite ( $this->fp, $e->getMessage()."\n" );
|
559 |
+
}
|
560 |
+
|
561 |
}
|
562 |
}
|
|
|
563 |
/**
|
564 |
* Clear all products from catalog
|
565 |
*/
|
566 |
+
public function clearProducts() {
|
567 |
$sql = "SET FOREIGN_KEY_CHECKS = 0;\n";
|
568 |
$tables = array ("catalog_product_bundle_option", "catalog_product_bundle_option_value", "catalog_product_bundle_selection", "catalog_product_entity_datetime", "catalog_product_entity_decimal", "catalog_product_entity_gallery", "catalog_product_entity_int", "catalog_product_entity_media_gallery", "catalog_product_entity_media_gallery_value", "catalog_product_entity_text", "catalog_product_entity_tier_price", "catalog_product_entity_varchar", "catalog_product_link", "catalog_product_link_attribute", "catalog_product_link_attribute_decimal", "catalog_product_link_attribute_int", "catalog_product_link_attribute_varchar", "catalog_product_link_type", "catalog_product_option", "catalog_product_option_price", "catalog_product_option_title", "catalog_product_option_type_price", "catalog_product_option_type_title", "catalog_product_option_type_value", "catalog_product_super_attribute_label", "catalog_product_super_attribute_pricing", "catalog_product_super_attribute", "catalog_product_super_link", "catalog_product_enabled_index", "catalog_product_website", "catalog_category_product_index", "catalog_category_product", "cataloginventory_stock_item", "mag_cataloginventory_stock_status", "mag_cataloginventory_stock" );
|
569 |
|
596 |
}
|
597 |
}
|
598 |
}
|
599 |
+
// TODO
|
600 |
+
// ADD a where for the store and atrribute code -
|
601 |
+
public function updateCost($pid, $item){
|
602 |
+
if(isset($item ["cost"])) {
|
603 |
+
$cost = $item ["cost"] ;
|
604 |
+
$websiteId = $this->website_ids [$item ["website"]];
|
605 |
+
$cped = $this->tablename ( "catalog_product_entity_decimal" );
|
606 |
+
$attribut_id = $this->costId;
|
607 |
+
$sql = "INSERT INTO `$cped`
|
608 |
+
(`attribute_id`,
|
609 |
+
`store_id`,
|
610 |
+
`entity_id`,
|
611 |
+
`value`) VALUES (?,?,?,?) ";
|
612 |
+
|
613 |
+
$data = array ($attribut_id, $this->website_ids [$item ["website"]], $pid, $cost);
|
614 |
+
$this->insert($sql,$data);
|
615 |
+
}
|
616 |
+
return true;
|
617 |
+
}
|
618 |
|
619 |
/**
|
620 |
* update product stock
|
622 |
* @param array $item : attribute values for product indexed by attribute_code
|
623 |
*/
|
624 |
public function updateStock($pid, $item) {
|
625 |
+
$updated = true;
|
626 |
$csit = $this->tablename ( "cataloginventory_stock_item" );
|
627 |
$sql = "INSERT INTO `$csit`
|
628 |
(`product_id`,
|
633 |
`stock_status_changed_automatically`)
|
634 |
VALUES (?,?,?,?,?,?)";
|
635 |
$data = array ($pid, $this->website_ids [$item ["websites"]], $item ["qty"], $item ["qty"] > 0 ? 1 : 0, null, 1 );
|
636 |
+
$this->insert($sql,$data);
|
637 |
}
|
638 |
|
639 |
/**
|
664 |
$this->insert ( $sql, array ($catid, $pid ) );
|
665 |
}
|
666 |
|
667 |
+
public function updateIndexes() {
|
668 |
+
|
669 |
+
}
|
670 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
671 |
/**
|
672 |
* set website of product if not exists
|
673 |
* @param int $pid : product id
|
683 |
}
|
684 |
}
|
685 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
686 |
/**
|
687 |
* full import workflow for item
|
688 |
* @param array $item : attribute values for product indexed by attribute_code
|
689 |
*/
|
690 |
+
public function updateItem($item) {
|
691 |
+
|
692 |
+
|
693 |
//retrieve sku
|
694 |
$sku = $item ["sku"];
|
695 |
+
//echo "importing ... item ".$sku."\n";
|
696 |
+
//fwrite ( $this->fp ,"updating item with ". $sku."\n");
|
697 |
$asname = $item ["attribute_set"];
|
698 |
//retrieve attribute set from given name
|
699 |
//if not in cache, add to cache
|
704 |
$asid = $this->attribute_sets [$asname];
|
705 |
}
|
706 |
|
707 |
+
|
708 |
//begin transaction
|
709 |
$this->beginTransaction ();
|
710 |
try {
|
713 |
$pid = $this->getProductId ( $sku );
|
714 |
//if not found, create new product
|
715 |
if (! isset ( $pid )) {
|
716 |
+
//$pid = $this->createProduct ( $item, $asid );
|
717 |
}
|
718 |
+
|
|
|
|
|
|
|
719 |
//assign categories
|
720 |
+
//$category_ids = $item ["category_ids"];
|
721 |
+
//if (isset ( $category_ids )) {
|
722 |
+
//$this->assignCategories ( $pid, $item );
|
723 |
+
//}
|
724 |
+
|
725 |
+
if($pid = $this->getProductId ( $sku )){
|
726 |
+
|
727 |
+
|
728 |
+
|
729 |
+
//remove old attributes
|
730 |
+
$this->destroyAttributes ( $pid );
|
731 |
+
|
732 |
+
//create new ones
|
733 |
+
try {
|
734 |
+
fwrite ($this->fp,"done");
|
735 |
+
|
736 |
+
$this->createAttributes ( $pid, $item ); // corrupts the database - will check it out
|
737 |
+
$this->commitTransaction ();
|
738 |
+
fwrite ($this->fp,"done");
|
739 |
+
} catch (Exception $e){
|
740 |
+
throw new Exception ( Mage::helper ( 'sqlupdate' )->__($e->getMessage()) );
|
741 |
+
}
|
742 |
+
|
743 |
+
//update website
|
744 |
+
$this->updateWebSite ( $pid, $item );
|
745 |
+
//update stock
|
746 |
+
$this->updateStock ( $pid, $item );
|
747 |
+
}
|
748 |
//ok,we're done
|
749 |
+
|
750 |
+
|
751 |
} catch ( Exception $e ) {
|
752 |
+
echo $e->getMessage();
|
753 |
+
fwrite($this->fp, $e->getMessage()."\n") ;
|
754 |
//if anything got wrong, rollback
|
755 |
$this->rollbackTransaction ();
|
756 |
}
|
757 |
}
|
|
|
758 |
/**
|
759 |
* main import function
|
760 |
* @param string $csvfile : csv file name to import
|
761 |
* @param bool $reset : destroy all products before import
|
762 |
*/
|
763 |
public function import($csvfile, $reset = false) {
|
764 |
+
$stimer = explode ( ' ', microtime () );
|
765 |
+
$stimer = $stimer [1] + $stimer [0];
|
766 |
+
if (file_exists ( $this->logfilename )) {
|
767 |
+
unlink ( $this->logfilename );
|
768 |
+
}
|
769 |
+
$this->fp = fopen ( $this->logfilename, 'a' ) or die ( "can't open file: " . $this->logfilename );
|
770 |
+
fwrite ( $this->fp , "Update Started " . date ( "Y-m-d H:i:s" ) . "\n" );
|
771 |
if (! isset ( $csvfile )) {
|
772 |
die ( "No csv file set" );
|
773 |
}
|
783 |
//if reset
|
784 |
if ($this->reset) {
|
785 |
//clear all products
|
786 |
+
//$this->clearProducts ();
|
787 |
}
|
788 |
//open csv file
|
789 |
$f = fopen ( $csvfile, "r" );
|
812 |
$item = array_combine ( $this->cols, $row );
|
813 |
if (is_array ( $item )) {
|
814 |
//import item
|
815 |
+
$this->updateItem ( $item );
|
816 |
//intermediary measurement
|
817 |
} else {
|
818 |
+
fwrite ($this->fp, "ERROR - LINE $cnt - INVALID ROW :" . count ( $row ) . "/" . count ( $this->cols ) . " cols found\n" );
|
819 |
}
|
820 |
if ($cnt % $mstep == 0) {
|
821 |
$tend = microtime ( true );
|
822 |
+
fwrite ( $this->fp, $cnt . " - " . ($tend - $tstart) . " - " . ($tend - $tdiff)."\n" );
|
823 |
$tdiff = microtime ( true );
|
824 |
}
|
825 |
} catch ( Exception $e ) {
|
826 |
+
fwrite ( $this->fp, "ERROR - LINE $cnt - " . $e->getMessage () . "\n" );
|
827 |
}
|
828 |
|
829 |
}
|
831 |
fclose ( $f );
|
832 |
$this->updateIndexes ();
|
833 |
$tend = microtime ( true );
|
834 |
+
fwrite ( $this->fp, $cnt . "-" );
|
835 |
+
fwrite ( $this->fp, " Speed Average " . ceil ( ($cnt * 60) / ($tend - $tstart) ) . " rec/mn" . "\n" );
|
836 |
flush ();
|
837 |
+
$etimer = explode ( ' ', microtime () );
|
838 |
+
$etimer = $etimer [1] + $etimer [0];
|
839 |
+
fwrite ( $this->fp, "Update completed in " );
|
840 |
+
fwrite ( $this->fp, $etimer - $stimer . " Seconds === " . date ( "Y-m-d H:i:s" ) . "\n" );
|
841 |
+
@fclose ( $this->fp );
|
842 |
$this->disconnectFromMagento ();
|
843 |
}
|
844 |
}
|
845 |
+
|
app/code/community/Ayasoftware/SQLupdate/Model/Observer.php
CHANGED
@@ -12,24 +12,31 @@ class Ayasoftware_SQLupdate_Model_Observer extends Mage_Core_Model_Abstract
|
|
12 |
public function batchUpdate ($observer)
|
13 |
{
|
14 |
$reset = false;
|
15 |
-
$
|
16 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
$csvfile = Mage::getBaseDir() . DS . $updateFeed;
|
18 |
$sqlimport->import($csvfile, $reset);
|
19 |
}
|
20 |
-
public function changeScheduling($timescheduled)
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
35 |
}
|
12 |
public function batchUpdate ($observer)
|
13 |
{
|
14 |
$reset = false;
|
15 |
+
$dbhelper = Mage::getModel('sqlupdate/DBHelper');
|
16 |
+
$sqlimport = Mage::getModel('sqlupdate/massimport');
|
17 |
+
$updateFeed = Mage::getStoreConfig('sqlupdate/sqlupdateSettings/feedname');
|
18 |
+
$host = Mage::getStoreConfig('sqlupdate/ftpSettings/host');
|
19 |
+
if ($host) {
|
20 |
+
echo "Downloading the file from the FTP server\n";
|
21 |
+
$dbhelper->downloadRemoteFile($updateFeed);
|
22 |
+
}
|
23 |
$csvfile = Mage::getBaseDir() . DS . $updateFeed;
|
24 |
$sqlimport->import($csvfile, $reset);
|
25 |
}
|
26 |
+
public function changeScheduling ($timescheduled)
|
27 |
+
{
|
28 |
+
$timecreated = strftime("%Y-%m-%d %H:%M:%S", mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")));
|
29 |
+
$jobCode = 'direct_sql_update';
|
30 |
+
try {
|
31 |
+
// Delete pending or completed cron jobs
|
32 |
+
$sql_update = Mage::getModel('cron/schedule')->getCollection()->addFieldToFilter('job_code', array('eq' => array($jobCode)))->load();
|
33 |
+
foreach ($sql_update->getIterator() as $record) {
|
34 |
+
$record->delete();
|
35 |
+
}
|
36 |
+
$schedule = Mage::getModel('cron/schedule');
|
37 |
+
$schedule->setJobCode($jobCode)->setCreatedAt($timecreated)->setScheduledAt($timescheduled)->setStatus(Mage_Cron_Model_Schedule::STATUS_PENDING)->save();
|
38 |
+
} catch (Exception $e) {
|
39 |
+
throw new Exception(Mage::helper('cron')->__('Unable to save Cron.'));
|
40 |
+
}
|
41 |
+
}
|
42 |
}
|
app/code/community/Ayasoftware/SQLupdate/etc/config.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<config>
|
2 |
<modules>
|
3 |
<Ayasoftware_SQLupdate>
|
4 |
-
<version>1.4.1.
|
5 |
<depends>
|
6 |
<!-- no dependencies -->
|
7 |
</depends>
|
1 |
<config>
|
2 |
<modules>
|
3 |
<Ayasoftware_SQLupdate>
|
4 |
+
<version>1.4.1.2</version>
|
5 |
<depends>
|
6 |
<!-- no dependencies -->
|
7 |
</depends>
|
app/code/community/Ayasoftware/SQLupdate/etc/system.xml
CHANGED
@@ -83,6 +83,48 @@
|
|
83 |
</rowsnumber>
|
84 |
</fields>
|
85 |
</sqlupdateSettings>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
</groups>
|
87 |
</sqlupdate>
|
88 |
</sections>
|
83 |
</rowsnumber>
|
84 |
</fields>
|
85 |
</sqlupdateSettings>
|
86 |
+
|
87 |
+
<ftpSettings translate="label">
|
88 |
+
<label>FTP Settings</label>
|
89 |
+
<sort_order>340</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<fields>
|
93 |
+
<host translate="label">
|
94 |
+
<label>FTP host</label>
|
95 |
+
<frontend_type>text</frontend_type>
|
96 |
+
<sort_order>10</sort_order>
|
97 |
+
<show_in_default>1</show_in_default>
|
98 |
+
<show_in_website>1</show_in_website>
|
99 |
+
<comment>FTP Host: eg: ftp.yourdomain.com</comment>
|
100 |
+
</host>
|
101 |
+
<username translate="label">
|
102 |
+
<label>FTP Username</label>
|
103 |
+
<frontend_type>text</frontend_type>
|
104 |
+
<sort_order>20</sort_order>
|
105 |
+
<show_in_default>1</show_in_default>
|
106 |
+
<show_in_website>1</show_in_website>
|
107 |
+
<comment>FTP username</comment>
|
108 |
+
</username>
|
109 |
+
<password translate="label">
|
110 |
+
<label>FTP Password</label>
|
111 |
+
<frontend_type>password</frontend_type>
|
112 |
+
<sort_order>30</sort_order>
|
113 |
+
<show_in_default>1</show_in_default>
|
114 |
+
<show_in_website>1</show_in_website>
|
115 |
+
<comment>FTP Password</comment>
|
116 |
+
</password>
|
117 |
+
<directory translate="label">
|
118 |
+
<label>FTP directory</label>
|
119 |
+
<frontend_type>text</frontend_type>
|
120 |
+
<sort_order>32</sort_order>
|
121 |
+
<show_in_default>1</show_in_default>
|
122 |
+
<show_in_website>1</show_in_website>
|
123 |
+
<comment>FTP directory (eg: /files/inventory)</comment>
|
124 |
+
</directory>
|
125 |
+
</fields>
|
126 |
+
</ftpSettings>
|
127 |
+
|
128 |
</groups>
|
129 |
</sqlupdate>
|
130 |
</sections>
|
app/design/adminhtml/default/default/template/sqlupdate/schedule.phtml
CHANGED
@@ -51,6 +51,53 @@ $timecreated = $timecreated = date("Y-m-d H:i:s");
|
|
51 |
<h2>How to use this module</h2>
|
52 |
<h4 class="icon-head head-edit-form fieldset-legend"><?=$this->__ ( 'The SQL Update is by default Scheduled to be automatically run at midnight 00:00 ' )?></h4>
|
53 |
<h4 class="icon-head head-edit-form fieldset-legend"><?=$this->__ ( 'If you pick a new Scheduling for your SQL Update, we will replace the default (only this time) ' )?></h4>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
</div>
|
55 |
<script type="text/javascript">
|
56 |
var editForm = new varienForm('edit_form');
|
51 |
<h2>How to use this module</h2>
|
52 |
<h4 class="icon-head head-edit-form fieldset-legend"><?=$this->__ ( 'The SQL Update is by default Scheduled to be automatically run at midnight 00:00 ' )?></h4>
|
53 |
<h4 class="icon-head head-edit-form fieldset-legend"><?=$this->__ ( 'If you pick a new Scheduling for your SQL Update, we will replace the default (only this time) ' )?></h4>
|
54 |
+
|
55 |
+
<h2>Cron Status</h2>
|
56 |
+
|
57 |
+
<?php
|
58 |
+
|
59 |
+
$jobCode = "direct_sql_update";
|
60 |
+
|
61 |
+
?>
|
62 |
+
<table border="1" class="entry-edit" cellspacing="0" cellpadding="0">
|
63 |
+
<tr>
|
64 |
+
<td>Job Code</td>
|
65 |
+
<td>Status</td>
|
66 |
+
<td>Created At</td>
|
67 |
+
<td>Scheduled At</td>
|
68 |
+
<td>Finished At</td>
|
69 |
+
</tr>
|
70 |
+
<?php
|
71 |
+
try {
|
72 |
+
$sql_update = Mage::getModel ( 'cron/schedule' )->getCollection ()->addFieldToFilter ( 'job_code', array ('in' => array ($jobCode ) ) );
|
73 |
+
|
74 |
+
foreach ( $sql_update->getIterator () as $record ) {
|
75 |
+
echo "<tr>";
|
76 |
+
//$record->load ();
|
77 |
+
echo "<td>";
|
78 |
+
echo $record->getJobCode ();
|
79 |
+
echo "</td>";
|
80 |
+
echo "<td>";
|
81 |
+
echo $record->getStatus ();
|
82 |
+
echo "</td>";
|
83 |
+
echo "<td>";
|
84 |
+
echo $record->getCreatedAt ();
|
85 |
+
echo "</td>";
|
86 |
+
echo "<td>";
|
87 |
+
echo $record->getScheduledAt ();
|
88 |
+
echo "</td>";
|
89 |
+
echo "<td>";
|
90 |
+
echo $record->getFinishedAt ();
|
91 |
+
echo "</td>";
|
92 |
+
echo "</tr>";
|
93 |
+
}
|
94 |
+
|
95 |
+
} catch ( Exception $e ) {
|
96 |
+
throw new Exception ( Mage::helper ( 'cron' )->__ ( 'Unable to save Cron.' ) );
|
97 |
+
}
|
98 |
+
echo "</table>";
|
99 |
+
?>
|
100 |
+
|
101 |
</div>
|
102 |
<script type="text/javascript">
|
103 |
var editForm = new varienForm('edit_form');
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Speedup_your_catalog_update_using_our_Direct_SQL_Update_extension</name>
|
4 |
-
<version>1.4.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
|
7 |
<channel>community</channel>
|
@@ -23,15 +23,16 @@ Extension Features:
|
|
23 |
- No programming Skills required
|
24 |
- User-friendly interface
|
25 |
- Provide a detailed updates report saved to a log File.
|
|
|
26 |
- Based on Dweeves script (Follow thread )</description>
|
27 |
<notes>added task status to check the direct SQL update status. No need anymore to check your cron_schedule table: 
|
28 |

|
29 |
Status: pending, error, missed or succes
|
30 |
Created At, Scheduled and At Finished At times</notes>
|
31 |
<authors><author><name>EL Hassan Matar</name><user>auto-converted</user><email>support@ayasoftware.com</email></author></authors>
|
32 |
-
<date>2011-06-
|
33 |
-
<time>
|
34 |
-
<contents><target name="magecommunity"><dir name="Ayasoftware"><dir name="SQLupdate"><dir name="Block"><dir name="System"><file name="Html.php" hash="9b9e6aa706535e58e86ea1260910cb17"/></dir></dir><dir name="Helper"><file name="Data.php" hash="ecbe414b1c243fb379266dbd15047993"/></dir><dir name="Model"><file name="DBHelper.php" hash="
|
35 |
<compatible/>
|
36 |
<dependencies/>
|
37 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Speedup_your_catalog_update_using_our_Direct_SQL_Update_extension</name>
|
4 |
+
<version>1.4.1.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
|
7 |
<channel>community</channel>
|
23 |
- No programming Skills required
|
24 |
- User-friendly interface
|
25 |
- Provide a detailed updates report saved to a log File.
|
26 |
+
- Download inventory file from remote server.
|
27 |
- Based on Dweeves script (Follow thread )</description>
|
28 |
<notes>added task status to check the direct SQL update status. No need anymore to check your cron_schedule table: 
|
29 |

|
30 |
Status: pending, error, missed or succes
|
31 |
Created At, Scheduled and At Finished At times</notes>
|
32 |
<authors><author><name>EL Hassan Matar</name><user>auto-converted</user><email>support@ayasoftware.com</email></author></authors>
|
33 |
+
<date>2011-06-10</date>
|
34 |
+
<time>21:23:03</time>
|
35 |
+
<contents><target name="magecommunity"><dir name="Ayasoftware"><dir name="SQLupdate"><dir name="Block"><dir name="System"><file name="Html.php" hash="9b9e6aa706535e58e86ea1260910cb17"/></dir></dir><dir name="Helper"><file name="Data.php" hash="ecbe414b1c243fb379266dbd15047993"/></dir><dir name="Model"><file name="DBHelper.php" hash="c169d4385b9fe022f1b378c4a5004750"/><file name="Massimport.php" hash="e83debeefef050d3fbed36bbf50eef07"/><file name="Observer.php" hash="3ecc4ff834d902fd3467fbc9510e4722"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SqlupdateController.php" hash="8f4ff5e1322690b832bca7de213b0987"/></dir></dir><dir name="etc"><file name="config.xml" hash="ef235ae5ec119afcfdd5a932a7d710ac"/><file name="system.xml" hash="d41095ac60902e37bf08f22fd5dbe1d5"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sqlupdate.xml" hash="c71a6d533ec8dd5ec93d52b3d8d2d316"/></dir><dir name="template"><dir name="sqlupdate"><file name="schedule.phtml" hash="836d182873a1cbc68ce1a58806659dc7"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="ayasoftware"><file name="behaviors.js" hash="803fbd82d3a132633288f31edb12f5ca"/><file name="behaviour.js" hash="782fb396b22aff61b4e4b03d144fd1d7"/><file name="datepicker.css" hash="7889f5fe2cf572b8bce80d7d8d1ac5c2"/><file name="datepicker.js" hash="56234bdc9ebbb7f58da1344664f9bbb1"/><file name="datetimepicker.js" hash="39a363522d2654d5a35a7469a753481f"/><file name="prototype-1.6.0.2.js" hash="6f804651639c56d134e892125179b76d"/><file name="prototype-base-extensions.js" hash="eec08721b9e8b4fd05ecd20653978355"/><file name="prototype-date-extensions.js" hash="babd1760797624cbac3479a16647a5fd"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ayasoftware_SQLupdate.xml" hash="8ef6e3f0f41e0960a02484cefd1afd48"/></dir></target></contents>
|
36 |
<compatible/>
|
37 |
<dependencies/>
|
38 |
</package>
|