magento2 – How to override a method in a vendor module?

Hi so i wrote this code to override a method in the woom cmstree module. But it seems like, something is wrong and i have used an entire day to figure it out, without any success.

My Vendor/MyModule/Block/Widget/Children.php


namespace VendorMyModuleBlockWidget;

class Children extends WoomCmsTreeBlockWidgetChildren


protected $belongsToMenu = "";

public function prepareLinks($treeChildren, $first = false)
    $html = '';

    some random code

    return $html;

My etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="WoomCmsTreeBlockWidgetChildren" type="VendorMyModuleBlockWidgetChildren" />

So this is how i did it. And i of course got the registration file and module.xml

But when i go to the page where this widget is used i get this error

(2021-03-04 20:56:22) main.CRITICAL: Error: Class 'VendorMymoduleBlockWidgetChildren' not found in /home/sonose2/public_html/generated/code/Vendor/Mymodule/Block/Widget/Children/Interceptor.php:7

I have been look at some examples but the are exact as mine and i have been trying alot of other stuff and now i ran out of ideas what to do.

magento2 – Adding Google Web Font to Transactional Email?

I’m attempting to add a Google Web Font (Montserrat: in the Marketing -> Email Templates area and attempted to add this in two ways.

I added the <link .. /> element in the <header> and also tried adding an @import rule in the box that allows you to add styles in the Email Template section of the admin panel.

Am I doing this wrong? The font is not showing on my sales emails. Thank you.

magento2 – Product are not displaying on Category page after Data Migration

For this you need to change into database set only is_filterable_in_search to 0

This is old code

FROM catalog_eav_attribute cea
JOIN eav_attribute ea
ON ea.attribute_id = cea.attribute_id 
AND backend_type IN ('text')
cea.is_filterable = 1 OR cea.is_filterable_in_search = 1

Replace with below one code with your prefix like.

UPDATE **prefix_**catalog_eav_attribute cea 
JOIN **prefix_**eav_attribute ea
ON ea.attribute_id = cea.attribute_id
AND backend_type in ('text')
cea.is_filterable = 0, cea.is_filterable_in_search = 0
cea.is_filterable = 1 OR cea.is_filterable_in_search = 1

Now after that just do reindex and cache

magento indexer:reindex
magento cache:clean
magento cache:flush

That’s it..

magento2 – Magento 2 : setItem() on bool error

file frontend/templates/email/items/shipment/default.phtml

/** @var $_item MagentoSalesModelOrderItem */
$_item         = $block->getItem();
$_order        = $_item->getOrder();
$helper        = $this->helper('ModSalesHelperData');
$product_image = $helper->getProductImage($_item->getSku());
$productObj    = $helper->getProductBySku($_item->getSku());
$color         = $productObj->getAttributeText('color');
$size          = $productObj->getAttributeText('size');
$brand         = $productObj->getDisplayBrand();
    <!-- Price -->
    <div align="left" style="font-size:16px;">
        <?php echo $block->getItemPrice($_item) ?>
    <!-- Spacer -->
        <td height="25">

Error: Call to a member function setItem() on bool in vendor/magento/module-sales/Block/Order/Email/Items/DefaultItems.php:118 Stack trace: #0

Any thoughts why it shows such error & how to fix it asap ?

magento2 – Assign images to products programmatically

I want to assign images to products in my store
the imagesname same sku product name.
I put my php file in root/pub and tried this code:


ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);


  • Assumes doc root is set to ROOT/pub
    require_once dirname(DIR) . ‘/app/bootstrap.php’;
    $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);

