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.

    Is your site slow? Let’s talk

    While discussing with many leads, we realized website owners face this general problem their site runs slow.

    There could be multiple reasons behind it, such as,

    – Poor programming
    – Poor server
    – Poor technical configuration
    – Unoptimized media
    – JavaScript, CSS, or other Technical factors
    – & many more

    The above reason always leads to slowing your site which will decrease your sales cycle. You will not be able to see your sales growth with a slow site.

    Thus, to overcome this problem, with certified in-house developers, Mage Monkeys comes with our website speed expert unit.

    We have trained and skilled developers who have proven experience in making your site faster.

    If you are too dealing with a slow site issue, then let’s discuss it now. We can give you a booster speed in a few days.

    Live Stream Shopping – The New Way of eCommerce

    Live streaming shopping is where a company or a brand or an individual sells something in real-time through streaming videos to a live audience. The videos are broadcasted over a website, on a social network or a dedicated platform for viewers to see and interact. Video streaming shopping help shoppers to buy from the brand instantly and this lets the brand deliver instant gratification to customers.

    Live streaming is the latest trend followed in the eCommerce industry and it offers some benefits to businesses supporting the claim. They are:

    • Helps drive sales

    Live streaming helps businesses to offer a more immersive shopping experience to the audience and speed up the customer buying journey. As compared to other conventional methods, live streaming is more inclined to boost sales as it helps to bring in exclusive and time-sensitive offers to customers directly.

    • Better customer experiences through stronger human connections

    Live shopping helps businesses to recreate the in-store shopping experience for the audience. This helps potential customers to be directly involved with the brand and its products. Now, this means better sales opportunities for businesses.

    • Storytelling always works

    Videos help eCommerce businesses to present their products to the audience in the form of storytelling. This helps them with building brand awareness and boosting sales through improved customer engagement.

    Live stream is the future of eCommerce shopping. It has a great potential when it comes to engaging the audience and boosting sales. This means if you are looking for ways to witness exponential growth and stay competitive, exploring the possibilities of integrating live stream into your eCommerce business is worth a try.

    Top Five FREE Plugins Which Can Increase Sales

    There are thousands of free plugins available in the market and it can be a cumbersome task to choose the right one for your Magento store. To help you out, here we have listed out the top five free plugins that you can integrate with your eCommerce store to improve its performance and boost sales.

    1. Site search

    The Site Search extension will bring in the most relevant and highly-accurate search results to the shoppers who are looking for products. It will provide product filter tools, guided navigation, and an auto-complete feature to let customers quickly find and reach their destination. For the business, it will mean increased revenue chances and higher conversion rate.

    1. Shop By Brand

    With the Shop by Brand plugin businesses will be able to easily feature the popular and top brands on their eCommerce store. This will make it easy for the shoppers to find their favourite brand and shop instantly.

    1. Improved popups

    With the popup extension in place, eCommerce businesses will be able to dissuade visitors from leaving the store with making a purchase or taking a specific action. The popup can be set based on an event trigger which can be time specific or based on the movement of the visitor on the store. This will help in improving conversions while boosts customer engagement.

    1. Advanced report

    This is an innovative Magento extension that will let you track and manage your online store through advanced reports. Here business owners and the marketing team will be able to make informed decisions by learning from the data collected from orders, sales, customers, and products.

    1. Social login

    This Magento extension will help your customers to quickly login to your Magento store without having to go through long and complicated registration process. Here customers can choose to use their login details of preferred social media account like Facebook, Twitter, or Instagram.

    Conclusion

    Plugins help eCommerce sites to enhance their performance by adding in new functionalities. A better performing online store will attract more visitors and encourage them to shop more by offering enhanced shopping experience.

    Magento 2: How to add close button on error and success message?

    Step1 : Override message.js in current theme file on the following path.

    – /app/design/frontend/Magemonkey/child/Magento_Theme/web/js/view/

    – Add the below code:

    /**
     * Copyright © Magento, Inc. All rights reserved.
     * See COPYING.txt for license details.
     */
    
    /**
     * @api
     */
    define([
        'jquery',
        'uiComponent',
        'Magento_Customer/js/customer-data',
        'underscore',
        'escaper',
        'jquery/jquery-storageapi'
    ], function ($, Component, customerData, _, escaper) {
        'use strict';
    
        return Component.extend({
            defaults: {
                cookieMessages: [],
                messages: [],
                allowedTags: ['div', 'span', 'b', 'strong', 'i', 'em', 'u', 'a']
            },
    
            /**
             * Extends Component object by storage observable messages.
             */
            initialize: function () {
                this._super();
    
                this.cookieMessages = _.unique($.cookieStorage.get('mage-messages'), 'text');
                this.messages = customerData.get('messages').extend({
                    disposableCustomerData: 'messages'
                });
    
                // Force to clean obsolete messages
                if (!_.isEmpty(this.messages().messages)) {
                    customerData.set('messages', {});
                }
    
                $.mage.cookies.set('mage-messages', '', {
                    samesite: 'strict',
                    domain: ''
                });
            },
    
            RemoveMessage: function () {
                setTimeout(function () {
                    $('.page.messages').hide()
                }, 1000);
            },
            /**
             * Prepare the given message to be rendered as HTML
             *
             * @param {String} message
             * @return {String}
             */
            prepareMessageForHtml: function (message) {
                return escaper.escapeHtml(message, this.allowedTags);
            }
        });
    });

    Step2 : Override messages.phtml in current theme file on the following path.

    – /app/design/frontend/Magemonkey/child/Magento_Theme/templates/

    – Add the below code:

    <?php
    /**
     * Copyright © Magento, Inc. All rights reserved.
     * See COPYING.txt for license details.
     */
    ?>
    <div data-bind="scope: 'messages'">
        
            <!-- ko if: cookieMessages && cookieMessages.length > 0 -->
            <div aria-atomic="true" role="alert" data-bind="foreach: { data: cookieMessages, as: 'message' }" class="messages">
                <div data-bind="attr: {
                    class: 'message-' + message.type + ' ' + message.type + ' message',
                    'data-ui-id': 'message-' + message.type
                }">
                    <div data-bind="html: $parent.prepareMessageForHtml(message.text)"></div>
                   <div class="close"  data-bind="click: $parent.RemoveMessage"></div> 
                </div>
            </div>
            
            <!-- /ko -->
    
            <!-- ko if: messages().messages && messages().messages.length > 0 -->
            <div aria-atomic="true" role="alert" class="messages" data-bind="foreach: {
                data: messages().messages, as: 'message'
            }">
                <div data-bind="attr: {
                    class: 'message-' + message.type + ' ' + message.type + ' message',
                    'data-ui-id': 'message-' + message.type
                }">
                    <div data-bind="html: $parent.prepareMessageForHtml(message.text)"></div>
                    <div class="close"  data-bind="click: $parent.RemoveMessage"></div>
                </div>
            </div>
            
            <!-- /ko -->
        
    </div>
    <script type="text/x-magento-init">
        {
            "*": {
                "Magento_Ui/js/core/app": {
                    "components": {
                            "messages": {
                                "component": "Magento_Theme/js/view/messages"
                            }
                        }
                    }
                }
        }
    </script>

    that’s it

    Here is message design and output :

    Magento 2 : Get request params in your controller file

    If you want get query string params in controller file, then you can try like below.

    <?php
    namespace MageMonkeyCheckReqControllerIndex;
    
    use MagentoFrameworkControllerResultFactory;
    use MagentoFrameworkAppActionContext;
    use MagentoFrameworkViewResultPageFactory;
     
    class Index extends MagentoFrameworkAppActionAction
    {
         protected $resultPageFactory;
        
        public function __construct(
            Context $context,
            PageFactory $resultPageFactory
        ) {
        
            parent::__construct($context);
            $this->resultPageFactory = $resultPageFactory;
        }
        
        public function execute()
        {	
            $params = $this->getRequest()->getParams();
            /* print_r($params); die */
            $this->_view->loadLayout();        
            $this->_view->getLayout()->initMessages();
            $this->_view->renderLayout();
        }
    }

    Magento 2 : Redirect custom page after login using plugin

    Create di.xml and add the below code
    Magemonkey/Redirect/etc/frontend/di.xml

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <type name="MagentoCustomerControllerAccountLoginPost">
        <plugin name="redirect_custom_url" type="MagemonkeyRedirectPluginRedirectCustomUrl" sortOrder="1" />
      </type>
    </config>

    Create the plugin
    Magemonkey/Redirect/Plugin/RedirectCustomUrl.php

    <?php
    namespace MagemonkeyRedirectPlugin;
    class RedirectCustomUrl
    {
        public function __construct(
            MagentoStoreModelStoreManagerInterface $storeManager,
            MagentoFrameworkAppHttpContext $authContext,
            MagentoFrameworkAppResponseRedirectInterface $redirect,
            MagentoFrameworkAppRequestInterface $request        
        ){
    
            $this->storeManager = $storeManager;
            $this->authContext = $authContext;
            $this->redirect = $redirect;
            $this->_request = $request;        
        }
        public function afterExecute(MagentoCustomerControllerAccountLoginPost $subject,$result)
        {
            $currentWebsiteId = $this->storeManager->getStore()->getWebsiteId();
            $isLoggedIn = $this->authContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
            if ($isLoggedIn){
                $customUrl = 'customurl.html';
                $result->setPath($customUrl);
        	}
            return $result;
        }
    }

     

    Magento 2 – How to change local date to UTC date?

    You can try below code to change local date to UTC date.

    <?php
    namespace MagemonkeyUtcDateModel;
    
    use MagentoFrameworkStdlibDateTimeTimezoneLocalizedDateToUtcConverterInterface;
    
    class UtcDate
    {
        /**
         * @var LocalizedDateToUtcConverterInterface
         */
        private $localtoutc;
    
        public function __construct(
            LocalizedDateToUtcConverterInterface $localtoutc
        ) {
            $this->localtoutc = $localtoutc;
        }
    
        /**
         * convert UTC Date
         *
         * @return string
         */
        public function convertUTCdate(): string
        {
            $localDate = date('m-d-Y');
            return $this->localtoutc->convertLocalizedDateToUtc($localDate);
        }
    }

     

    How to change order status using cron?

    Step 1: First you need to add registration.php file in the following path: app/code/Magemonkey/Orderstatus/

    Add below code in it.

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

    Step 2: Next, you need to add module.xml file in the following path:
    app/code/Magemonkey/Orderstatus/etc/

    Add below code in it.

    <?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_Orderstatus" setup_version="1.0.0">
        </module>
    </config>

     

    Step 3: Now you need to add Orderstatus.php file in the following path: app/code/Magemonkey/Orderstatus/Cron/

    Add below code in it.

    <?php
    
    namespace MagemonkeyOrderstatusCron;
    
    class Orderstatus
    {
    	protected $_logger;
    	protected $_orderCollectionFactory;
    	protected $orderObj;
    	protected $timezoneInterface;
       	
       	public function __construct(
           PsrLogLoggerInterface $logger,
           MagentoSalesModelResourceModelOrderCollectionFactory $orderCollectionFactory,
           MagentoSalesModelOrder $orderObj,
           MagentoFrameworkStdlibDateTimeTimezoneInterface $timezoneInterface
       	) 
        {
         	$this->_logger = $logger;
         	$this->_orderCollectionFactory = $orderCollectionFactory;
         	$this->_orderObj = $orderObj;
         	$this->_timezoneInterface = $timezoneInterface;
        }
    
    	public function execute()
    	{
    		$paymentMethod = 'stripe_payments_sofort';
    		/* get order collection */
    		$collection = $this->_orderCollectionFactory->create()->addFieldToSelect('*')
    		->addFieldToFilter('status', ['in' => 'pending']);
    
    	     /* join with payment table */
    	    $collection->getSelect()
    	    ->join(
    	        ["sop" => "sales_order_payment"],
    	        'main_table.entity_id = sop.parent_id',
    	        array('method')
    	    )
    	    ->where('sop.method = ?',$paymentMethod);
    
    	    /* get current date time */
    	    $current_datetime = $this->_timezoneInterface->date()->format('Y-m-d H:i:s');
    	    
    	    /* set default time in second */
    		$set_default_time = 3600;
    	    foreach ($collection->getData() as $key => $orders) {
    	    	
    	    	$created_at = $orders['created_at'];
    			$dateTimeZone_order = $this->_timezoneInterface->date(new DateTime($created_at))->format('Y-m-d H:i:s');
    
    			/* get time diff from order datetime and current datetime */
    			$time_diff = strtotime($current_datetime) - strtotime($dateTimeZone_order);
    
    			/* change order status to processing */
    			if($set_default_time <= $time_diff){
    				/* @var $order MagentoSalesModelOrder */
    				$order = $this->_orderObj->load($orders['entity_id']);
    			    $order->setStatus("processing");
    			    $order->save();
    			}
    	    }
    	}
    }

     

     

    Latest Magento Security Update is Launched – Have you installed it?

    Magento has released security updates for Adobe Commerce and Magento Open Source.

    These updates resolve a vulnerability rated critical.

    Avoiding installation of such patches may lead to compromising the security of your store.

    It is advisable to install this update, because with

    – It will make your Magento store more secure.
    – It will keep your Magento store healthy
    – It will keep your Magento store safe.

    Don’t delay much and install Magento Open Source 2.4.0-2.4.3-p1 updates.

    Normally, installing such updates requires technical exercising.

    Thus, we suggest you to not execute this security updates until you are Magento tech expert.

    If you are not familiar with Magento technicalities, we suggest you to hire a Magento tech experts from Mage Monkeys who can do such task like a pro.

    How to add table via declarative schema in Magento 2?

    Magento 2.4 version have given feature to add table using declarative schema.

    Module name : Magemonkeys_Core

    We need to create db_schema.xml file in the app/code/Magemonkeys/Core/etc/  folder

    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
       <table name="customtable" resource="default" engine="innodb" comment="Custom table">
          <column xsi:type="smallint" name="id" unsigned="false" nullable="false" identity="true" comment="ID" />
          <column xsi:type="varchar" name="name" nullable="false" length="20" comment="Name" />
          <column xsi:type="varchar" name="email" nullable="false" length="20" comment="Email" />
          <constraint xsi:type="primary" referenceId="PRIMARY">
             <column name="id" />
          </constraint>
       </table>
    </schema>

    After that, we need to generate db white list schema json

    For that, we need to run command as per below

    php bin/magento setup:db-declaration:generate-whitelist --module-name=Magemonkeys_Core

    After that we need to run setup:upgrade and cache:flush command

    That’s it.