Class: Spree::Themes::DuplicateComponentsJob
- Defined in:
- app/jobs/spree/themes/duplicate_components_job.rb
Instance Method Summary collapse
-
#perform(theme_id, duplicated_theme_id) ⇒ Object
We need to duplicate: 1.
Instance Method Details
#perform(theme_id, duplicated_theme_id) ⇒ Object
We need to duplicate:
-
Theme files + sections with pageable_type Spree::Theme.
-
Duplicate pages + sections.
-
Adjust linkable on page links for Spree::PageSection and Spree::PageBlock parents and Spree::Page linkable.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/jobs/spree/themes/duplicate_components_job.rb', line 11 def perform(theme_id, duplicated_theme_id) theme = Spree::Theme.find(theme_id) duplicated_theme = Spree::Theme.find(duplicated_theme_id) ApplicationRecord.transaction do duplicated_pages = duplicate_pages(theme, duplicated_theme) # Duplicated links on pages and blocks have references to pages from the previous theme # We need to look for a duplicated page and update the link with it duplicate_layout_sections(theme, duplicated_theme) adjust_page_links(theme, duplicated_theme, duplicated_pages) duplicated_theme.update!(ready: true) end end |