class AssignImages extends MagentoFrameworkAppHttp implements MagentoFrameworkAppInterface
public function launch()
$state = $this->_objectManager->get(‘MagentoFrameworkAppState’);

    $galleryReadHandler = $this->_objectManager->create('MagentoCatalogModelProductGalleryReadHandler');
    $imageProcessor = $this->_objectManager->create('MagentoCatalogModelProductGalleryProcessor');
    $productGallery = $this->_objectManager->create('MagentoCatalogModelResourceModelProductGallery');

     * Assumed images are named (sku).(ext) and reside in ROOT/pub/media/(image_dir)
    foreach (glob(__DIR__ . "/media/img/*.{jpg,png,gif}", GLOB_BRACE) as $image) {
        $imageFileName = trim(pathinfo($image)('filename'));
        $sku = $imageFileName;
        try {
            $product = $this->_objectManager->create('MagentoCatalogModelProduct')->loadByAttribute('sku', $sku);
            if ($product) {

                // Unset existing images
                $images = $product->getMediaGalleryImages();
                foreach($images as $child) {
                    $imageProcessor->removeImage($product, $child->getFile());

                 * Add image. Image directory must be in ROOT/pub/media for addImageToMediaGallery() method to work
                $product->addImageToMediaGallery('img' . DIRECTORY_SEPARATOR . pathinfo($image)('basename'), array('image', 'small_image', 'thumbnail'), false, false);
                echo "Added media image for {$sku}" . "n";
        } catch (Exception $e) {
            echo $e->getMessage();
    return $this->_response;

public function catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception)
    echo $exception->getMessage();
    return false;


/** @var MagentoFrameworkAppHttp $app */
$app = $bootstrap->createApplication(‘AssignImages’);

But display this error:

Fatal error: Declaration of AssignImages::catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception) must be compatible with MagentoFrameworkAppHttp::catchException(MagentoFrameworkAppBootstrap $bootstrap, Exception $exception): bool in /home/tabasheermedia/public_html/no-limits/pub/importimage.php on line 12

My Magento version 2.3.3

magento2 – M2.4.2 – XML the footer HTML markup not coming altogether any clue?

Developing a new frontend using BS5, the issue with the layout XML keeps breaking, the footer HTML markup not coming altogether any clue?

<?xml version="1.0"?>
<page xmlns:xsi="" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

        <!-- Header -->
        <referenceContainer name="header.container" htmlClass="header">
            <!-- Header Content -->
            <container name="header.content" htmlClass="content" htmlTag="div" />
        <!-- <referenceContainer name="header.content" htmlClass="content" /> -->

        <referenceBlock name="top.links">
                <argument name="css_class" xsi:type="string">top-links</argument>

        <referenceContainer name="">
            <block class="MagentoThemeBlockHtmlTopmenu" name="catalog.topnav" template="html/topmenu.phtml" ttl="3600" before="-"/>

        <!-- Main -->
        <referenceContainer name="main.content"/>

        <!-- Footer -->
        <referenceContainer name="footer.container" htmlClass="footer">
            <!-- Footer Content -->
            <container name="footer.content" htmlClass="content my-3" htmlTag="div">
                <container name="footer.row" htmlTag="div" htmlClass="row">
                    <container name="footer.newsletter" htmlTag="div" htmlClass="col-xs-12 col-md-6 col-lg-3 order-md-2" />
                    <container name="footer.navigation" htmlTag="div" htmlClass="col-xs-12 col-md-6 col-lg-9 order-md-1">
                        <block class="MagentoCmsBlockBlock">
                                <argument name="block_id" xsi:type="string">footer_navigation</argument>

        <!-- Removing Magento Native Blocks -->
        <referenceBlock name="my-account-link" remove="true"/>
        <referenceBlock name="register-link" remove="true"/>
        <referenceBlock name="currency" remove="true" />
        <referenceBlock name="navigation.sections" remove="true" />
        <referenceBlock name="footer_links" remove="true" />
        <referenceContainer name="header.panel.wrapper" remove="true" />

        <!-- Moving Elements to the new Containers -->
        <move element="logo" destination="header.content" before="-" />
        <move element="minicart" destination="header.content" after="logo" />
        <move element="" destination="header.content" after="minicart" />
        <move element="top.links" destination="header.content" after="-" />
        <!-- <move element="footer_links" destination="footer-links-container" /> -->
        <move element="form.subscribe" destination="footer.newsletter" />
        <!-- <move element="store_switcher" destination="footer-tools-container" /> -->
        <move element="copyright" destination="footer.content" after="-"/>
        <!-- <move element="report.bugs" destination="footer-legal-container" /> -->


magento2 – Error 404 on Magento 2.4.2 on Localhost

I have set up a localhost installation of Magento 2.4.2 community edition, now I am getting this error: 404 Not Found.

I’ve got elasticsearch installed, a mysql database created but I can’t even access the mainpage of magento 2.4.2.

I have magento set up on /var/www/html/magento/ and this is my /etc/apache2/apache2.conf configuration:

# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#   /etc/apache2/
#   |-- apache2.conf
#   |   `--  ports.conf
#   |-- mods-enabled
#   |   |-- *.load
#   |   `-- *.conf
#   |-- conf-enabled
#   |   `-- *.conf
#   `-- sites-enabled
#       `-- *.conf
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
# * ports.conf is always included from the main configuration file. It is
#   supposed to determine listening ports for incoming connections which can be
#   customized anytime.
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
#   directories contain particular configuration snippets which manage modules,
#   global configuration fragments, or virtual host configurations,
#   respectively.
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
#   their respective man pages for detailed information.
# * The binary is called apache2. Due to the use of environment variables, in
#   the default configuration, apache2 needs to be started/stopped with
#   /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
#   work with the default configuration.

# Global configuration

# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:>);
# you will save yourself a lot of trouble.
# Do NOT add a slash at the end of the directory path.
#ServerRoot "/etc/apache2"

# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#Mutex file:${APACHE_LOCK_DIR} default

# The directory where shm and other runtime files will be stored.

DefaultRuntimeDir ${APACHE_RUN_DIR}

# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars

# Timeout: The number of seconds before receives and sends time out.
Timeout 300

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
KeepAlive On

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
KeepAliveTimeout 5

# These need to be set in /etc/apache2/envvars

# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., (on) or (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
ErrorLog ${APACHE_LOG_DIR}/error.log

# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf

# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied

<Directory /usr/share>
    AllowOverride None
    Require all granted

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted

#<Directory /srv/>
#   Options Indexes FollowSymLinks
#   AllowOverride None
#   Require all granted

# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
AccessFileName .htaccess

# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
<FilesMatch "^.ht">
    Require all denied

# The following directives define some format nicknames for use with
# a CustomLog directive.
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
LogFormat "%v:%p %h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"" vhost_combined
LogFormat "%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%h %l %u %t "%r" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

To install I used composer and then I ran:

sudo bin/magento setup:install --base-url="" --db-host=localhost --db-name=magento2 --db-user=root --db-password=(password) --admin-firstname=Name --admin-lastname=Surname --admin-user=admin --admin-password=admin123 --language=en_US --currency=EUR --timezone=UTC --use-rewrites=1 --search-engine=elasticsearch7 --elasticsearch-host=localhost --elasticsearch-port=9200

This is my /etc/hosts/ config:   localhost   pcportatilrafael

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

These are my /var/www/html/magento contents:

total 1784
drwxrwxrwx  4 www-data www-data   4096 mar  3 22:30 app
-rwxrwxrwx  1 www-data www-data    150 mar  3 22:27 auth.json.sample
drwxrwxrwx  2 www-data www-data   4096 mar  3 22:27 bin
-rwxrwxrwx  1 www-data www-data 766543 mar  3 22:27
-rwxrwxrwx  1 www-data www-data   2634 jan  7 21:59 composer.json
-rwxrwxrwx  1 www-data www-data 952379 mar  3 22:27 composer.lock
-rwxrwxrwx  1 www-data www-data    650 mar  3 22:27 COPYING.txt
drwxrwxrwx  4 www-data www-data   4096 mar  3 22:27 dev
drwxrwxrwx  4 www-data www-data   4096 mar  3 23:19 generated
-rwxrwxrwx  1 www-data www-data     55 mar  3 22:27 grunt-config.json.sample
-rwxrwxrwx  1 www-data www-data   2994 mar  3 22:27 Gruntfile.js.sample
drwxrwxrwx  4 www-data www-data   4096 mar  3 22:27 lib
-rwxrwxrwx  1 www-data www-data  10376 mar  3 22:27 LICENSE_AFL.txt
-rwxrwxrwx  1 www-data www-data  10364 mar  3 22:27 LICENSE.txt
-rwxrwxrwx  1 www-data www-data   6898 mar  3 22:27 nginx.conf.sample
-rwxrwxrwx  1 www-data www-data   1275 mar  3 22:27 package.json.sample
drwxrwxrwx  2 www-data www-data   4096 mar  3 22:27 phpserver
drwxrwxrwx  6 www-data www-data   4096 mar  3 22:27 pub
-rwxrwxrwx  1 www-data www-data    700 mar  3 22:27
drwxrwxrwx  7 www-data www-data   4096 mar  3 22:27 setup
drwxrwxrwx  7 www-data www-data   4096 mar  3 23:19 var
drwxrwxrwx 84 www-data www-data   4096 mar  3 22:27 vendor

When I access I go to the localhost apache2 page, when I access localhost/magento I get the 404 error… GOing to localhost/phpmyadmin works just fine.

What am I missing here? What am I doing wrong?

magento2 – How to create an Observer for the OrderCommentSender class

I need to create an observer of the vendor/magento/module-sales/Model/Order/Email/Sender/OrderCommentSender.php class, at the send() method (83th line), so that I can append a customized comment in the comments section.

Line 83 starts at $this->eventManager->dispatch

public function send(Order $order, $notify = true, $comment = '') {


$transport = (
    'order' => $order,
    'comment' => $comment,
    'billing' => $order->getBillingAddress(),
    'store' => $order->getStore(),
    'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
    'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
    'order_data' => (
        'customer_name' => $order->getCustomerName(),
        'frontend_status_label' => $order->getFrontendStatusLabel()

$transportObject = new DataObject($transport);

 * Event argument `transport` is @deprecated. Use `transportObject` instead.
    ('sender' => $this, 'transport' => $transportObject->getData(), 'transportObject' => $transportObject)


return $this->checkAndSend($order, $notify); }

magento2 – Magento 2.4.2 composer install PHP extension errors

I am trying to set up a local Magento 2.4.2 instance just to experiment and develop some work, but I keep hitting a problem with PHP extensions when I run composer create-project --repository-url= magento/project-community-edition

Creating a "magento/project-community-edition" project at "./project-community-edition"
Installing magento/project-community-edition (2.4.2)
  - Installing magento/project-community-edition (2.4.2): Extracting archive
Created project in /home/rafael/Desktop/project-community-edition
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires magento/product-community-edition 2.4.2 -> satisfiable by magento/product-community-edition(2.4.2).
    - magento/product-community-edition 2.4.2 requires ext-curl * -> it is missing from your system. Install or enable PHP's curl extension.
  Problem 2
    - magento/magento2-functional-testing-framework(3.0.0, ..., 3.3.0) require ext-curl * -> it is missing from your system. Install or enable PHP's curl extension.
    - Root composer.json requires magento/magento2-functional-testing-framework ^3.0 -> satisfiable by magento/magento2-functional-testing-framework(3.0.0, ..., 3.3.0).

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.4/cli/php.ini
    - /etc/php/7.4/cli/conf.d/10-opcache.ini
    - /etc/php/7.4/cli/conf.d/10-pdo.ini
    - /etc/php/7.4/cli/conf.d/15-xml.ini
    - /etc/php/7.4/cli/conf.d/20-calendar.ini
    - /etc/php/7.4/cli/conf.d/20-ctype.ini
    - /etc/php/7.4/cli/conf.d/20-dom.ini
    - /etc/php/7.4/cli/conf.d/20-exif.ini
    - /etc/php/7.4/cli/conf.d/20-ffi.ini
    - /etc/php/7.4/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.4/cli/conf.d/20-ftp.ini
    - /etc/php/7.4/cli/conf.d/20-gettext.ini
    - /etc/php/7.4/cli/conf.d/20-iconv.ini
    - /etc/php/7.4/cli/conf.d/20-json.ini
    - /etc/php/7.4/cli/conf.d/20-mbstring.ini
    - /etc/php/7.4/cli/conf.d/20-phar.ini
    - /etc/php/7.4/cli/conf.d/20-posix.ini
    - /etc/php/7.4/cli/conf.d/20-readline.ini
    - /etc/php/7.4/cli/conf.d/20-shmop.ini
    - /etc/php/7.4/cli/conf.d/20-simplexml.ini
    - /etc/php/7.4/cli/conf.d/20-sockets.ini
    - /etc/php/7.4/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.4/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.4/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.4/cli/conf.d/20-tokenizer.ini
    - /etc/php/7.4/cli/conf.d/20-xmlreader.ini
    - /etc/php/7.4/cli/conf.d/20-xmlwriter.ini
    - /etc/php/7.4/cli/conf.d/20-xsl.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

I already tried to install the extensions with the following command:

sudo apt-get install php7.4-opcache php7.4-pdo php7.4-calendar php7.4-ctype php7.4-dom php7.4-exif php7.4-ffi php7.4-fileinfo php7.4-ftp php7.4-gettext php7.4-iconv php7.4-json php7.4-mbstring php7.4-phar php7.4-posix php7.4-readline php7.4-shmop php7.4-simplexml php7.4-sockets php7.4-sysvmsg php7.4-sysvsem php7.4-sysvshm php7.4-tokenizer php7.4-xmlreader php7.4-xmlwriter php7.4-xsl

PHP version:

PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

Mysql version:

mysql  Ver 8.0.23-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

Elasticsearch version:

  "name" : "magecomp4",
  "cluster_name" : "magento-local-app-dummy",
  "cluster_uuid" : "keE77f1bQyudHuyvNVFWYQ",
  "version" : {
    "number" : "7.11.1",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "ff17057114c2199c9c1bbecc727003a907c0db7a",
    "build_date" : "2021-02-15T13:44:09.394032Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  "tagline" : "You Know, for Search"

Can anyone please help me?

magento2 – Magento 2 Redirect and display error in all admin page after click on “sign in”

I am trying to login in admin but it display “There has been an error processing your request”.

It generate error in like “Undefined offset: 2 in C:xampphtdocsm24libinternalMagentoFrameworkEncryptionEncryptor.php on line 591”

Also try to create new user and login but that solution is not working in my case. Note that I am using magento 2.4. Thanks in advance.