25
EASY MAGENTO SYNCHRONIZATION Presented by & Mage::day(2013); // Modena - 8 Novembre 2013 Alessandro Ronchi Roberto Gambuzzi

Mageploy, easily keep track of changes and deploy synchronization between different magento environments

Embed Size (px)

DESCRIPTION

Mageploy, easily keep track of changes and deploy synchronization between different magento environments

Citation preview

Page 1: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

EASY MAGENTO SYNCHRONIZATIONPresented by &

Mage::day(2013); // Modena - 8 Novembre 2013

Alessandro Ronchi Roberto Gambuzzi

Page 2: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

CHI SIAMO

Membri e Fondatori del

Magento Certified DevelopersColleghi in

PUG MoRe

@webgriffe

Page 3: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

PERCHÉ E COME È NATOPROBLEMA

Propagare modifiche in Admin Panel su diversi ambienti

SOLUZIONI POSSIBILIA mano: time consuming, error prone, costosoUpgrade Script: time consuming, e conflitti su featurebranchDB centralizzato: no offline, concorrenza spietataSelenium: selettori da correggere e non cross-platformMageFlow (?): "MageFlow Beta is launching in December"Mageploy: niente codice, distribuito, time-saving

Page 4: Mageploy, easily keep track of changes and deploy synchronization between different magento environments
Page 5: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME FUNZIONALIVE DEMO

Page 6: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME FUNZIONASTATUS E RUN (GIT PULL SU ALTRO AMBIENTE)

vagrant@precise32:/var/www/mag1800$ git pullremote: Counting objects: 27, done.remote: Compressing objects: 100% (4/4), done.remote: Total 14 (delta 3), reused 14 (delta 3)Unpacking objects: 100% (14/14), done.From github.com:pug-more/demo-mageday2013ea5a492..7e44329 master -> origin/masterUpdating ea5a492..7e44329Fast-forwardvar/mageploy/mageploy_all.csv | 1 +1 files changed, 1 insertions(+)

Page 7: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME FUNZIONASTATUS

vagrant@precise32:/var/www/mag1800$ php shell/mageploy.php -s

Mageploy v 1.1.9 - tracking is active - user is roberto

Pending Actions list:ID: 1 - Save new Magazzino 'mag-001' (aronchi on Mon Oct 28 09:22:56 2013)

Total pending actions: 1

RUN

vagrant@precise32:/var/www/mag1800$ php shell/mageploy.php -r

Mageploy v 1.1.9 - tracking is active - user is roberto

Action ID #1 - success Elemento creato con successo

Executed actions: 1/1

Page 8: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME FUNZIONAPANNELLO DI ADMIN

Page 9: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME FUNZIONAPANNELLO DI ADMIN (DELETE)

Page 10: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME FUNZIONAPANNELLO DI ADMIN (COMMIT E PUSH DELLA DELETE)vagrant@precise32:/var/www/mag1800$ git status# On branch master# Changes not staged for commit:## modified: var/mageploy/mageploy_all.csv#

vagrant@precise32:/var/www/mag1800$ git commit -am "Eliminato magazzino"[master eddeb26] Eliminato magazzino1 file changed, 1 insertion(+)

vagrant@precise32:/var/www/mag1800$ git pushCounting objects: 9, done.Delta compression using up to 2 threads.Compressing objects: 100% (3/3), done.Writing objects: 100% (5/5), 440 bytes, done.Total 5 (delta 2), reused 0 (delta 0)To [email protected]:pug-more/demo-mageday2013.git357d4bf..eddeb26 master -> master

Page 11: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME FUNZIONAPANNELLO DI ADMIN (RICEZIONE DELLE DELETE DA PARTE

PRIMO DEV)

alessandro@Kowalski:~/NetBeansProjects/mage1800$ php shell/mageploy.php -s

Mageploy v 1.1.9 - tracking is active - user is aronchi

Pending Actions list:ID: 2 - Delete existing Magazzino 'mag-001' (roberto on Mon Oct 28 10:21:20 2013)

Total pending actions: 1

alessandro@Kowalski:~/NetBeansProjects/mage1800$ php shell/mageploy.php -r

Mageploy v 1.1.9 - tracking is active - user is aronchi

Action ID #2 - success Elemento cancellato con successo

Executed actions: 1/1

Page 12: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME È SVILUPPATOTHE MAGENTO WAY

Request Funnel: registra le invocazioni alle Action a cui èassociato un TrackerTracker: implementa encoding e decoding dei parametridelle Action convertendo gli ID specifici di ogni ambiente inUUIDUUID (Universally Unique Identifier): identificaunivocamente le entità secondo una logica specifica;implementazione potenzialmente complessa che puòrichiedere vincoliConfig: un modulo può aggiungere i propri Trackerdichiarandoli nel config.xml

Page 13: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME È SVILUPPATO

Page 14: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME È SVILUPPATODICHIARAZIONE DI UN TRACKER NEL CONFIG.XML

<config> ... <default> ... <mageploy> <actions> <demo_mageday2013> <disabled>0</disabled> <class>Demo_Mageday2013_Model_Mageploy_Action_Magazzini</class> </demo_mageday2013> </actions> </mageploy> ... </default> ...</config>

Page 15: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME È SVILUPPATOLA CLASSE CHE IMPLEMENTA IL TRACKER

EstendePugMoRe_Mageploy_Model_Action_Abstract

Implementazione minima per registrare le informazioniutili nel log utilizzando la funzione match() della classe

