mage titans usa 2016 - igor melnykov - staging and preview

32
© 2016 Magento, Inc. Page | 2

Upload: stacey-whitney

Post on 08-Jan-2017

60 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 2

Page 2: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 5

Agenda

1. Overview2. Staging Architecture3. Sample Module with Staging4. QA

Page 3: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 6

Overview

Page 4: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 7

Making Content Changes on Magento EE < 2.1

Make changes on

separate copy of a

store

Make sure changes look

good

On scheduled

date replicate changes on

live store

Make sure changes look

good

Troubleshoot and fix issues on live site if not replicated

correctly

Page 5: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 8

Staging and Preview

Make changes in one place

Make sure changes look good using

preview

Schedule when

changes applied

Changes applied

automatically

Page 6: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 10

Staging Campaigns• Create, edit, and delete updates to:

– Products – prices, page designs, descriptions, images, and more

– Categories – menu and display options, which categories are enabled

– CMS Content – page content and layouts

– Promotions – catalog and shopping cart price rules

– Additional entities with customization

• Group individual updates into campaigns for easier management

• Schedule an unlimited number of updates

Updating product content with quick access to other scheduled changes

Page 7: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 11

Staging Dashboard• Manage all updates from a single

dashboard with grid and timeline views

• Easily monitor key campaign information:

– Start and end dates

– Campaign components

– Campaign status• Drill down into campaigns to preview,

make edits or delete updates

Dashboard grid view – complete list of all campaigns and their components within a specified date range

Page 8: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 12

Staging Timeline DashboardDashboard timeline view – shows all current and upcoming campaigns in a calendar, making it easy to confirm you have a coordinated merchandising strategy in place

Page 9: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 13

Preview Updates• Preview and verify updates by date and store view• Screen the user experience through checkout without placing orders• Share links with others to preview pages

Page 10: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 14

Staging Architecture

Page 11: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 15

The Big Picture

Changes to Schema

From Condition Renderer

Entity Manager

Sequence Manager Version Manager

Persistence Operations for Stageable Entities

*Staging Modules Cron Jobs BusinessLogic

PersistenceLayer

Database

Configurable Ui Elements Ui

Page 12: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 16

Database Schema

row_id PK int

entity_id int

created_in int

updated_in int

sku varchar

… …

value_id int

attribtue_id int

store_id int

row_id int

value varchar

catalog_product_entity_varchar

catalog_product_entity

product_id int

website_id int

catalog_product_website

Stagable attributes and relationslinked by row_id

Non stagable attributeslinked by entity_id (sequence id)

id bigint

start_time datetime

name varchar

description int

rollback_id bigint

is_campaign tinyint

is_rollback tinyint

moved_to bigint

stagign_update

sequence_value

int

sequence_product

Page 13: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 17

Entity Version

created_in – version from which update is active, default 1updated_in – version to which update is active, default 2147483647

1 and 2147483647 are left and right margins for the version

+------+---------+----------+----------+---------+-----+-------------------------------+|row_id|entity_id|created_in|updated_in|name |price|short_description |+------+---------+----------+----------+---------+-----+-------------------------------+| 1| 1| 1| 999|Product 1|10.99|Product 1 short description |+------+---------+----------+----------+---------+-----+-------------------------------+| 2| 2| 200| 999|Product 2|15.00|Product 2 short description |+------+---------+----------+----------+---------+-----+-------------------------------+

Page 14: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 18

Select Current Version

staging_update+---+-------------------+-----------------------------------+|id | start_time|name |+---+-------------------+-----------------------------------+|100|2016-08-31 04:05:00|Update 1 for Product 1 |+---+-------------------+-----------------------------------+|200|2016-09-12 04:05:00|Update 2 for Product 1 |+---+-------------------+-----------------------------------+|300|2016-09-18 04:05:00|Update 3 for Product 1 |+-----------------------+-----------------------------------+

SELECT * FROM staging_update WHERE start_time <= '2016-09-12 04:05:00' DESC LIMIT 1

2016-09-12 04:05:00 is current date and time

Page 15: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 19

Select Active Updates

+------+---------+----------+----------+---------+-----+-------------------------------+|row_id|entity_id|created_in|updated_in|name |price|short_description |+------+---------+----------+----------+---------+-----+-------------------------------+| 1| 1| 1| 999|Product 1|10.99|Product 1 short description |+------+---------+----------+----------+---------+-----+-------------------------------+| 2| 2| 1| 200|Product 2|15.00|Product 2 short description |+------+---------+----------+----------+---------+-----+-------------------------------+| 3| 2| 200| 300|Product 2|12.00|Product 2 short description |+------+---------+----------+----------+---------+-----+-------------------------------+| 4| 2| 300| 999|Product 2|12.00|Product 2 new short description|+------+---------+----------+----------+---------+-----+-------------------------------+

1 300200 999

Product 1

Product 2Price updated Description updated

SELECT * FROM catalog_product_entity WHERE created_in <= 200 AND updated_in > 200

