Shopify Inventory App - Sync Products and Orders through REST API

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay um hello everyone welcome to another live stream and I think I have this slight issue here so let me start up the expressjs server and in this live stream we will take a look at how we can synchronize orders and products data um that the migrations will be defined for in LEL but it's the expressjs API that will call the API on a loop and it will take all the data and put it in the table so Express CHS I have it here and I can do just no sorry yeah all looking good then I can refresh this why is it a problem these days okay so let me remove that uh redest thing here this I refresh yeah now it works so let me remove this cach and red is kind of thing here yeah this shouldn't be bothered with um anything with um caching on anything it just should call expressjs Api and expressjs API decides whether it wants to read from redis or whether it wants to read from the database so yeah that's how this will be and yeah so we can we have this orders and products here so in the LEL migration I kind of forgot to put the table structure in it so database migrations so ORD stable um I I have done it so many here products table we can do that so we will open up so Shopify products with their variants and with their metaps and with their images it's a lot it's a lot data to it's a lot of data to store in the tables but for the sake of Simplicity we will only do products so we have ID title body HTML yeah so we will do that the big increments would be table ID here [Music] um big integer product ID no sorry ID then it would be table with unsign big integer store ID then it will be table um string not string medium text title this can be inable if you want so then table ID title body HTML so we can take that so long text body HTML this can be nullable as well then there is vendor product type created at yeah so we can do that and then we can just put product type here then we can create it at here after that handle we can do here updated that publish that templates ofx publish scope status admin graph API ID that's needed then we have the variants information okay so variants maybe we will uh keep that in a separate table and we will use equalize to join products table with their variant table because the relationship is like one store can have multiple products which can have multiple variants so I really want to hammer down on the database design where I would keep the variants in a separate um table yeah sounds good after variants we have an array of uh variants so then we have images then we have image we can do a default image with long text yeah but then for the created at and updated at we can just take these values then we can do table soft deletes yeah then after that in the model we have to match it by saying use soft deletes did I use soft deletes on orders um no I didn't okay so we can use on product we can use soft deletes then we will do protected guarded equal to nothing public times times equal to false this will take away and protected primary key equals table ID yeah these three things these four things will make sure that uh our database will hold up with LL all right so this seems uh good enough from last double side so let's run these migrations so in the database I will go and delete the migration last entry so in products I can drop this table then in the migrations I can come down here delete this entry yeah and now I can run PHP Arts migrate in P PHP Artis migrate yeah so product table got created and if I refresh then here's the products boom so now we have the proper uh data here close this out so now let's close everything yeah and in commands we will make another command PHP Artis make Command sync products this calls the express JS a to sync all the orders no not all the orders all the products from the store and place it in the database yep good enough then we can do this um we can call the last command that we created for orders we can just change it into orders sorry products so here I have get Docker API URL sync SL products Docker API headers null then this will be a get request yeah good enough so now we can close this out we can close this out I have to turn on the fan just oh hey how how's it going on how's your Sunday going H so in first Ms just like I Define for orders I can Define for products then I can do sync [Music] apis authenticated apis data anyway this is work so sync orders then we will do sync products so store controller can I just directly invoke all the stores and yeah we can do that so we can copy this try cat here okay so then we can do where stores equal await my ai. get stores maybe I can pass in an array of table id id my Shopify domain and access token what is it so these four things I would need um in order to call the apis right yeah so we can do this oh I'm sorry to hear that man yeah you you you were saying things about your legs um yesterday I don't know why I took it so lightly I would recommend going to a doctor but I would suppose that you know better than me so yeah if stores then we can do for where I in stores okay um can I do function trade uh trades. function trade I have it here um later I can Define it via um the redish key on R key equals sync orders store then probably we can do um store I do table ID for AWA wi store off store then we can do store i. table ID yeah I I need this uh looping to wait anyway if const redis key exist equal await redis do exists red is key if red is key exists I'm not going to redus do set redis key one I can say one then I can say ex then I can say for 300 seconds so that will be 5 minutes did you just say white noise went IST do you do your country have that kind of insurance kind of thing like you can't go to the doctor without having an insurance does Russia have that for for for I gave my apartment a little too much credit for uh for it to be silent now that I started to live stream and every little sound matters now I'm realizing it's not oh man that sucks sorry to hear that do you know do you know what though went I absolutely love o stream creating an old account called Avo file with Double L and he's trying to do what he's doing on deand I got a kick out of it when I saw it now in SQL eyes Let's uh first try to do a response um so since ID would be zero so it will be a do while loop products not equal to null or products. so then I can do where end point equals products. Json since ID equals since ID yeah I understand man totally get totally get that did you see the GTA 6 trailer uh went that has given me a little bit of Hope to stay alive you know just so I can hold it out until 2025 uh GTA 6 Grand Theft Auto uh head for it's coming out in 2025 2 years from now bro I don't do react man and using rest API with authenticate I'm not a react GS developer sorry since ID equal to this then I can do response equals yeah I'm more like [Music] a now I should keep this in uh store controller itself for that's okay um but what I'm really looking for is patreon subscribers um best motivation speaker that will that will uh enable you to for you to put requests uh for me to make videos on and also that will help the channel out I can create even more videos than I usually am I hope you understand [Music] um syn orders for store then we can do this then I can do function trade. G Shopify API headers for store then I can do function trade store then I can do request trade do um make an API call to Shopify but I love GTA man I absolutely love GTA GTA 5 I played around three times and finished it the story it's so good but then again that's me make an API call to Shopify get Endo headers that's all I need right Endo headers yeah yeah it's a Content gold actually um Rockstar uh released a trailer photo for the trailer sorry what am I saying Rockstar released a post on Instagram about uh when the first trailer would drop and that received 6 million likes so it's crazy man and as of right now the trailer uh on YouTube has 150 million views in 4 days so the hype is there it's more than Mr Beast uh views uh best motivation speaker what is your name man what uh state are you from I imagine you're from India what state are you from all right so then I can can I return return response products equals response do status yeah and response Arrow rest body then we can do response. resp body do products otherwise it's null let me make this false for now so I can absolutely make sure it only runs once then can I go to here and can I type PP Artis app sync orders oh for I never heard of uh apolog justice ace at tring man okay so [Music] then oh I'm sorry get all stor is not defined what is that uh most of all I I need a second screen actually second screen meaning that I can put the chat in that and I can put uh only vs code and myself uh in the corner that's what I need but still like I can't justify buying a second display I feel like the kind of money that I would spend I wouldn't get a Roi on this like yeah it's a little complicated I hope you understand patreon patreon npm squiz select by select columns so it will go on attributes okay so then I can so remove where make it find all and I can do store yeah obviously I'm on Windows man um it's the it's a pain it's a pain for me to have this because then I have to deal with sound issues in uban 2 I'm telling you like I can pay good money for it if somebody can solve my sound issues h why am I receiving 200 but such a silly mistake man such a silly mistake you didn't have to cut off does it look a little wonky um how I present uh my screen on live streams for for for yeah true true uh return okay what is this for good to hear that man um um um where is it okay I can remove this for for um I still appreciate that man there no issues you still choose to be here I'm thankful for that okay what's uh this same fers it's not a function then what else is it for a controller can't call a controller function uh wind can you help me out here a little so OJs cells API route prefix sync orders store controller do sync orders so in store controller I have the sync orders function which is calling sync orders for store function and this is a async function request receive then down here I have defined this function and now it is saying sync orders for store is not a function and what else is it console log type of why is it saying property maybe I have to call this um in service class sending all the crap so controllers oh hey faran uh good to see you back I'm doing fine man thanks for asking how are you doing oh hey relax gamer you're back how's your Sunday going all right for store it can't call um function tra that function tra should function trades refer themselves yeah you are playing fortnite and having a good time and here I am stuck with this uh JavaScript issue so let me put that in did I just shoot myself in the foot with defining a function trait actually no I'm not going to give up just so easy um I will take all of this delete that paste it in here itself products equal to new array and then what we can do function trade do this request this is yeah M Falls yeah so faran how's things going on for you actually went um I like to suffer so you know products I got null what the hell no problem foran um what what did I get null products. ID equals this should I do console l in point1 just to make sure yeah uh why is X Shopify access token undefined um store so function trade store. access tokeny API URL for store yep I can remove this now still null console log headers conso log end point there is no product in my store what the hell um for for for why is it null what's happened here um how do I find out even that this was not name Shopify store what are the access Scopes added to the app um in config profile PHP API Scopes yeah I would hope so I'm taking since ID as null then I'm checking if it is not null then you can append it otherwise Wise It's a blank string therefore products. Json plus uh since ID prefix would result in nothing getting uh appended right I start the wrong way y cuz I caught it pretty quickly that it converts null into a string man JavaScript is something else JavaScript really is uh something else I'm telling you if this was PHP I wouldn't have to test it at every line I don't know why I have to so this is crazy dude um every single line has to be checked oh it's [Music] promise if this was uban 2 I could simply install pm2 and every time I hit save on the vs code window the pm2 automatically refreshes I could have done that it was it would have been so simple but no no no it has to have sound issues I only did one YouTube video on one two and it came out uh what oh it's a get oh okay okay sorry sorry so in this thing method is not used at all okay so xs. poost can I use anyway if method equal equals get all method N I have to do this result equals what is it my code for what do you mean V is it my code or is it something else ask your get request oh okay bye v um appreciate you stopping by once again there we go boom if response. status then I can do products equal response dot SP body do products else products equal to null for for for I'm doing anything interesting on a Sunday going out for dinner or whatever no um product do store ID equals store. table ID yeah we can do that then we can do await MySQL API dot save product squize update or create it's fine fan you can just chill that also counts right update or create Shopify product I want to do this update or create thing okay so in myql API update or create on model so I can do async function this return model. findind one where for for vuejs is and View and react are front end Frameworks no expressjs is a backend framework so I'm trying to I'm more on the back end side now that's [Music] [Music] why so then in in store controller to create shy product yeah MyQ API Bing [Music] function do I have product defined up here nope I don't so in models I should have a products. JS which will return products [Music] products table ID store id id after that what else is it thing is faran um why I am picking up such a huge project oh reactor view is front end you completely use it in front end you just call backend apis with view or react Express GS is like WordPress which is completely back end that's why I'm using this and you know why I'm doing such a huge project on um expressjs is because I'm obviously transitioning to express CHS from larel but sometimes doing these videos it a new video idea hits out of nowhere so then I can use that um for my regular uploads that's uh one of the side effects of this so title body HTML vender title body HTML vendor product type created at yeah thanks what are data types man you [Music] did um seize data type data types body HTML is long text then there is another medium text after that everything is string for e for for created ad handle oh yeah I did it's crazy isn't it uh that game is going to be a game changer Marvel Spider-Man 2 boasted itself of using PS5 Hardware but it actually GTA 6 that will make the full use of it yeah do you have a PS5 foran I probably still won't be having a PS5 yeah exactly sucks isn't it um product type then I can do handle created that templex effect the money that will it will generate it would be crazy isn't it publish everybody knows everybody wants GTA uh six templates of effect um Rockstar if you are watching this stream for some reason I don't know why you would but feel free to to send me a PS5 public scope then there would be status after that admin graphql API ID and after that image then I can do then yep sounds good looks good um model I should really do model then these two will become model nice image cannot be oh sorry um inside store controller yeah product do image equals Json string fi product. image is image defined in the model products oh it is there string yeah now seems good did I get products hit refresh oh here we go so now we received orders uh sorry not orders products in the database now we can use them although I do realize I really want to put this on record I realize this is not a clean way to do this because on a loop I'm calling I'm calling insert queries which is obviously not good ideally it should be insert into products on duplicate key update so that would take care of uh inserting a bulk set of 250 products into the database in one shot and it will take care of um the duplic duplications so but that's a good way to go isn't it so let me stay for 20 minutes more okay so I will create a products page where I can um pull this information and I can uh show it I'm sorry Asing get products for store so that it would be user store filters then it would be cons products equal MySQL API do get store products store do table ID filter yeah return products right then in this store ID filter app okay return products find all um where store ID is store ID anyway equalize order by for I should create another um controller here called products controller so new file not ksjs so then we can take store controller s ERS and I can delete this then I can do get products B for Yep this sounds good um wait I just defined a function in this okay produ controller this would be function. product. store oh hey Arian um how you you doing what's up function TR how's your Sunday going Arian doing anything interesting product you go get store products product length control yeah the sound seems good enough yeah so in ajs now I can just do a w products controller equals require controllers product controller my scale API trades rers yeah can pass that then authenticated apis is this app.get API out Prix plus products would be API O then it would be product controller. get products yep seems good okay close this out close this out where are you from Aran um user equals all user what happened oh sorry public function construct would be this middle whereare would be o Quest trade then it would be public reest mod use that for North JS is it get request what okay get request get request endpoint headers yeah DD response let's see what I get so then I can run PHP Artis optimize cool then I go here I click [Music] products product controller does not exist okay so in web.php ooh what happened in a 404 not found response what happened here so in OJs oh I had to restart sorry now if I refresh there we go filter a is not defined um okay so get products there we go now I now we got all the products that we need and we can show that in um the dashboard so we can do the same thing with product collections I think this will expand into much more with um products images their variants um uh what is it and meta Fields meta Fields is something that um I'm getting asked about a lot so I have to look into how these meta Fields really work all right all right so it is 1: p.m. U Indian time I appreciate everyone of you um who joined in um if you're watching this live stream at a later time uh don't worry about it my Discord link it is in my description box you can join me there and if you want to support the Channel please consider donating on patreon um I would really appreciate that as it helps me be motivated to put out more content like this yes meta fields and meta objects correct correct so I have to look deeper into it I know a basic knowledge of how those work but uh a deeper knowledge is needed in that so please consider donating um head over to my Discord and I will see you in the next live stream thank you
Info
Channel: Sid The IT Guy
Views: 357
Rating: undefined out of 5
Keywords:
Id: uVRnViVkGl4
Channel Id: undefined
Length: 93min 6sec (5586 seconds)
Published: Sun Dec 10 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.