base<?phpclass Demo_Mageday2013_Model_Mageploy_Action_Magazzini extends PugMoRe_Mageploy_Model_Action_Abstract{ const VERSION = '1';

protected $_code = 'demo_mageday13_magazzini'; protected $_blankableParams = array('key', 'form_key');

protected function _getVersion() { return Mage::helper('pugmore_mageploy')->getVersion(2).'.'.self::VERSION; }}

Page 16: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME È SVILUPPATOLA FUNZIONE MATCH() DELLA CLASSE BASE

<?phppublic function match() { $h = Mage::helper('pugmore_mageploy'); $h->log("Module name: %s", $this->_request->getModuleName()); $h->log("Controller name: %s", $this->_request->getControllerName()); $h->log("Action name: %s", $this->_request->getActionName()); $h->log("Request Parameters: %s", print_r($this->_request->getParams(), true)); return false;}

Page 17: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME È SVILUPPATOINFORMAZIONI NEL LOG DOPO UNA SAVE ACTION

NEW2013-10-28T08:44:27+00:00 DEBUG (7): Module name: demmag20132013-10-28T08:44:27+00:00 DEBUG (7): Controller name: adminhtml_magazzini2013-10-28T08:44:27+00:00 DEBUG (7): Action name: save2013-10-28T08:44:27+00:00 DEBUG (7): Request Parameters: Array( [key] => 1da213e76...519158b044a [form_key] => v11Moz5RhX5U84O3 [codice] => mag-001 [nome] => MBCenter [nazione] => IT [citta] => Modena [cap] => 41100 [indirizzo] => viale Virgilio, 52/E [email] => [email protected] )

DELETE2013-10-28T09:00:28+00:00 DEBUG (7): Module name: demmag20132013-10-28T09:00:28+00:00 DEBUG (7): Controller name: adminhtml_magazzini2013-10-28T09:00:28+00:00 DEBUG (7): Action name: delete2013-10-28T09:00:28+00:00 DEBUG (7): Request Parameters: Array( [id] => 1 [key] => f661970...23ce30a6)

Page 18: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME È SVILUPPATOCLASSE COMPLETA PER IL TRACKING DEI MAGAZZINI

su GitHub

Page 19: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

<?phpclass Demo_Mageday2013_Model_Mageploy_Action_Magazzini extends PugMoRe_Mageploy_Model_Action_Abstract{ const VERSION = '1';

protected $_code = 'demo_mageday13_magazzini'; protected $_blankableParams = array('key', 'form_key');

protected function _getVersion() { return Mage::helper('pugmore_mageploy')->getVersion(2) . '.' . self::VERSION; }

public function match() { if (!$this->_request) { return false; }

if ($this->_request->getModuleName() == 'demmag2013') { if ($this->_request->getControllerName() == 'adminhtml_magazzini') { if (in_array($this->_request->getActionName(), array('save', 'delete'))) { return true; } } }

return false; }

public function encode() {

Page 20: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

COME È SVILUPPATORISULTATO DEL TRACKING (CSV)

col1: 1382952176col2: aronchicol3: Save new Magazzino 'mag-001'col4: Demo_Mageday2013_Model_Mageploy_Action_Magazzinicol5: Demo_Mageday2013col6: adminhtml_magazzinicol7: savecol8: o3OntzOjY6ImNvZGljZSI7c...tb3JlLmdydXNwLm9yZyI7fQ==col9: 1.1.1

Page 21: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

CONFLITTIScenario: due programmatori hanno creato un magazzinocon lo stesso codice. Il primo ha già fatto commit e push.

Il secondo si ritrova nello stato seguente:

alessandro@Kowalski:~/NetBeansProjects/mage1800$ git pullremote: Counting objects: 9, done.remote: Compressing objects: 100% (1/1), done.remote: Total 5 (delta 2), reused 5 (delta 2)Unpacking objects: 100% (5/5), done.From github.com:pug-more/demo-mageday2013 4683099..587da1b master -> origin/masterAuto-merging var/mageploy/mageploy_all.csvCONFLICT (content): Merge conflict in var/mageploy/mageploy_all.csvAutomatic merge failed; fix conflicts and then commit the result.

Page 22: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

CONFLITTICosa troveremo nel mageploy_all.csv ?

<<<<<<< HEAD1382956530,aronchi,"Save new Magazzino 'mag-001'",Demo_Mageday2013_Model_Mageploy_Action_Magazzini=======1382956146,roberto,"Save new Magazzino 'mag-001'",Demo_Mageday2013_Model_Mageploy_Action_Magazzini>>>>>>> 587da1b12229317342038ef3854357f2e1c650fc

Come si risolve? Parlandosi :-)

Un conflitto di questo tipo è il risultato di una mancatacomunicazione; va risolto scegliendo l'azione da mantenere

o eliminando entrambe e registrandone una nuova.

Page 23: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

CONCLUSIONIAS-IS

Attribute TrackerCategory TrackerCMS TrackerStoreSystem Config (sperimentale)

TO BEPiù Tracker possibiliControllo dei vincoliTest automatici

Page 24: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

?Q & (HOPEFULLY) A

Page 25: Mageploy, easily keep track of changes and deploy synchronization between different magento environments

GRAZIE!RIMANIAMO IN CONTATTO...

Mageploy:

Twitter: -

GitHub: -

Blog:

PUG MoRe:

mageploy.com

@aleron75 @pug_more

github.com/aleron75 github.com/pug-more

www.magentocommunity.it

http://more.grusp.org

Magento Italia on G+