How to Create Table in Magento 2

How to Create Table in Magento 2

Magento 2 offers a mechanism to create database tables, modify existing ones, and add data into them.

You can create a new database table by InstallSchema in Magento 2.

Create table in Magento 2 to store and retrieve the data. Not only that, but you can also perform various operations such as insert, update and delete on the table data.

Moreover, it can be used for checking the login credentials.

Check the below steps to programmatically create table in Magento 2. You can use this method when creating a custom module in Magento 2.

Steps to Create Table in Magento 2:

  1. Create InstallSchema.php at app\code\Meetanshi\Extension\Setup
  2. Once the extension is created, all the commands are being run. We are creating InstallSchema.php file after executing the extension. Therefore, we have to delete the existing record.To do that, go to table setup_module and search Meetanshi_Extension in the column module and delete the record.Now, run the commands given below.

    After running these commands, the table ‘extension’ will appear in the database.
    How to Create Table for Magento Extension Development

Done!

If you have a question regarding this post, feel free to ask in the Comments section below.

I would be happy to help you.

Do share the post with Magento Community via social media.

Thank you.

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]]]>

How to Create Model File to Perform CRUD Operation in Magento 2

In the previous tutorial, you came to know how to create a table in Magento 2. This tutorial is all about creating a model file to perform CRUD operation.

To use a table in Magento, one has to create files for the model.

Bookmark this tutorial while developing a Magento 2 module.

Steps to Create Model File to Perform CRUD Operation in Magento 2:

Create a file having a name Extension.php in given address: app\code\Cozmot\Extension\Model

The name of the table is Extension here so we have given the name of a file Extension.php.

For fetching and loading the data, you need to create another file “Extension.php” on a given location.

Create file app\code\Cozmot\Extension\Model\ResourceModel\Extension.php

Another important file is Collection.php

Collection.php file helps to collect all the data of the table.

In the given path, create a file and copy the code.

app\code\Extension\Model\ResourceModel\Extension\Collection.php

Done!

I would be happy to answer your questions regarding this blog.

Please do consider sharing this blog with interested ones via social media.

Thanks a bunch.

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]]]>

Magento 2.4.1 | Improvements in Performance & Security

The latest Magento 2 version is the proof of ever-learning, ever active Magento community that cannot be stopped no matter the shifted working system, pandemic, or any 2020 disaster!

Download the latest Magento 2 version to enhance the performance and security of your store, because that is what the new release is all about!

Check the overview of the latest version of Magento 2 here:

Highlights of Magento 2.4.1 release:
Support for SameSite attributes for cookies.
Included the CAPTCHA protection for payment and order related API endpoints.
CAPTCHA on Place Order frontend page
150 fixes to core code
More than 15 security enhancements
Improvements in GraphQL, infrastructure, performance, PWA Studio, and much more!
Magento Security-only Patch 2.4.0.1
Option to install a time-sensitive security fix without applying hundreds of functional fixes.
The security-only patch 2.4.0.1 (Composer package 2.4.0-p1) to fix the vulnerabilities identified in the previous quarterly release, Magento 2.4.0.
Includes the hotfixes applied to Magento 2.4.0
Substantial Security Enhancements
Includes 15+ security fixes to close remote code execution (RCE) and cross-site scripting (XSS) vulnerabilities
Includes CAPTCHA protection to:
Place Order storefront page and REST and GraphQL endpoints
Payment-related REST and GraphQL endpoints.
Support for SameSite cookie attribute in order to support the Google Chrome enforcement of the new cookie classification system
The enhanced Magento Scanning Tool allows the merchants to get real-time insights into the security status of their site through proactive detection of malware and reduction of false positives.
Infrastructure Improvements
Allow the store users to clear the contents of their shopping cart in a single action
Improved quality of the Framework
Improvements in:
Customer Account
Catalog
CMS
OMS
Import/Export
Promotions and Targeting
Cart and Checkout
Staging and Preview
Performance Enhancements
Reduced the size of network transfer between Redis and Magento.
Hence, a decrease in network cache size and execution time for many scenarios
A decrease of 20% in consumer queue CPU consVenia mini-cart experience motion that resulted in increased control over consumers and saves server resources.
Improved execution time for “bin/Magento” commands
New Media Gallery
Allows the merchants to perform the following in the media gallery which is now enabled by default in the admin panel:

