 Thank you. Yes. This is working. Yes Hi guys, my name is Tiffany Chan and I'm from Deloitte Digital and I started Drupal just last year when I was an intern at Deloitte Digital and So it was it this concept is very new for me And I found Drupal very fascinating because like my university taught me a very manual Like HTML, CSS and JavaScript code. So when I when I was like given Drupal I was like, wow, what's this thing? So yes, it's very exciting thing and learning Drupal for the first time was very hard And I wouldn't be able to stand here if it wasn't for my colleague Adam Malone, Christopher Hopper, Henry Tran and Aaron Nicole. So I would like to thank them for this presentation So let's just move on to this presentation So When I was an intern I was placed in an e-commerce project and this project is related to a telecommunication company and Their objective their objective is like they want to create a new website for their company so This means that we need to move their entire Product from the old website to the new website I'm not talking about just like a couple of products. I'm talking about hundreds of products like maybe even like maybe a thousand and In this project I was provided a JSON as a type of data format for this migration and The products includes broadband, nbn, bundles So this is the range of products that they offer So because there are hundreds of products needed to be migrated We need to build an easy solution for this migration So this telecommunication company used commerce to build their website. So have has anyone here used commerce before? Few people there. So if anyone haven't used commerce yet, it's Actually a solution for building your e-commerce website and so you can just create your product type and attribute Custom and you can also dynamically change your display product and also your Attributes very easily and it's very flexible to you to do your orders and also displaying the product itself And best of all you don't have to create your own payment methods for this And so which is why they chose this telecommunication company chose commerce So the question then arises of how to migrate products Effectively because there's just too many products to migrate manually. It's time-consuming It's a waste of energy and very expensive to manually migrate the products So before we start doing some coding Or making modules, so I want to introduce you to three terminologies about commerce So product type is the kind of product of that telco company. So for example here, you can see that The product type is broadband Bundles and mobile broadband. So it's just a it's just a what they're selling. So product attribute is the characteristic of the product and this can be seen in the JSON at the key value pair and Also, the last one is product variation It's actually the specific instance for each of every product first So for example in this in this demo, I'll be showing you I will be showing you later I'll be using bundles, which is the middle one and there's a hundred and twenty different variations of bundles So just imagine like bundle one bundle two bundle three So they're that's what product variation is and I know as a beginner. It's very confusing to To know what what this terminology is because believe me or believe me. I've been there. So Yeah, this is a very simple way to Some summarize product type variation and attributes So before before we do anything we have to set up the commerce website We have to make sure that the store currency and product type exist before we do anything And it's very important because I got stuck with this for a long time We have to create a product type which in the other The other slide it's like the bundles So for example, if you want to create a bundle product type You have to go to the configuration and just create a simple bundle product type. This is important because This defines what they're selling and This doesn't have this doesn't if you don't if you forgot to do this It won't show up in any of the error message very important So next thing is that Creating product attribute and as mentioned before product attribute is basically the characteristic of the product and the so the difference between product attributes and other things like let's say the IDs and Like the name is that product attribute has multiple values to choose from so for example in this example we have access technology and In this in this particular example, we can choose different types of access technology I'll be showing you later of this Different options, but we cannot this is not the same as ID because ID We can't choose from multiple values because ID is just predefined. It's Let's say for example ID 1 ID 2 ID 3 so we can choose from it. So we have to create it from the start so yes Next one is after defining the product type and other configuration. We need to Create the products. So this is important because we need to create the products and We need to define it because we need to see the variation. So if you create the products, you'll see that there's variation tabs and We can actually see that there's nothing currently so our goal Here if you don't understand what I'm like what I'm talking about today is to get the JSON Which has been provided with the telco company? Get the JSON data and just put everything you want to put in this Variations tab very easy so yeah, so Now I'll be explaining you how to create the modules. So We will be creating the module just for this migration commerce and this is just a basic presentation So I won't be covering everything about this code, but I'll be trying my best to explain Everything hopefully so for this module. We need three external modules Which are migrate plus migrate tools and migrate and you need to doubt you need to do a composer require for migrate plus and migrate tools because migrate Because migrate is already in the course. So you don't need to do that. So After doing the basic things like creating module info Info YAML dot module file and so on we need to create two things So basically we need to create group migration configuration and the product configuration So that's it. So for example in this example the group migration will be commerce bundles and it will be and the first one will be used in the product configuration entity, which is commerce bundles, which is the The example below the one highlighted in the screenshot. So I'll be talking about what to put inside of this product configuration entity and This is what the first of the third section looks like for the product configuration entity so There are three things here to note that in order to migrate stuff you need to Know about source you need to know about destination and you need to know about process So let me repeat that source that's destination and process So what is source? I got very confused when I first started like what is source? It's just like a like a label field everything is in there, but basically The big section down like the fields The fields in the screenshot. It's actually what you want to get from the JSON. So for example Name equals to ID label equals to ID It means that I want to get the ID from the JSON which is next to it Which is ID equals to nbn01 underscore underscore. So that is the ID that I want to get and Sometimes we don't need to use all the information from the JSON So you can pick just which one you want to use for this because in reality you don't want to be displaying every information to the customer and There's also other things in the source, which is like what kind of what kind of data type data format you're using which is JSON in this and also the URL and like Constants like the string the type of what the bundles the also the identifier depth in my Example it will be of like like only one identifier depth for the JSON because it makes it easier So yeah, that's a source. So the second part would be destination So destination is pretty straightforward because we want to migrate it to the product variation We need to use this entity commerce product variation So it can be migrated and it's already it's already made this plug-in So you don't need to like stress about how to use this so the third and final one is process and This the process is how to get from the source which we just talked earlier and displayed at triple So if you can see here So this is just the same thing like This screenshot is the same screenshot as this one But I just added source next to it with which we just explained earlier So basically we're just like mapping things into into the process from the source. So for example Here we can see that name is mapped to SKU With a plug-in called skip on empty So it means like it basically means take Take ID from this from the source and also and see what what it is inside and After you see what's inside check if it's empty If it's not empty then push it to the Drupal commerce website this also applies to this also applies to title which is taken from description and Product ID you see that you might see that the plug-in is a little bit different. It's not skip on empty this is a custom plug-in I made and If this also applies to commerce price too, so basically commerce Product is to allow it to select the right product ID While commerce price is actually to set the price and currency curve So we're just using using the plug-ins, which is what you want to do for the for the data so what you want to do with the data you have and also For attributes we need to do entity look up before before we do anything with this because they need to look up the the List that they generated from this data It's if this seems like confusing. I'll be showing you the demonstration later so next one Executing the migration is pretty simple. You just need to do a drush migrate status to check the status and You can choose the product type The product you want to migrate and also type the drush migrate import and there are also useful commands such as rollback and Also migrate reset status. I find migrate reset status to be very important because There's not a lot of documentation like let's say you got stuck and the status got stuck in importing you can just Reset it and it will go back to idle so when you open the product variations, you can see the list of the items here and I'll be showing you the demonstration So if I go to my commerce and this is my commerce Module and if I go to product you see that I created a bundle and and Currently there's nothing inside right and if you can see the product attributes We I created a product attribute called access technology and I I didn't put anything first. I just put one one Value and it automatically like populates it for me so if you see again the variations and if you go to your terminal and you just type drush migrate status This will show you how many how many but items are in your json and It will show what? How many is unprocessed and how many are processed and this also applies to if you Update stuff it will show how many items are updated and how many items are not updated You just need to type the migrate import Okay, I Have a backup. Yes. So if I just open this I'll just fast forward so yep, there's nothing in this variation yet and If I just force fast forward to this so as you can see I did the migration status and I there's 122 unprocessed items and if I did a migrate import It won't say it it won't say anything so don't panic if it doesn't show you anything Like there's no like successful message and If you check the status again You'll see that It's imported already and if you go check your check your Website you can see that all the variations are all there and if you don't see some of the Tabs like for example, where's the description like where's some tabs? It's all there already It's it's just too too many things to be displayed at the front. So if you go inside of each of the Variations you see the details there So yeah, thank you guys Thank you Tiffany. We have Time for couple questions. So if you want to raise your handle come and handle the mic. Thank you. Thank you very much I was wondering if You had like how many things you imported like if the files were too big or if the Just like it was too much content if there was an strategy to break down the migrations or or if or or you did everything in one go Just basically like if there is a lot of content to migrate if you have a strategy for that If there's no content to migrate if there is too much like a lot of content Yes, like how many how many is too much a million a hundred thousand, you know, like a very big Import well, I only try it with like a hundred of products each Product type. So if if you're like saying like like ten thousand maybe it will slow down the importing But I'm sure it still works, but it will just very slow You know, when you type it to rush migrate import, it will be very slow Thank you. I would like to maybe respond to the comment here as well like when you have lots of content. Let's say 100,000 that basically all of your content would be just one type So when you do your migration, you can just split that into your bundles So for example, if you have like ten content types, you will have ten yaml files with ten configurations So when you do the migration, it will be split it between those ten. So it's not like all their own one go Any more questions? Thank you. Oh, here you go Last one. I'm just curious how did rollback go when you rollback your migration? Yeah, so we just type drush rollback as mentioned here So just drush migrate rollback of that product and it did everything you wanted to and nothing else You didn't have any problems with it. Oh, I don't know why like I couldn't do it just now maybe it's the network issue, but Usually it it's okay. It will just disappear So you were only importing product variations not products. Is that correct? Yeah product variations not product So your product variations you already knew what the product ID was going to be Sorry, you already knew what the product ID would be Product ID. Oh, um product ID. Yeah So it's already it's already there. So I just need to take it Yeah, from and you you made the products without using migrate Yeah, oh, no, no, so I create the product on Itself like manually. Yes, and then like after I create the products I Go to the variations tab and look look at it and do the do the commands and After the commands it will appear in the variations tab. So we still have to do the products manually Right, so the you created the products manually and then you migrated in the product variations Yeah, so that when you did a rollback of product variations You only rolled back the variations and not yeah, so when you do a rollback. Yes. Okay. Thank you Tiffany Yeah, thank you guys Don't forget to leave your feedback on the website and we'll be back in two or three minutes