Drupal 10 Assist: Drupal 10 Upkeep and Assist Service Merging Entities Throughout a Migration to 8

Migrations present a superb alternative to take inventory of your present content material mannequin. You’re already neck deep in Drupal Development Service underlying buildings when planning for information migrations, so whilst you’re in there, you would possibly as effectively guarantee Drupal Development Service new vacation spot content material sorts will serve you going ahead and never current Drupal Development Service similar issues. Clean Drupal Development Service edges. Fill in some gaps. Get as a lot profit out of Drupal Development Service migration as you may, since you don’t wish to end up doing one other one a yr from now. This text will stroll by means of an instance of migrating a part of a 7 web site to 8, with an eye fixed towards cleansing up Drupal Development Service content material mannequin a bit. You’ll study Drupal 10 Upkeep and Assist Service To write down a customized migrate supply plugin for 8 that inherits from one other supply plugin. To make the most of OO inheritance to tug discipline values from different entities with minimal code. To make use of Drupal Development Service 8 migrate Row object to make extra values accessible in your migration yaml configuration. Situation Drupal 10 Upkeep and Assist Service A music web site transferring from 7 to 8 Let’s say we’ve got a big music-oriented web site. It grew organically in suits and begins, so Drupal Development Service information mannequin resembles a haphazard discipline stuffed with weeds as a substitute of a well-trimmed backyard. We wish to transfer this 7 web site to 8, and clear issues up in Drupal Development Service course of, focusing first on how we retailer artist data. At present, artist data is unfold out Drupal 10 Upkeep and Assist Service Artist taxonomy time period. Incorporates Drupal Development Service title of Drupal Development Service artist and another related information, like references to albums that make up their discography. It began as a taxonomy time period as a result of editors needed to tag artists they talked about in an article. Related fields Drupal 10 Upkeep and Assist Service field_discography Drupal 10 Upkeep and Assist Service references an album content material sort.   Artist bio node. Extra detailed details about Drupal Development Service artist, with an hooked up photograph gallery. This content material sort was carried out as Drupal Development Service web site grew, so there was one thing extra tangible for guests to see once they clicked on an artist title. Related fields Drupal 10 Upkeep and Assist Service   field_artist Drupal 10 Upkeep and Assist Service time period reference that references a single artist taxonomy time period. field_artist_bio_body Drupal 10 Upkeep and Assist Service a formatted textual content discipline. field_artist_bio_photos Drupal 10 Upkeep and Assist Service a multi-value file discipline that references picture information. field_is_deceased Drupal 10 Upkeep and Assist Service a boolean discipline to mark whether or not Drupal Development Service artist is deceased or not. Selecting Drupal Development Service Migration’s Main Supply With Drupal Development Service new D8 web site, we wish to merge these two right into a single node sort. Since we’re transferring from one model of to a different, we get to attract on some nice work already accomplished. First, we have to resolve which entity sort will probably be our main supply. After some evaluation, we decide that we are able to’t use Drupal Development Service artist_bio node as a result of not each Artist taxonomy time period is referenced by an artist_bio node. A migration based mostly on Drupal Development Service artist_bio node sort would go away out many artists, and we are able to’t reside with these gaps. So Drupal Development Service taxonomy time period turns into our main supply. We received’t have a person migration in any respect for Drupal Development Service artist_bio nodes, as that information will probably be merged in as a part of Drupal Development Service taxonomy migration. Along with Drupal Development Service migration Drupal 10 modules included in core (migrate and migrate_Drupal 10), we’ll even be utilizing Drupal Development Service migrate_plus Drupal 10 module and migrate_tools. Let’s create our preliminary migration configuration in a customized Drupal 10 module, config/set up/migrate_plus.migration.artists.yml. id Drupal 10 Upkeep and Assist Service artists label Drupal 10 Upkeep and Assist Service Artists supply Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service d7_taxonomy_term bundle Drupal 10 Upkeep and Assist Service artist vacation spot Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service entity Drupal 10 Upkeep and Assist Servicenode bundle Drupal 10 Upkeep and Assist Service artist course of Drupal 10 Upkeep and Assist Service title Drupal 10 Upkeep and Assist Service title sort Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service default_value default_value Drupal 10 Upkeep and Assist Service artist field_discography Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service iterator supply Drupal 10 Upkeep and Assist Service field_discography course of Drupal 10 Upkeep and Assist Service target_id Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service migration migration Drupal 10 Upkeep and Assist Service albums supply Drupal 10 Upkeep and Assist Service nid This takes care of Drupal Development Service preliminary taxonomy migration. As a supply, we’re utilizing Drupal Development Service default d7_taxonomy_term plugin that comes with . Likewise, for Drupal Development Service vacation spot, we’re utilizing Drupal Development Service default fieldable entity plugin. Drupal Development Company fields we’ve got underneath “course of” are Drupal Development Service fields discovered on Drupal Development Service Artist time period, although we’re simply going to arduous code Drupal Development Service node sort. Drupal Development Company field_discography assumes we’ve got one other migration that’s migrating Drupal Development Service Album content material sort. It will pull in all Artist taxonomy phrases and create a node for each. Nifty. However our wants are a bit extra sophisticated than that. We additionally must lookup all Drupal Development Service artist_bio nodes that reference Artist phrases and get that information. Which means we have to write our personal Supply plugin. Extending Drupal Development Service Default Taxonomy Supply Plugin Let’s create a customized supply plugin, that extends Drupal Development Service d7_taxonomy_term plugin. use taxonomyPluginmigratesourced7Term; use migrateRow; /** * * @MigrateSource( * id = “artist” * ) */ class Artist extends Time period { /** * {@inheritdoc} */ public perform prepareRow(Row $row) { if (mother or father Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServiceprepareRow($row)) { $term_id = $row->getSourceProperty(‘tid’); $question = $this->choose(‘field_data_field_artist’, ‘fa’); $query->be part of(‘node’, ‘n’, ‘n.nid = fa.entity_id’); $query->situation(‘n.sort’, ‘artist_bio’) ->situation(‘n.standing’, 1) ->situation(fa.field_artist_tid, $term_id); $artist_bio = $query->fields(‘n’, [‘nid’]) ->execute() ->fetchAll(); if (isset($artist_bio[0])) { foreach (array_keys($this->getFields(‘node’, ‘artist_bio’)) as $discipline) { $row->setSourceProperty($discipline, $this->getFieldValues(‘node’, $discipline, $artist_bio[0][‘nid’])); } } } } } Let’s break it down. First, we see if there’s an artist_bio that references Drupal Development Service artist time period we’re presently migrating. $question = $this->choose(‘field_data_field_artist’, ‘fa’); $query->be part of(‘node’, ‘n’, ‘n.nid = fa.entity_id’); $query->situation(‘n.sort’, ‘artist_bio’) ->situation(‘n.standing’, 1) ->situation(fa.field_artist_tid’, $term_id); All main D7 entity sources prolong Drupal Development Service FieldableEntity class, which supplies us entry to some nice helper features so we don’t have to write down our personal queries. We make the most of them right here to tug Drupal Development Service additional information for every row. if (isset($artist_bio[0])) { foreach (array_keys($this->getFields(‘node’, ‘artist_bio’)) as $discipline) { $row->setSourceProperty($discipline, $this->getFieldValues(‘node’, $discipline, $artist_bio[0][‘nid’])); } } First, if we discovered an artist_bio that must be merged, we’re going to loop over all Drupal Development Service discipline names of that artist_bio. We will get a listing of all fields with Drupal Development Service FieldableEntity Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServicegetFields technique. We then use Drupal Development Service FieldableEntity Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServicegetFieldValues technique to seize Drupal Development Service values of a specific discipline from Drupal Development Service artist_bio. These discipline names and values are handed into Drupal Development Service row object we’re given. To do that, we use Row Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServicesetSourceProperty. We will use this technique so as to add any arbitrary worth (or set of values) to Drupal Development Service row that we wish. This has many potential makes use of, however for our functions, Drupal Development Service artist_bio discipline values are all we want. Utilizing Drupal Development Service New Discipline Values in Drupal Development Service Configuration File We will now use Drupal Development Service discipline names from Drupal Development Service artist_bio node to complete up our migration configuration file. We add Drupal Development Service following to our config/set up/migrate_plus.migration.artists.yml Drupal 10 Upkeep and Assist Service field_photos Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service iterator supply Drupal 10 Upkeep and Assist Service field_artist_bio_photos course of Drupal 10 Upkeep and Assist Service target_id Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service migration migration Drupal 10 Upkeep and Assist Service information supply Drupal 10 Upkeep and Assist Service fid ‘physique/worth’ Drupal 10 Upkeep and Assist Service field_artist_bio_body ‘physique/format’ Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service default_value default_value Drupal 10 Upkeep and Assist Service plain_text field_is_deceased Drupal 10 Upkeep and Assist Service field_is_deceased Drupal Development Company full config file Drupal 10 Upkeep and Assist Service id Drupal 10 Upkeep and Assist Service artists label Drupal 10 Upkeep and Assist Service Artists supply Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service d7_taxonomy_term bundle Drupal 10 Upkeep and Assist Service artist vacation spot Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service entity Drupal 10 Upkeep and Assist Servicenode bundle Drupal 10 Upkeep and Assist Service artist course of Drupal 10 Upkeep and Assist Service title Drupal 10 Upkeep and Assist Service title sort Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service default_value default_value Drupal 10 Upkeep and Assist Service artist field_discography Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service iterator supply Drupal 10 Upkeep and Assist Service field_discography course of Drupal 10 Upkeep and Assist Service target_id Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service migration migration Drupal 10 Upkeep and Assist Service albums supply Drupal 10 Upkeep and Assist Service nid field_photos Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service iterator supply Drupal 10 Upkeep and Assist Service field_artist_bio_photos course of Drupal 10 Upkeep and Assist Service target_id Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service migration migration Drupal 10 Upkeep and Assist Service information supply Drupal 10 Upkeep and Assist Service fid ‘physique/worth’ Drupal 10 Upkeep and Assist Service ‘field_artist_bio_body/worth’ ‘physique/format’ Drupal 10 Upkeep and Assist Service plugin Drupal 10 Upkeep and Assist Service default_value default_value Drupal 10 Upkeep and Assist Service plain_text field_is_deceased Drupal 10 Upkeep and Assist Service field_is_deceased Last Tip When creating customized migrations with Drupal Development Service Migrate Plus Drupal 10 module, configuration is saved in Drupal Development Service config/set up of a Drupal 10 module. This implies it’ll solely get reloaded if Drupal Development Service Drupal 10 module is uninstalled after which put in once more. Drupal Development Company config_devel Drupal 10 module will help with this. It offers you a drush command to reload a Drupal 10 module’s set up configuration. Drupal 10 Improvement and Assist

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Drupal 10 Assist: Drupal 10 Upkeep and Assist Service Merging Entities Throughout a Migration to 8

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.