Bulk image delete
Identify the duplicate and unused images on the storefront, hence optimizing the media storage
Filter images by the storefront area
View metadata from the images, edit it, and search for images by metadata
GraphQL
Allow customers and guests to write product reviews. Customers can also retrieve their product review history
Allow customers and guests to add a gift message to their order.
Allow customers to view details about their order histories, including invoices, shipping, and refunds.
Allow customers to add these product types to the cart:
Simple
Configurable
Bundled
Grouped
Virtual
Gift Card
Downloadable
Allow logged in customers to store the payment details
PWA Studio v8.0.0
Updates to the Venia style guide
Enhanced Venia mini-cart experience
and much more

Apart from these, the Magento 2.4.1 release includes the Adobe Stock Integration v2.1.0., Magento Functional Testing Framework 3.1.0, and fixed issues in the Magento 2.4.1 core code

The Magento Commerce 2.4.1 release includes
According to Magento, the latest version is capable to prepare your store for the upcoming holiday season as it offers:

Improved PageBuilder that supports full-screen mode for easier editing of content and consistent experience editing content across the admin.
Sitewide analysis tool dashboard integration
Improved B2B Shipping methods
Improved shopping cart
Introduces new admin features
Magento 2.4.1 Release Notes:
Magento Open Source 2.4.1 Release Notes
Magento Commerce 2.4.1 Release Notes
Now that you know what the latest version has to offer, you surely cannot afford to miss these exciting features. Upgrade to the latest Magento 2 version as soon as it releases!

But it requires expertise to risk the upgrade process on your own. The easy way out is Meetanshi’s Magento 2 Upgrade Service that helps upgrade your store to the latest version of Magento.

Offering a secure upgraded shopping platform to the customers is a must in order to stand in the competition. And that is what the Magento 2.4.1 version is all about!

Apart from this, also have a look at the Magento 2.3.6 version released along with Magento 2.4.1.

Do let me know what you think about the upcoming version in the Comments section below.

Get acquainted with this Magento 2 version until the release of Magento 2.4.2 in January 2021!

Till then, keep sharing this post with Magento Community via social media.

Thank you!

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]]]>

What is CDN? Content Delivery Network Explained

