 Today I'm here to present some tips in Magento development which will be very helpful for developers I think. So we can start from here, like what are the best practices we can follow in Magento to get it better and better output from Magento in our website to make it more powerful. So here is the agenda of my presentation is first week I can introduce like why we need to do this best, why we need to follow all these best practices in Magento after that I can share some best practices in which I can compare what is the wrong we are doing and what is the correct way we can do and after that we can conclude some points. So in interaction like I can say Magento experts consultancy group ECG which is known as ECG has conducted many code audits for their clients and they find some coding issues that's why their stores are very taking high loads and so from about 28% of the issues affected performance and scalability of the code and the top 5 performance coding issues represent 84% of the performing issues. So most of the issues are related to insufficient operations redundant or useless computations and memory misuses. So among 5 these these are the calculating the size of an array on each iteration of a loop. So whenever we use a forage loop so at the time we calculate the size of the array. So I can explain all these point in the further slides and after that the SQL queries inside a loop loading the same module multiple times redundant data set utilization insufficient memory utilizations. So these are the major findings by the Magento itself. So these are the yeah you can say it's this PPD is given from Magento from Magento also. So here first is the calculating the size of the array in on each iteration of a loop. So here you can see like if we use a count in for a statement then it is calculating every time as my loop rotates. So what is the good practices we have to calculate the counts at the first and then just use the variable in the forage iteration. So it will be very fast and after that SQL query inside a loop we can say like in Magento's we can load models in to get data like it's an example like if I need to get a product data then I need to load my model which is actually hitting the database. So here you can see for in forage loop I have multiple number of IDs and I am in each iteration I am hitting the database to calling the models. So instead of this we have to calculate our model outside the loop and then just iterate the collection. Collection will contain all the data of these product IDs which I have passed here. So this is the best practice we can use here and after that the loading the same model multiple times like I have to show some SKU my product SKU and my product attributes like color size I have to show on front end then what I can but usually we prefer is we can load the model then get the attribute from that product and again if I need to get the SKU of that product then I can again load it but it will very time consuming. So we have to follow like we have to only load model only once and from that model we are already getting all the data. So whatever we have to show we just have to retrieve from that data instead of loading the same products many times or sometimes we no need to load the whole models like in Magento on front end we have to show only color I don't need of size and different SKU names and different things so I can just directly load the SKU or the size by ID of the product. So this will only give me the SKU. So after that the memory fetching large results sets in Magento or we can say it's a normal PHP in which we just get fetch all the results like I have in my tables I have a one lack of records if I will fetch once it will be a my memory usage actually. So it will be a good to calculate a row by row in a loop in a while loop I need to fetch actually one row and then process it then one row then process it instead of getting all whole data which will be a memory actually and after that query resulting limitations we can say in Magento whenever we fetch data we don't use generally limits like I have to fetch a user information in which I just already mentioned in model like particular user data but instead of not defining the size or the limit I am fetching the whole data or accessing the whole database to get that particular information instead of this if I will apply some limit or something like in the collection you can use get limit or set limit something after that we can also use get size instead of get count instead of counts the difference is here count will we can say scan all the database to get the count every time and the get size will just give you directly the size of the collection which you have that so or overriding the core file actually very often developers rewrite the core files when there is a possible way to accomplish the functionality by the observer Magento have very useful feature and very beautiful feature which is an event observers so instead of rewriting the core modules in Magento we have to use the events like whenever any user add the product into the cart then we don't we have to add or restrict some condition there then we then we don't need to modify the core code in Magento we already have an event like add to cart after or add to cart before so at that particular point you can write the code Magento will do their functionality without writing the rewrite core files actually so these are the some basic best practices in Magento's all are not of Magento are some of from PHP also but we generally use this all in Magento as the Magento is built in PHP and following the Zend framework so we have to follow all this and also you can whenever we have to debug anything in Magento we have to use the locks instead of for like eco exit in like we did every time in PHP we write some print R or some using the eco exit to check the execution of the code so instead of doing this we can use the locks in the locks we can store whatever the flow of our code so it will not affect the end user also it will be very useful when we are debugging on the production site actually in production we cannot just eco exit to test our issues so we have to write this code in the Magento we have to write the locks and it will everything whatever you want it will written in the locks and you can check the flow like how your code works and what was the data it was passed and here you can see the first parameter is what you have to pass you can pass any variable or any array in that first field second is a null or you can specify one two or three or four it's null is a Zend lock and one two three different codes is there in the Magento one is for alert and different notifications and different type of values you can pass here and after that this is a log file name you can create your own log files or Magento already have system.locks and exception.lock you can also store there but to do this you don't have to forget to check in if you have enabled the locks in the Magento or not if you will not enable it it will not store in the locks so this is the first thing you have to check yeah so here the conclusion like points to be note for the developers what they have to note always be attentive for the performance critical code actually whenever we develop we are not looking into the performance first we are our first idea is to complete the functionality and after that we can think about the code performance or not if it it will not affect then we will not make it changes but it will work for the small systems like I have a 50 users or 100 user 200 user but whenever my system grows the actual performance of code will highlight that time so that time if I write the wrong codes which is very performance critical then at the end I will be stuck actually there is no way to make it optimize they will be very difficult for the user so from the starting we have to remember for the performance critical codes in Magento after that to avoid the useless computation inside the loops like we just so we have loading the models every time in the loop so we have to take care we will not do this it will significantly improve our Magento performance and try to learn and understand the feature of frameworks and use them correctly like in Magento is a e-commerce and which is also written in PHP so we can directly write the core PHP in Magento also so instead of doing this we have to understand what the framework is and how to write the code on that particular framework so that we can utilize the performance or the better benefits or features of that particular framework instead of writing the core codes and after that the common we have to use a common sense like sometimes we have to fetch all the data at a time like if we have a small database table sometimes we don't have to fetch all the time all data at a time we have to fetch every row in a for each which I just saw you so as per the situation we have to understand like which code we have to use either we have to fetch all at the time or we have to fetch one by one in a loop so these are the nodes which developer have to take care whenever they write any code in Magento also so this is the I cannot say it's purely Magento it's also PHP also so use developer have to maintain all these features and keep in mind whenever they develop any modules or anything in Magento so in the next this is the part one of the presentations and the best practices in Magento for the next meetup I will share many other good feedbacks or good features like how to implement the things in Magento so thank you that's for my side any questions or so it's so much answer, yeah Can you replace PHP? Yeah Can you replace PHP? Yeah Yeah So it's so much answer Yeah Can you replace PHP? Yeah So it's so much answer yeah No actually I have not tried it because as per the Magento guidelines they are suggesting to run the PHP from I think 5.3 to 7 in the co-PHP so I have not tried it actually anything else