We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    How to generate invoice PDF & save it on server at invoice creation time?

    Follow the below steps to generate invoice PDF & save it on the server at invoice creation time.

    1. Create file event.xml on app/code/Magemonkeys/Saveinvoice/etc

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
      <event name="sales_order_invoice_save_after">
        <observer name="save_invoice_pdf" instance="MagemonkeysSaveinvoiceObserverSaveinvoice" />
      </event>
    </config>

    2. Create file Saveinvoice.php on app/code/Magemonkeys/Saveinvoice/Observer

    <?php
    namespace MagemonkeysSaveinvoiceObserver;
    
    use MagentoFrameworkEventObserverInterface;
    
    class Saveinvoice implements ObserverInterface
    {
        protected $_pdfInvoiceModel;
        protected $_outputDirectory;
        private $_myPdfStorageSubDirectory = "pdfinvoices";
    
        public function __construct(
            MagentoSalesModelOrderPdfInvoice $pdfInvoiceModel,
            MagentoFrameworkFilesystem $filesystem
            ) {
                $this->_pdfInvoiceModel = $pdfInvoiceModel;
                $this->_outputDirectory = $filesystem->getDirectoryWrite(MagentoFrameworkAppFilesystemDirectoryList::VAR_DIR);
        }
    
        public function execute(MagentoFrameworkEventObserver $observer)
        {
            try{            
                $invoice = $observer->getEvent()->getInvoice();            
                $pdfContent = $this->_pdfInvoiceModel->getPdf([$invoice])->render();
                //save to file  var/pdfinvoices/[IncrementID].pdf
                $this->_outputDirectory->writeFile($this->_myPdfStorageSubDirectory. "/" . $invoice->getIncrementId() . ".pdf" ,$pdfContent);
            } catch (Exception $e){
                $message = $e->getMessage();
            }
            return $this;
        }
    }

     

    How to solve “The address failed to save. Verify the address and try again.” error in Magento 2?

    You might get this error “The address failed to save. Verify the address and try again.”

    If you can see the exception.log displaying the Email Validation failed error, then you can solve this error by doing some PHP settings.

    If You are a Plesk customer, then go to PHP settings, and then check the field “include_path” and you will see the value “.:/opt/Plesk/php/7.2/share/pear” replace this with “.”. and then press Apply button.

    After performing the above steps, you should overcome the programming error.

    See Attached Screenshot for reference

    Magento 2: move wishlist link after media images in product detail page

    In this article, we are going to move the wishlist link under the media block after view more images.

    The first step is to create file catalog_product_view.xml in custom theme :

    Create app/design/frontend/Magemonkey/theme/Magento_Catalog/layout/catalog_product_view.xml

    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
            <move element="view.addto.wishlist" destination="product.info.media" after="-"/>
        </body>
    </page>

    after executing above step, you need to execute the below command

    php bin/magento cache:flush

    That’s it.

     

    Invalid customer address id at checkout – Magento2

    I focused merely on the solution and I just changed the function validateForCart
    In vendor/magento/module-quote/Model/QuoteAddressValidator.php file :

    from :

     public function validateForCart(CartInterface $cart, AddressInterface $address): void
        {
            $this->doValidate($address, $cart->getCustomerIsGuest() ? null : $cart->getCustomer()->getId());
        }

    to :

    public function validateForCart(CartInterface $cart, AddressInterface $address): void
        {
            $this->doValidate($address, $cart->getCustomerId() ? $cart->getCustomer()->getId() : null );
        }

    It worked for me very well. Let me know if this trick helped you too.

    When You Should Develop A New Magento Extension For Your Magento Store?

    As we all know that extensions are used by websites or online stores to add in a new feature or functionality. The functionality can be in the form of any needed customization, to improve sales, enhance product searches, etc. So, it is important for you to identify whether you need to have a new feature added to your current online store or not. In case you are not making sales as expected or you need to improve user experience, then you will need an extension for the job. Sometimes you will need to come up with extensions that are tailored to your business needs and this is the time you invest in a new extension development for your eCommerce store.

    So, there may come some situations when you will feel the need to develop Magento extension and some have been explained below. It means, if you too encounter any one of these situations, it is time you think about investing in a new extension for your store and get it developed by an expert Magento development company.

    To add in new functionalities to the store

    Extensions are the best way for a website to add new functionalities. Right from improving the workflow of operations to enhancing overall performance, Magento extensions can do much for the site. These extensions add features to the store that works in favor of the users. Some of such extensions that you can add to the store will help the users with tasks like searching for products, comparing them, sorting them, simplifying checkout, and much more. If you feel you are missing out on something you can choose to go for our consultation service. Our team will first look into your store to identify the benefit of having such functionality in there. Based on that will suggest you an extension that can add value to your business and get it customized to meet your needs.

    Improve the efficiency of your website backend

    Apart from helping eCommerce stores deliver better UX, extensions can be used to improve the efficiency of the backend. The use of extensions is highly recommended for backends of online stores as it makes it easier for the admins to manage different aspects of the store easily. A good number of extensions are now available in the market which can be used to handle various backend tasks like managing inventory, customer, reviews, sales, analytics, and much more. This way the store owners have to take less stress and concentrate more on business. If you don’t have one and feel that such an extension can reduce your load, it is time you think in that direction. Our Magento developers will go through your store and list out all the needed extensions that will give your store backend a boost. We will provide all the needed customizations to ensure it works well for your store.

    Easily manage and track delivery

    In case your business is growing and the number of orders is increasing, you will need an effective system in place to manage the orders and their deliveries. This is crucial for any business as delays in the delivery of products will bring in a bad reputation for the business. Businesses have to keep track of the products and let the customers know about the same. Now it can be overwhelming! Here our developers will suggest extensions that can help your business to take care of such tasks quickly without having to take the trouble of handling them manually. Our years of experience in this field help us to recommend the right extensions, customize them completely and turn your whole delivery management into an easy task.

    Multi-store handling

    Multi-store is no more a new concept these days. Businesses with different products or market niches now handle their multiple storefronts using a single backend. Now, this is not as simple as said! So, if yours is a similar business you will need an extension that can simplify your life. Here at Mage Monkeys, we have seen such kinds of online businesses in the past and have a clear understanding of what kind of extension you will need to run everything smoothly. Based on your business needs we will design and develop a Magento extension that takes care of your business requirement.

    Enhanced user experience

    For any online store, offering an excellent user experience is very important. A website that is user-friendly will only be frequently visited by the customers. So, in case your online store fails to be user-friendly, it is time you invest in Magento extensions that can help you with the task. When we speak of user experience two main things come to our mind. They are – the deliverance of ease of shopping and security of customer data. Both of these elements will let the users easily shop at your store as they will have peace of mind regarding all their transactions and data being safe at your site. If the user experience delivered by the store is not up to the mark, then users will no longer visit it. This means a loss of traffic and revenue. In such a scenario, we will look into factors that are diminishing user experience and will suggest extensions that can be build to resolve the problem.

    Manage inventory effectively

    For any eCommerce business managing its inventory is the greatest challenge. It is important to maintain a perfect balance as low inventory can lead to an out-of-stock situation while the excess of it can lead to your money getting blocked unnecessarily. Taking care of these things manually may be hectic and cumbersome and with the right use of Magento extensions, this can be resolved. Our developers understand this pain point of your business and so we offer to make a Magento extension that is personalized and deals with the specific inventory management issues of your business.

    Third-party apps for mobile are somewhat similar to what extension means for a store. Extensions enhance the capability of an eCommerce store. Generally, many extensions will be available on the official marketplace, but they’re developed with market needs. It’s natural that you may have some different needs and extensions for the same may not be available on the marketplace. This is the time when a certified agency like Mage Monkeys comes into the picture where we help you with Magento extension development as per your business needs.

    Extensions developed by us are:

    – Easy to integrate

    – Easy to install

    – Light-weighted in code size

    – Compatible with all versions of your eCommerce store

    – Safe and secure

    In short, Magento development company like Mage Monkeys has the immense experience in building fully-customized Magento extensions for business clients to satisfy the changing needs of their customers.

    If you also wish to develop a Magento extension for your business then talk to our team and have a detailed discussion!

    How Can You Hire A Certified Magento Developer For Your Ongoing Magento Development Requirement?

    In an eCommerce business, you are bound to carry out regular improvements and make constant changes. There is always a need to add in a new feature or tweak the existing one. This happens every now and then. To let these changes happen regularly, you will have to hire a certified Magento developer who can understand your changing needs and come up with solutions quickly.

    This is where an eCommerce development partner like Mage Monkeys can help you. We understand that your business needs to be meticulous about choosing the right Magento developer for your eCommerce store needs.

    Here in this post, we bring to you the right tips that you can follow to choose certified Magento developers for your ongoing eCommerce store project needs.

    They are as mentioned below:

    Agency or freelancer
    You need to understand that there is a limit to the things that the freelancer can do for you. It is not necessary that the freelancer you choose is certified in Magento technology, nor you can be sure about the quality of services they can offer you. Moreover, chances are low that a single Magento developer will not possess all the needed capabilities to complete your project as expected.

    In case you need multiple developers for your ongoing project then managing them all will not be easy if they are all freelancers. It is at this point you should think about hiring an agency like ours.

    Being an entrepreneur, you need time to spend on the core objectives of your business rather than using it all to just manage developers and check the work progress. A good Magento development company will offer you quality work and here everything will be managed by a dedicated project manager who has a team of certified Magento developers capable to handle your business requirements well.

    Team with an experienced project manager
    When you are planning to choose a Magento development team for your ongoing business requirements then you will need to choose a team that is lead by an experienced and skilled project manager (as said above). Mage Monkeys has such kind of strong team of Magento developers that are capable to work for your business needs as and when required. Your developers will be properly led by our project lead. So as the requirements of the projected increase or decrease with time, the project lead will scale up or down the team as and when needed. Again, you will not have to worry about the task of managing the developers on their own as that will be taken care of by our project lead itself.

    The knack to fit in the ongoing project
    Not all developers have the capability to easily understand the current status of your project and quickly fit in and start working. Freelancers generally have the technical knowledge and the experience that they have gained from the projects they have done before. Now in the case of an agency like ours, it is built by a team of certified Magento developers who have years of experience in the field of Magento development and have worked for different industry niches. This makes our developers a better choice for your project. They can easily start working on your project by making needed feature updates, technology upgrades, resolving errors, etc.

    You get what you pay for
    If you are low on budget then you may choose to go for a freelancer to complete your project. However, this does not offer you the guarantee of the high-level technical expertise and experience that you are looking for. They may have worked on a few projects but that does not mean they can offer you the best solution.

    On the other hand, when you hire Magento developer or a team from a Magento agency like ours you can be sure that you will be able to find quality Magento services from developers who are skilled and passionate about what they do. When compared to the expense of hiring freelancers, an agency can seem to be a bit expensive to meet your Magento requirement. However, the quality the developers offer while ensuring the work is completed within the stipulated time is what makes them better from the former option.

    Flexible engagement models
    Different engagement models are offered by Magento development agencies like ours to let our clients choose a certified Magento developer based on their project requirements. They are:
    • Fixed cost
    This is the most common pricing model selected by businesses and developers. Here a contract is signed up between both parties for a fixed amount for completing the project. This is generally chosen when the requirements are predictable and the developers have a clear idea about the resources and time needed for the same.
    • Project-based
    Here you can hire a Magento developer based on the requirement of your business project. The developer can be hired on an hourly basis to match the work scope. This kind of option can be good for mid-sized or bigger projects due to the flexibility it offers the developers and the business in question to adjust their requirements.

    Reliable and timely delivery
    One thing that all businesses look for when hiring certified Magento developers is to confirm whether they can provide your reliable services and that too within the deadline or not. Our Magento development company can assure to offer quality development services for your ongoing requirements without skipping any deadlines. Our team of developers is completely professional and they will ensure your requirements are met properly and as expected.

    Conclusion
    Here at Mage Monkeys, our main objective is to help your business enhance its growth and boost revenue by offering affordable and reliable Magento development services. Based on business needs, you can choose to hire Magento developers from us. Our team will work towards letting you offer an improved user experience to your consumers on your eCommerce store, thus bringing in more profits!

    If you are in search of Magento developers who can help you with your ongoing development needs, talk to us!

    How Magento Agencies Give You Cost Estimation for Your Magento Development Requirement?

    Building an online business needs you to prepare yourself with a few things like deciding the set of products for the store, finding reliable partners, establishing an effective delivery service, and coming up with a strong marketing strategy.

    Above all, something that is more crucial and critical in the development of an eCommerce website. The look and feel of your store, the way it has been designed, custom functionality you have added to make the experience simple for the users -together everything contributes towards the success of your online store.

    Today businesses prefer to go for Magento for eCommerce store development for a number of reasons like its popularity, reliability, flexibility, etc. among others. To build an eCommerce store on Magento, businesses should have an idea of the estimated cost of development, to begin with.

    Having an understanding of the estimated costs will help the business to set their budget accordingly while knowing the right price to develop the website cannot be known easily upfront as it is influenced by a number of factors.

    When you choose a Magento development agency like ours we will let you know the estimated cost of your Magento development requirement based on those influencing factors.

    So, let’s see them one by one…

    Magento Editions
    Magento is an open-source platform, but there are other two versions that offer additional functionalities at added expenses. This means the final price of your Magento development completely depends on the version you choose for your project.

    In the case of Magento 2, there are three versions and they are:

    Magento 2 Open Source
    If you want to save on your development costs by paying nothing for the platform then you can choose this version. It is open source and so can be used free of charge. However, it comes with limited options and is generally preferred for small businesses. So, if yours is a small business then we recommend you go with this version. In this case, you will have to pay for the website development service only.

    Magento 2 Commerce and Magento 2 Commerce Cloud
    Both these versions of Magento are paid. Both of them let the businesses enjoy added functionality.

    However, both versions have some points of difference. In the case of the first version, you have to choose the right hosting and the servers where you plan to run the platform. In the case of Magento Commerce Cloud, it chooses AWS servers on a default basis.

    So based on which version you decide for your Magento store, developers with the required knowledge and skills will be selected to work for you by us. Being one of the leading Magento agencies, we have Magento developers with varying levels of experience and expertise. The hourly rate of the developers chosen for you will depend on the level of expertise required for the project.

    Hosting
    Magento will take care of your hosting needs if you choose Magento Commerce Cloud. In case you go for the other two options, then it will be on your side to choose the hosting providers. Based on the size of your store and the kind of traffic you want it to generate, you will have three options to choose from. They all differ in prices and come with different security levels. They are:

    Shared server: It has low security. Here more than one website is hosted on the server. A load of a website will affect the performance of other sites on the server.

    Virtual private server: It has a medium level of security. Here more than one website will be hosted on the server and the resources will be distributed among them.

    Dedicated server: It has a high level of security. Here a dedicated server will be available for a website and the website will have full control over the server.

    Based on your project needs and the limit of your budget, we will suggest you the right hosting provider and the price estimation for the service will be based on the choice you make.

    Design
    The overall website development rate will also have to include the cost of designing the Magento site. When you look at the whole picture, you need to understand that better designs will help with higher conversion rates. Keep in mind that you will have a very little window of opportunity to impress your visitors and your design will decide whether they will stay or leave.

    Using Magento themes is the most cost-efficient and time-saving way of creating designs for Magento websites. Moreover, when you want to have the site designed in the least amount of time then choosing themes can be good for you.

    However, choosing themes may not seem to be a wise choice always for Magento development, especially when you want the business to stand out. Designing customized themes that will help your business present well among the audience and stay ahead of the competition is what matters. Here at Mage Monkeys, our designers can help you design your storefront in a unique style that will help you convert your visitors into loyal customers with ease. The cost estimation for hiring designers will depend on the man-hours needed, the level of expertise required, and the complexity of your website design.

    Customizations
    Customizing stores as per your business needs is what owners look forward to when investing in eCommerce store development. Magento customization is all focused on maximizing revenue for the business through increased customer engagement. It is achieved by creating a completely optimized online shopping experience for visitors so that they make a purchase at the end of their journey. Our developers understand the real essence of such online stores and offer customization services that will help them achieve a competitive edge in the market while boosting revenue on the other hand. Right from offering consultation to store redesigning, we offer an array of services. So based on what customization service the business client needs for their site, the cost can be estimated.

    Third-party integrations
    One of the main reasons why people opt for Magento is the level of customization it offers. With third-party integration, it is possible to accomplish vast possibilities for your online store. You get to automate your online store by using such third-party applications. Here at Mage Monkeys, we can help you integrate all the needed third-party applications without causing any complications. Our developers will run the applications for you to ensure it is compatible with your Magento store and is not causing any errors or issues. The complexity of integrating third-party applications varies and so is the cost of doing it.

    User experience design
    Right user experience design will help the business establishment in the market as a brand. The user experience of a Magento store has to be designed in a way that it offers a perfect balance between boosting conversions and expressing itself well. Properly thought-out page layout and well-laid navigation will lead the visitors to spend more time on the site. This means investing ineffective user experience design is the need of the hour. Our Magento designers provide a range of design services to help businesses reach their goals. Based on the complexity of design and needed requirements, the work hours of designers with the required expertise can be calculated.

    Extensions
    Extensions are used to extend the functionality of the Magento store. Some of such extensions are free while you need to spend money on others. Extensions are used when the features of your online store are not enough or do not satisfy all your requirements. Using the default-free ones may not always work in your favor regardless of the edition of Magento you are using. The added functionality can be easily implemented in your store just by using extensions.

    The cost of extensions can vary due to many factors, so the Magento development quote provided by the development firm will include their rate. Here at Mage Monkeys, we try to keep the development costs to a minimum to help our clients have extensions build at an affordable rate.

    As such extensions come at a price, you need to be cautious when using them. Extensions may face compatibility issues on the site or with other already existing extensions. Chances are there those incompatible extensions may cause low page speed or errors. So, the use of extensions should be done kept to a minimum. We can ensure you build extensions that are highly compatible and runs smoothly with your site.

    If you are planning to develop a Magento store for your retail business then we can help you with the job. To get a cost estimate for your project, just contact us today.

    Magento 2: How to Add the filter option value in title on category page?

    Step 1). Create the Vendor/Module/etc/frontend/event.xml in your module

    <event name="controller_action_postdispatch">
       <observer name="change_title_filter" instance="VendorModuleObserverFiltertitle" />
    </event>

    Step 2). Create the Vendor/Module/Observer/Filtertitle.php in your module

    <?php
    
    namespace VendorModuleObserver;
    
    use MagentoFrameworkEventObserverInterface;
    use MagentoFrameworkEventObserver;
    use MagentoFrameworkViewLayoutInterface;
    
    class Filtertitle implements ObserverInterface
    {
        protected $context;
        public function __construct(
            MagentoFrameworkViewElementTemplate $context,
            MagentoFrameworkViewResultPage $resultPage,
            MagentoFrameworkViewPageConfig $pageConfig
        ) {
            $this->pageConfig = $pageConfig;
            $this->resultPageFactory = $resultPage;
            $this->context = $context;
        }  
        public function execute(MagentoFrameworkEventObserver $observer)
        {
            $layout = $this->context->getLayout();
            $pageMainTitle = $layout->getBlock('page.main.title');
            if ($pageMainTitle) {
                $blockfilter = $layout->getBlock('catalog.navigation.state');
                if($blockfilter){
                    $selectedFilters = $blockfilter->getActiveFilters();
                    if (!empty($selectedFilters)){
                        $filters = array();
                        foreach($selectedFilters as $filter){
                            $filters[] = $blockfilter->stripTags($filter->getLabel());
                        }
                        if(count($filters) > 0){
                            $activefilters = __("Your selection: ").implode(" - ", $filters);
                            $pageMainTitle->setPageTitle($activefilters);
                        }
                    }
                }
            }
        }
    }

     

    How to send mail to admin after customer signup front-side in Magento 2?

    By default in Magento 2 does not provide the mail functionality to admin when new customers signup. It means no email will be sent to the admin when a customer registers with the front side.

    If you want to get the mail sent to admin when new customer signup happens then do follow below steps:

    Step 1: Create a registration file like

    <?php
    MagentoFrameworkComponentComponentRegistrar::register(
        MagentoFrameworkComponentComponentRegistrar::MODULE,
        'Magemonkey_MailtoAdmin',
        __DIR__
    );

     

    Step 2: Create event file like

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
        <event name="customer_register_success">
            <observer name="sendmail_toadmin" instance="MagemonkeyMailtoAdminObserverMailtoAdmin"/>
        </event>
    </config>

     

    Step 3: Create module file like Magemonkey/MailtoAdmin/etc/module.xml

    <?xml version="1.0" ?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
        <module name="Magemonkey_MailtoAdmin" setup_version="1.0.0"/>
    </config>

     

    Step 4: Create PHP file in Magemonkey/MailtoAdmin/Observer/MailtoAdmin.php

    <?php
     
    namespace MagemonkeyMailtoAdminCustomObserver;
    
    use MagentoFrameworkEventObserverInterface;
     
    class MailtoAdmin implements ObserverInterface
    {
     
        const XML_PATH_EMAIL_RECIPIENT = 'trans_email/ident_general/email';
        protected $_transportBuilder;
        protected $inlineTranslation;
        protected $scopeConfig;
        protected $storeManager;
         protected $_escaper;
        
        public function __construct(
            MagentoFrameworkMailTemplateTransportBuilder $transportBuilder,
            MagentoFrameworkTranslateInlineStateInterface $inlineTranslation,
            MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
            MagentoStoreModelStoreManagerInterface $storeManager,
            MagentoFrameworkEscaper $escaper
        ) {
            $this->_transportBuilder = $transportBuilder;
            $this->inlineTranslation = $inlineTranslation;
            $this->scopeConfig = $scopeConfig;
            $this->storeManager = $storeManager;
            $this->_escaper = $escaper;
        }
     
        public function execute(MagentoFrameworkEventObserver $observer)
        {
            
            
            $customer = $observer->getData('customer');
            
            $this->inlineTranslation->suspend();
            try
            {
                $error = false;
                
                $sender = [
                    'name' => $this->_escaper->escapeHtml($customer->getFirstName()),
                    'email' => $this->_escaper->escapeHtml($customer->getEmail()),
                ];
                $postObject = new MagentoFrameworkDataObject();
                $postObject->setData($sender);
                $storeScope = MagentoStoreModelScopeInterface::SCOPE_STORE;
                $transport =
                    $this->_transportBuilder
                    ->setTemplateIdentifier('1')
                    ->setTemplateOptions(
                        ['area' => MagentoFrameworkAppArea::AREA_FRONTEND, 
                        'store' => MagentoStoreModelStore::DEFAULT_STORE_ID,]
                    )
                    ->setTemplateVars(['data' => $postObject])
                    ->setFrom($sender)
                    ->addTo($this->scopeConfig->getValue(self::XML_PATH_EMAIL_RECIPIENT, $storeScope))
                    ->getTransport();
                $transport->sendMessage(); ;
                $this->inlineTranslation->resume();
                
                
            }
            catch (Exception $e)
            {
                MagentoFrameworkAppObjectManager::getInstance()->get('PsrLogLoggerInterface')->debug($e->getMessage());
            }
        
        }
     
    }

     

    Step 5: Then after run the below commands.

    php bin/magento setup:upgrade
    php bin/magento setup:static-content:deploy
    php bin/magento cache:flush

     

    That’s it…

    Now clean the cache and check it by creating new customer signup. You will find the mail of new customer’s sign up.

    Magento 2.3.5-P2 error cannot use a scalar value as an array in SessionManager.php on line 492

    The following error occurs while we using Redis for session storage Or file session storage :

    Warning: Cannot use a scalar value as an array in /home/web/domains/web.com/public_html/vendor/magento/framework/Session/SessionManager.php on line 492


    – Please follow the below steps to resolve it :

    Step 1: Please first override the following file: vendor/magento/framework/Session/SessionManager.php

    Step 2: Open SessionManager.php and find following function ‘_getHosts()’  replace below line from this function :

    return $_SESSION[self::HOST_KEY] ?? [];

    replace it with:

    return isset($_SESSION[self::HOST_KEY]) ? [$_SESSION[self::HOST_KEY]] : [];
    

    That’s it! The error should be solved now.