What is CDN? Content Delivery Network Explained

  • What Is a CDN?
  • How Does a CDN Work?
  • Frequently Asked Questions for CDN
  • How to Choose a CDN?
  • What Is a CDN?

    CDN, also known as “distribution networks,” offers several points of presence (PoP) outside the origin server. This enables websites to better manage traffic by handling user requests more quickly, providing an overall better experience. In short, you’re using a CDN every time you visit a high-traffic site such as Amazon or catch up with your friends on Facebook. Their data centers keep allows to bring such content much more quickly regardless of the geographic location of individual users or the main website server. By spreading the delivery systems out over a large area, websites can reduce bandwidth consumption and page load times, shaving precious seconds off the time it takes to handle multiple user requests.

    What Is an Origin Server?

    An origin server is a computer that hosts the original version of your web files. Without a CDN, your site visitors will need to request information and receive the response directly from your site’s primary source. If each request has to return to your origin server, your website’s workload will increase. Furthermore, the farther the distance between the end-user and an origin server, the longer that user will have to wait for a page to load. That’s why using a CDN can help to decrease latency as it reduces the number of networks that must be crossed by a request and its response in reaching the final destination. A CDN can also protect the origin server from DDoS attacks or other online threats by masking the origin server and proxies requests from visitors, making the primary source practically invisible.

    What Is a CDN Edge Server?

    An edge server is a computer that can cache content retrieved from an origin server. It’s located in one of the points of presence, which are physical data centers spread worldwide. CDN edge servers serve as connections between separate networks, allowing traffic to flow quickly and efficiently from one location to another. To reduce the workload on an origin server and decrease the distance between a visitor and a web server, a CDN edge server stores content in strategic locations as close to the visitor as possible. As a result, visitors experience better performance and faster load times since they’re actually requesting content from a geographically closer server. That being said, origin servers will also be less likely to experience performance degradation when there is a sudden increase in your site’s traffic.

    How Does a CDN Work?

    Requests are handled by whatever network server is closest to the device that made the query. By caching data and spreading multiple requests for the same information over a network rather than a single web server, the traffic load becomes much more balanced. This eliminates problems such as page speed, browser crashes, and service disruptions. How a CDN might benefit you personally depends on the size of your site, its location relative to your core traffic source, and the amount of traffic generated. For example, a local business with a physical location that serves one small geographic area won’t benefit much from a CDN. However, if you’re an eCommerce business owner who needs a wider reach, or your website generates heavy traffic from diverse locations, then a fast, efficient CDN will help you retain your competitive edge. There are four main benefits of using CDN servers. Each of these builds on the other to help mitigate the problems of managing complicated pieces of content and servicing high-volume traffic. Effective content distribution networks should accomplish the following four things:

    Reducing Bandwidth Consumption

    One of the biggest expenses with some hosting services is bandwidth. Conserving the amount of bandwidth it takes to handle your traffic by multiplying your points of presence keeps your costs low. This is achieved through optimization tools such as caching, which places data into temporary storage on different computers or mobile devices for ease of access.

    Increased Overall Speed and Performance

    One of the biggest contributors to high bounce rates is latency. This is the increased time it takes to transfer information from the source to the use and vice versa. It’s usually caused by:
    • Delays in reading files due to blocked storage
    • Setbacks in data processing from the server
    • Type of data transmission, such as a fiber-optic network versus coaxial cables
    • Propagation, or the speed at which data travels from one node to another
    Many of these issues can be solved, or at least heavily reduced, by using an effective delivery network.

    Improved Security

    When all of the data transfer is conducted from a single server, it increases your vulnerability to malicious events like denial-of-service (DDoS) attacks and other vulnerabilities. In short, DDoS attacks are coordinated requests for information that are conducted from multiple locations and users at an appointed time; they can also be deployed automatically through bots. The purpose of this is to cause the server to crash due to traffic overloads. This is done by means of a threat such as extortion and blackmailing or just for the sake of making mischief. DDoS attacks can continue for hours or even days, making the website inaccessible to legitimate traffic. Using DDoS filters and spreading queries over several locations helps prevent artificially created traffic explosions. You can even use your CDN to keep hackers out and protect your sensitive data. This is achievable because CDNs continually refresh TLS/SSL certificates, providing higher authentication and encryption standards. They also deflect traffic away from your original server to proxies.

    Better Content Distribution

    Heavy traffic loads and hardware malfunction results in more downtime that most websites simply can’t afford. By distributing the traffic over multiple content delivery systems, your infrastructure and servers will have a less burden to carry. Here are some examples who can benefit from a CDN the most:
    • eCommerce. Websites such as these usually get heavier loads of traffic and need to handle requests from many different locations. However, if the site fails to provide the information required at a glance, countless opportunities can be missed. By efficiently distributing its content and delivering a faster response, CDN can prevent spikes in web traffic, avoiding unwanted crashes on the server.
    • Advertising. Online businesses rely heavily on multimedia-based ads – they can be both simple and innovative, yet more effective than traditional methods of advertising. However, these types of ads also require more resources, which can result in poor website loading times. The slower the site, the more customers abandon it. Advertising businesses need CDN to solve this problem as it stores cache content closer to the end-user, making the content load much faster. If the minimum load time can be maintained, the performance of the website will be better.
    • Online gaming. If advertising needs high resources for content, video games need even more resources. This is one of the biggest challenges for the online gaming industry – to keep delivering the best services possible to the largest amount of people around the world. CDN technology enables online games to have “push zones” where game developers can store large amounts of data on CDN servers, which means that the need to request data directly from the origin server is put at its lowest.
    • Entertainment. Content is the heart of the media and entertainment industry. From such streaming services like Netflix or Spotify to other media outlets, the content that they offer attracts millions of people every day. Such services need to have a solid strategy for distributing their content to keep their websites running perfectly no matter where someone is trying to access it.

    Frequently Asked Questions for CDN

    Here is some additional information about CDNs you might want to know:

    What’s the Difference Between Pull and Push CDNs?

    Some CDN providers give the option to pick between a pull or push zone, and choosing one depends on many factors and priorities. For example, a pull zone works by “pulling” site content from the nearest edge server and is the most common method to be used. Users can leave their content on the server with a pull zone and rewrite the URLs so that it would point to the CDN. When someone asks for a specific file, the CDN will first go to the original server, “pull” the file for the end-user, and cache that file when someone else wishes to download it. This method is suitable for sites that receive a great deal of traffic since content remains relatively stable, and the traffic will be spread out evenly. However, a pull zone can, at some points, work more slowly. For example, visitors who’ll try to access the file for the first time or try to download it after it has expired might notice a small difference in speed. Meanwhile, the push zone requires data to be uploaded to the CDN storage cloud since there is no existing source where the content was stored. This method requires users to be themselves responsible for providing content to the CDN, “pushing” it to the server. They can specify the content that is uploaded, when it expires, and when it is going to be updated. With that in mind, a push zone is recommended for minimal traffic sites – the content is pushed to the CDN once and left there until changes are needed.

    Does CDN Work With Mobile Devices?

    Yes. CDNs work with any desktop or mobile device that can be connected to the Internet. All of the processes are conducted from the source, not on the user end.

    How Can a CDN Speed Up My Website?

    There are three ways of how CDN can increase your site’s load times and overall speed:
    1. It distributes and stores diverse content types like images, text, and rich media files for faster access.
    2. Reduces bandwidth by serving content from several locations rather than pushing it all out from one server.
    3. Handles traffic spikes during peak times without disrupting the service.

    Is CDN Safe to Use?

    Security is one of the most important factors when it comes to CDN. Therefore your data is encrypted when being transferred from one endpoint to another. DDoS mitigation is also a significant concern when it comes to website security. Since information is stored on multiple data center locations, it reduces the chances servers from being overwhelming if such an attack does occur.

    Is CDN the Same as a Hosting Service?

    CDNs don’t host websites, but they can improve website performance of hosted servers by utilizing caching and other optimization methods to conserve bandwidth. Using a CDN can also improve website speed and prevent problems like connection disruptions, lax security, and slow content delivery. Content distribution networks can even work hand in hand with your hosting service provider. While one provides you with a platform to host your main website, CDN, on the other hand, provides the proxies to distribute it more efficiently.

    What Types of Websites Can Benefit from a CDN?

    Any form of B2B (business-to-business) or B2C (business-to-consumer) website that has a larger user base outside of their immediate geographic location can benefit from a CDN. They’re also helpful for bloggers and websites that have a high traffic volume.

    What’s Static and Dynamic Content?

    Static content is any web file that stays the same every time it’s delivered to the user. It rarely changes and doesn’t depend on user preferences. This type of content is usually stored in a CDN server, making it faster to process, cache, and deliver. On the other side, dynamic content changes based on user behavior or other variables, such as their time of visit, device, location, etc. A web page with dynamic content won’t look the same for everyone, making it more personalized and interactive. eCommerce websites and social media platforms are some of the more prominent examples of sites with this kind of content. However, unlike static content, dynamic content isn’t stored on a server. Instead, it uses server-side scripts to generate an HTML file in real-time and then send it to the user’s web browser. That’s why dynamic content is usually served from an origin server, not an edge server.

    CDN and VPN – What’s the Difference?

    Virtual Private Networks (VPNs) shield the user’s identity and use a range of servers in different locations to get around geographical and other restrictions on certain types of content. Content delivery networks speed delivery of information by sending and storing website content over a network of servers, allowing website visitors to access web pages from the closest available source. However, both provide additional layers of security for your website.

    How to Choose a CDN?

    Just like any other type of service provider, not all CDNs offer the same level of service, benefits, or functionality. Some CDN services are free, while some offer both additional premium services. Cloudflare is one of such a web-security company, known to be one of the most reliable content delivery network services available today. That is why we offer free Cloudflare services with all of our customers. A few key elements to consider when looking for a CDN service are your budget and requirements, and that includes anticipated needs in the case of future growth. In order to answer this question further, here’s a list of features any good CDN should have:
    • Push or pull functionality. Web owners should decide which caching method would best suit their type of website.
    • Origin shield services. This feature acts as an additional caching layer between an origin server and the CDN edge servers, which reduces the overall workload the primary source has to make.
    • Logging features. It allows users to search, store, analyze, and monitor the logging data and events from a CDN provider.
    • Cache-control. This HTTP cache header allows users to determine how or when a resource should be cached alongside its expiration time.
    • Customization capabilities. You should pick a service that allows you to modify a CDN to suit your needs. For instance, some CDN providers give their users access to customize their asset delivery, SEO, security measures, and mobile experience.
    • DDoS protection. Though a CDN can hide your origin’s IP address, you still need an additional layer of security to divert network-layer attacks, preventing hackers from potentially breaking into your website.
    • HTTP/2 support. Ensure that a CDN supports HTTPS, which is much more secure and provides faster web performance than the regular HTTP protocol.
    • Diagnostics, analytics, and reporting. These tools are necessary to monitor an origin server’s overall health, optimize your CDN configuration, etc.
    • Geo-filtering. Specify specific paths on your CDN endpoint and determine rules to restrict certain content based on location.

    Conclusion

    If you want to maintain your level of service as you grow your web presence, a reliable, scalable content delivery network is a worthy investment. In this article, we’ve learned all about what is CDN and how does it work, alongside some questions that might’ve needed a more in-depth explanation. If you have any more CDN-related questions, don’t hesitate to leave a comment down below.]]>

    How do I change the WordPress Site URL?

    How do I change the WordPress Site URL?


    Deprecated: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in /var/www/html/wp-content/plugins/urvanov-syntax-highlighter/class-urvanov-syntax-highlighter-langs.php on line 86

    Several reasons to change the URL

    The following are instructions for moving a WordPress installation from one URL to a different one. There are different cases for moving a WordPress install, as shown below.

    Case #1 — Moving from a subdirectory

    The first case is when a WordPress site moves from a sub-directory to its parent domain. For example:
    • Move from https://cozmot.com/blog to
    • https://cozmot.com
    If you’ve already moved your domain to a new URL, you are not able to log in since WordPress is configured to use the old URL.

    Case #2 — Adding or removing www

    Another reason to update your URLs is if you need to add or remove www from your domain. For example, if you’re using Cloudflare with DreamHost, you need to add www to your domain. So if it was previously example.com, you would change it to www.example.com. After adjusting the URL, you may also see a browser redirect error when viewing your site. It may say “Too many redirects” or “The page isn’t redirecting properly”.

    Case #3 — Adding ‘https’ to the URL

    If you’re using an SSL certificate, the first part of the URL changes from ‘http’ to ‘https’. If you’ve already made this change, you are not able to log in since WordPress is configured to use the old URL.

    Case #4 — Moving to a new domain

    The last case is when a WordPress site moves from one fully hosted domain to a different one. For example:
    • Move from https://example.com to
    • https://cozmot.com

    Option 1 – Changing the HOME and SITE URL using phpMyAdmin

    If you’ve already made any of the changes above, you’re not able to log into your dashboard. You can instead use phpMyAdmin to update the HOME and SITE URLs. Visit the following article for more information on how to log into phpMyAdmin:
    • Finding your phpMyAdmin login credentials
    1. Open phpMyAdmin.
    2. Click your database in the left pane. Several tables appear below it. Click on your wp_options table.
    3. Locate the siteurl and home rows. Click the pencil icon next to each to edit.
      When you scroll over these options, “browse” will appear.
    4. Click the pencil icon next to each to edit.
    5. Alter the URL by typing in a new one.
    6. Click the Go button to save the settings. Do this for both the ‘siteurl’ and ‘home’ options.
    You should now be able to log into your site at example.com/wp-login.php. Although this gives you access to your site, any former URLs in your database are still using the old URL. You should now use a plugin to update all URLs in your database to the new URL. View the following article for full instructions:
    • Changing all URLs in your WordPress database

    Option 2 – Changing the URLs in your wp-config.php file

    You can also change the URLs in your wp-config.php file. This is a little easier than editing your database and will give you immediate access to your site.
    The following assumes your Home and Site URL should be ‘example.com’.
    1. Log into your site using FTP or SSH.
    2. In your WordPress directory, edit the file titled wp-config.php.
      • Creating and editing files via FTP
      • Creating and editing a file via SSH
    3. In that file, add the following lines just above /* That’s all, stop editing! Happy blogging. */.

    4. If you visit your site now, you’ll see you can log in.
    Although this gives you immediate access to your site, the database is still not configured to use the correct HOME and SITE URL. You should now use a plugin to update all URLs in your database to the new URL. View the following article for full instructions:
    • Changing all URLs in your WordPress database

    Edit functions.php Edit functions.php

    If you have access to the site via FTP, then this method will help you quickly get a site back up and running, if you changed those values incorrectly.
    1. FTP to the site, and get a copy of the active theme’s functions.php file. You’re going to edit it in a simple text editor and upload it back to the site.
    2. Add these two lines to the file, immediately after the initial “<?php” line:
    update_option( 'siteurl', 'http://example.com' );
    update_option( 'home', 'http://example.com' );
    Use your own URL instead of example.com, obviously. 3. Upload the file back to your site, in the same location. FileZilla offers a handy “edit file” function to do all of the above rapidly; if you can use that, do so.

    Verifying the new HOME and SITE URL

    If you used options #1 above, the HOME and SITE URLs were updated in the database. You can confirm your site is now using the correct URLs in your dashboard.
      1. Log into your WordPress Dashboard.
      2. Navigate over to Settings > General.
      3. Here you’ll see the HOME and SITE URL your WordPress site is configured to use.
    ]]>