Page 16: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 20

Permanent Update

catalog_product_entity+------+---------+----------+----------+---------+-----+-------------------------------+|row_id|entity_id|created_in|updated_in|name |price|short_description |+------+---------+----------+----------+---------+-----+-------------------------------+| 1| 1| 100| 999|Product 1|10.99|Product 1 short description |+------+---------+----------+----------+---------+-----+-------------------------------+

catalog_product_entity – after creating permanent update+------+---------+----------+----------+---------+-----+-------------------------------+|row_id|entity_id|created_in|updated_in|name |price|short_description |+------+---------+----------+----------+---------+-----+-------------------------------+| 1| 1| 100| 200|Product 1|10.99|Product 1 short description |+------+---------+----------+----------+---------+-----+-------------------------------+| 2| 1| 200| 999|Product 1|12.00|Product 1 new short description|+------+---------+----------+----------+---------+-----+-------------------------------+

staging_update+---+-----------------------------------+-----------+|id |name |is_rollback|+---+-----------------------------------+-----------+|200|Update for Product 1 | 0|+---------------------------------------+-----------+

Page 17: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 21

Temporary Update

catalog_product_entity – after creating temporary update+------+---------+----------+----------+---------+-----+-------------------------------+|row_id|entity_id|created_in|updated_in|name |price|short_description |+------+---------+----------+----------+---------+-----+-------------------------------+| 1| 1| 100| 200|Product 1|10.99|Product 1 short description |+------+---------+----------+----------+---------+-----+-------------------------------+| 2| 1| 200| 300|Product 1|12.00|Product 1 new short description|+------+---------+----------+----------+---------+-----+-------------------------------+| 3| 1| 300| 999|Product 1|10.99|Product 1 short description |+------+---------+----------+----------+---------+-----+-------------------------------+

staging_update+---+-----------------------------------+-----------+|id |name |is_rollback|+---+-----------------------------------+-----------+|200|Update for Product 1 | 0|+---------------------------------------+-----------+|300|Rollback for “Update for Product 1”| 1|+---------------------------------------+-----------+

Page 18: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 22

Entity Manager

Entity Manager

Operations

Main Entity EAV AttributesRelation and

Extension Attributes

Read, Create, Update, Delete, CheckIfExists

Persistence of main entity

Persistence of EAV attributes

Magento\Framework\EntityManager

Handlers

Persistence of related and extension attributes, delegates all work to

handlers

Page 19: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 23

Operations for Staging

• Redefined in the DI for each stageable entity• In addition to persistence of main entity perform additional actions

– Manage campaigns– Manage updates

Page 20: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 24

From SQL Condition Renderer

You don’t need to specify active version, \Magento\Staging\Model\Select\FromRenderer modifies select queries and you always get active version in application.

SELECT * FROM catalog_product_entity WHERE created_in <= version AND updated_in > version

Load entity by sequence id (in our case, for product - entity_id), not row_id

Page 21: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 25

Version Manager and Sequence Manager

Version Manager – get current version in the system

Sequence Manager – generates sequence id, unique identifier for all of the versions of the same entity

Page 22: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 26

Cron Jobs

The following actions executed by cron jobs• Apply updates – make updates visible when they become active• Move updates from one campaign to another – when you change

effective dates for the campaign, Magento creates new campaign and move updates to the new campaign using cron

• Clean up old updates

Page 23: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 27

How Does Preview Work

• Version Manager provides requested version• Calculates page data on fly, it's always up to date• Preview uses all system cache types, except FPC (Full Page

Cache)• Indexes (as a database cache) also skipped at preview

Page 24: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 29

Sample Module with Staging

Page 25: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 30

Requirements

• Need to be able display and manage blog posts• Post need to have the following fields: title, description• Module should work in both Community and Enterprise editions• Enterprise edition need to allow

– Schedule updates for posts– See upcoming updates in staging dashboard– Preview changes

Page 26: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 31

Persistence

• Different database schema in Community and Enterprise• Different configuration for Entity Manager• Staging specific operations for Entity Manager instead of default

ones

Page 27: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 32

Ui

• Configure and add to form reusable staging Ui components– Upcoming updates form modal and grid– Edit update form– Select update grid on edit update form– Remove form– Select update grid on remove form

• Add controllers to handle save and delete operations for updates

Page 28: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 33

API

Provide API for managing updates

interface PostStagingInterface{ public function schedule(PostInterface $post, $version, $arguments = []);

public function unschedule(PostInterface $post, $version);}

Page 29: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 34

Resources

Page 30: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 35

Resources

• https://github.com/melnikovi/magento2-samples• http://devdocs.magento.com/guides/v2.1/extension-dev-guide/stagin

g/Staging.html

Page 31: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 36

Q&A

Page 32: Mage Titans USA 2016 - Igor Melnykov - Staging and Preview

© 2016 Magento, Inc. Page | 37

Thank You

[email protected]