magento2.3 – Override custom extension adminhtml template in my module

I want to over ride following tramplete:

app/code/Mageplaza/EditOrder/view/adminhtml/templates/order/edit/shipping/method/list.phtml

Declared in :

app/code/Mageplaza/EditOrder/view/adminhtml/layout/mpeditorder_quick_edit.xml

with following:

<container name="content">
    <block class="MageplazaEditOrderBlockAdminhtmlOrderEditQuickEdit" name="mpeditorder.quick.edit" template="Mageplaza_EditOrder::order/edit/quick/form.phtml">
        <block class="MageplazaEditOrderBlockAdminhtmlOrderEditShippingMethod" name="mpeditorder.shipping.method" template="Mageplaza_EditOrder::order/edit/shipping/method/list.phtml" />
    </block>
</container>

I create my custom module depend on this extension having.
app/code/Evx/EditOrder/view/adminhtml/layout/mpeditorder_quick_edit.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>
        <referenceBlock name="mpeditorder.shipping.method">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Evx_EditOrder::order/edit/shipping/method/list.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

and copy template into :

app/code/Evx/EditOrder/view/adminhtml/templates/order/edit/shipping/method/list.phtml

Template not overriding.

magento2 – Magento 2 Custom adminhtml validation rules doesn’t work

Custom adminhtml validation rules from Magento 2 docs on purely installed Magento 2.4.3 and Magento 2.4.2 doesn’t work.

Vendor/Module/view/frontend/requirejs-config.js

var config = {
  config: {
    mixins: {
      'mage/validation': {
        'Vendor_Module/js/validation-mixin': true
      }
    }
  }
}

Vendor/Module/view/frontend/web/js/validation-mixin.js

define(('jquery'), function($) {
  'use strict';

  return function() {
    $.validator.addMethod(
      'validate-five-words',
      function(value, element) {
        return value.split(' ').length == 5;
      },
      $.mage.__('Please enter exactly five words')
    )
  }
});

Vendor/Module/etc/adminhtml/system.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <tab id="vendor" class="vendor-tab" translate="label">
            <label>Vendor</label>
        </tab>

        <section id="vendor" translate="label" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Label</label>
            <tab>Vendor</tab>
            <resource>Vendor_Module::config</resource>

            <group id="module" showInDefault="1" showInWebsite="1" showInStore="1" translate="label">
                <label>Module</label>

                <field id="field" showInDefault="1" showInWebsite="1" showInStore="1" translate="label" canRestore="1" type="text">
                    <label>Field</label>
                    <validate>validation-mixin</validate>
                </field>
            </group>
        </section>
    </system>
</config>

Vendor/Module/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <vendor>
            <module>
                <field>1 2 3 4 5</field>
            </module>
        </vendor>
    </default>
</config>

When saving, nothing happens to me.

When adding standard Magento rules <validate>validate-number</validate>, they work.

What am I doing wrong? or maybe something is missing?

How to see new eav attribute label in adminhtml withour clear cache?

I am trying to save value into table ‘eav_attribute_label’

My code

INSERT INTO `eav_attribute_label`(`attribute_label_id`, `attribute_id`, `store_id`, `value`) VALUES (0,257,3,'test')

And I can see my value in table after that query – https://prnt.sc/1qh6ifr

But in admin grid I don’t see new value – https://prnt.sc/1qh6l2p
Only after command mage c:f I will see my value, but how can I disable this?

I really want to see my value without clearing cach. Is it possible?

magento2 – “validate-number-range” validation not working in Adminhtml form created using Ui Component

I am trying to implement the validate-number-range but it is not working.

Please find the implementation below

    <field name="custom_sequence" sortOrder="40" formElement="input">
            <settings>
                <required>true</required>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                    <rule name="validate-number" xsi:type="boolean">true</rule>
                    <rule name="validate-number-range" xsi:type="boolean">true</rule>
                    <rule name="number-range-1-50" xsi:type="boolean">true</rule>
                </validation>
                <dataType>number</dataType>
                <label translate="true">Custom Sequence</label>
                <dataScope>custom_sequence</dataScope>
                <componentType>field</componentType>
            </settings>
        </field>

adminhtml – Why does my admin customer edit form not seem to honor sort_order?

I’ve got about 100 attributes that I need to display on the customer admin form, and I went thru and set the sort order on nearly all of them, but they don’t seem to actually completely honor the sort_order database field.

For instance my first 3 attributes are “email”, “group_id”, and “account_name” (a custom attribute)

Listing of attributes

Their sort orders are 0, 5, and 19 respectively, but they show up “email” THEN “account_name” THEN “group_id”

Example of customer form

I tried trudging thru all of the code and even was looking at the MySQL queries being generated and I can find no where in the code to trace or debug to find how it’s being rendered. Any pointers would be fantastic

adminhtml – Admin redirect loop after 2.4 upgrade

we are working on updating 2.3.5 to 2.4.2-p1
Frontend loads ok, but admin backend creates a redirect loop admin/admin/auth/login/key/…. to admin/admin/index/index/key/… and admin/admin/auth/login/key/ again.
DB and config are roughly the same as on 2.3.
When requesting with a valid login cookie created by mage 2.3, I can enter admin backend ok, so this looks like general deployment is ok.
I’m a bit lost understanding what the system is supposed to do. I diffed the module-backend with no obvious change in that area.
As far as I can see on 2.3, there is some magic that actually lets vendor/magento/module-backend/Controller/Adminhtml/Auth/Login.php render the content when index/index is requested and no user is logged in. We seem to get a redirect to auth/login instead, which then fails due to Login.php:54-56, which detects the wrong URL and sends the user back to index/index.

nginx,config.php, php, varnish unchanged from mage 2.3

Any help or hint where to look highly appreciated.

regards
Alex

magento2.3 – Magento 2 adminhtml form add text field through function _prepareForm and how to enable pagebuilder component(without UI component)

In Magento2 Enterprise Edition, in normal text field configuration, when configuring a form via XML, you just need to add “IS_PageBuilder_Enabled” to true in the parameter, and the PageBuilder will be launched when the form is rendered in the background, as follows:

<field name="content" formElement="wysiwyg" template="ui/form/field">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="source" xsi:type="string">page</item>
                <item name="wysiwygConfigData" xsi:type="array">
                    <item name="is_pagebuilder_enabled" xsi:type="boolean">false</item>
                    <item name="toggle_button" xsi:type="boolean">true</item>
                    <item name="height" xsi:type="string">200px</item>
                    <item name="add_variables" xsi:type="boolean">true</item>
                    <item name="add_widgets" xsi:type="boolean">true</item>
                    <item name="add_images" xsi:type="boolean">true</item>
                    <item name="add_directives" xsi:type="boolean">true</item>
                </item>
            </item>
        </argument>
    </field>

The above code can render the PageBuilder Component successfully, but when we render the form in the Block using normal PHP code instead of the UI Component, we find the parameters: IS_PageBuilder_Enabled does not render PageBuilder component successfully. The code is as follows.

$fieldset->addField('post_content', 'editor', (
        'name' => 'post_content',
        'label' => __('Content'),
        'title' => __('Content'),
        'config' => $this->wysiwygConfig->getConfig((
            'toggle_button' => true,
            'is_pagebuilder_enabled' => true,
            'height' => '200px',
            'add_variables' => false,
            'add_widgets' => true,
            'add_directives' => true
        ))
    ));

So my problem is how to render the PageBuilder component using PHP without using the XML configuration of the UI Component;

thx.

magento2 – Add a dynamic note for a product attribute in the adminhtml

I’m trying to add a dynamic not based on the attribute-set besides the price field in Magento 2.

After a lot of research, I’ve tried using PHP modifiers in UI components, and depending on the Container component without any fields I was able to produce the following code:

Vendor/Module/etc/adminhtml/di.xml file content

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool" type="MagentoUiDataProviderModifierPool">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="vendor_module_example_modifier" xsi:type="array">
                    <item name="class" xsi:type="string">VendorModuleUiDataProviderProductFormModifierExampleModifier</item>
                    <item name="sortOrder" xsi:type="number">200</item>
                </item>
            </argument>
        </arguments>
    </virtualType>
</config>

VendorModuleUiDataProviderProductFormModifierExampleModifier

<?php

namespace VendorModuleUiDataProviderProductFormModifier;


use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
use MagentoFrameworkStdlibArrayManager;

class ExampleModifier extends AbstractModifier
{
    private ArrayManager $arrayManager;

    /**
     * @param ArrayManager $arrayManager
     */
    public function __construct(
        ArrayManager $arrayManager
    ) {
        $this->arrayManager = $arrayManager;
    }

    public function modifyData(array $data)
    {
        return $data;
    }

    public function modifyMeta(array $meta)
    {
        $containerPath = $this->arrayManager->findPath(static::CONTAINER_PREFIX . MagentoCatalogApiDataProductAttributeInterface::CODE_PRICE, $meta, null, 'children');

        $meta = $this->arrayManager->merge($containerPath, $meta, (
            'children' => (
                'example_field' => (
                    'arguments' => (
                        'data' => (
                            'config' => (
                                'componentType' => 'container',
                                'label' => false,
                                'text' => __('<p>this is something to show</p>'),
                                'template' => 'ui/form/components/complex',
                            )
                        )
                    )
                )
            )
        ));

        return $meta;
    }
}

But I got the following error in the console, and it’s not showing the text.

Uncaught ReferenceError: Unable to process binding “foreach: function(){return elems }”
Message: Unable to process binding “if: function(){return !$data.additionalForGroup }”
Message: Unable to process binding “if: function(){return visible() }”
Message: visible is not defined
at if (eval at createBindingsStringEvaluator (knockout.js:2982), :3:55)
at ko.computed.disposeWhenNodeIsRemoved (knockout.js:4381)
at Function.evaluateImmediate_CallReadThenEndDependencyDetection (knockout.js:2173)
at Function.evaluateImmediate_CallReadWithDependencyDetection (knockout.js:2140)
at Function.evaluateImmediate (knockout.js:2101)
at Object.ko.computed.ko.dependentObservable (knockout.js:1954)
at init (knockout.js:4380)
at knockout.js:3358
at Object.ignore (knockout.js:1470)
at knockout.js:3357

I’ve searched about the error and found nothing to help me, I’ve tried the base example for the modifier using the select box and it works fine, now I’m really stuck with this error, and all changes not fixing the issue.

I really appreciate your help so much.

adminhtml – Message inbox missing – No notifications

The message inbox is missing in two of our shops. We can not see messages and do not have the notification bell on the top right (see screenshot).
There are entries in the admin_system_messages table and when adding new messages programmatically it just writes a database entry, but shows no notifications and the bell is still missing.

enter image description here

admin – Magento 2.4.2 Adminhtml grid error

So I have a custom table and I want to create a grid in admin html to display all the records from my custom table.
I created new page using page factory.
I created listing.xml and di.xml as well but I am facing this error.
spinner keeps rotating and after that nothing happens.
enter image description here

enter image description here

Here is my code.
/app/code/VoltLighting/FriendsAndFamily/view/adminhtml/layout/rewards_friendsandfamily_index.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">
    <update handle="styles"/>
    <update handle="editor"/>
    <body>
        <referenceContainer name="content">
            <uiComponent name="rewards_listing"/>
        </referenceContainer>
    </body>
</page>


/app/code/VoltLighting/FriendsAndFamily/view/adminhtml/ui_component/rewards_listing.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">rewards_listing.rewards_listing_data_source</item>
        </item>
    </argument>
    <settings >
        <buttons>
            <button name="add">
                <url path="*/*/new"/>
                <class>primary</class>
                <label translate="true">Add New Member</label>
            </button>
        </buttons>
      <spinner>rewards_columns</spinner>
        <deps>
            <dep>rewards_listing.rewards_listing_data_source</dep>
        </deps>
    </settings>
    <dataSource name="rewards_listing_data_source" component="Magento_Ui/js/grid/provider">
        <settings>
            <storageConfig>
                <param name="indexField" xsi:type="string">entity_id</param>
            </storageConfig>
            <updateUrl path="rewards/friendsandfamily/index"/>
        </settings>
        <aclResource>VoltLighting_FriendsAndFamily::resource</aclResource>
        <dataProvider class="MagentoFrameworkViewElementUiComponentDataProviderDataProvider" name="rewards_listing_data_source">
            <settings>
                <requestFieldName>id</requestFieldName>
                <primaryFieldName>entity_id</primaryFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <columns name="rewards_columns">
        <settings>
            <editorConfig>
                <param name="clientConfig" xsi:type="array">
                    <item name="saveUrl" xsi:type="url" path="cms/block/inlineEdit"/>
                    <item name="validateBeforeSave" xsi:type="boolean">false</item>
                </param>
                <param name="indexField" xsi:type="string">entity_id</param>
                <param name="enabled" xsi:type="boolean">true</param>
                <param name="selectProvider" xsi:type="string">rewards_listing.rewards_listing.rewards_columns.ids</param>
            </editorConfig>
            <childDefaults>
                <param name="fieldAction" xsi:type="array">
                    <item name="provider" xsi:type="string">rewards_listing.rewards_listing.rewards_columns_editor</item>
                    <item name="target" xsi:type="string">startEdit</item>
                    <item name="params" xsi:type="array">
                        <item name="0" xsi:type="string">${ $.$data.rowIndex }</item>
                        <item name="1" xsi:type="boolean">true</item>
                    </item>
                </param>
            </childDefaults>
        </settings>
        <selectionsColumn name="ids">
            <settings>
                <indexField>entity_id</indexField>
            </settings>
        </selectionsColumn>
        <column name="entity_id">
            <settings>
                <filter>textRange</filter>
                <label translate="true">ID</label>
                <sorting>asc</sorting>
            </settings>
        </column>
        <column name="purchase_date">
            <settings>
                <filter>textRange</filter>
                <label translate="true">Purchase Date</label>
                <sorting>asc</sorting>
            </settings>
        </column>
        <column name="amount">
            <settings>
                <filter>textRange</filter>
                <label translate="true">Amount</label>
                <sorting>asc</sorting>
            </settings>
        </column>
        <column name="customer_id">
            <settings>
                <filter>textRange</filter>
                <label translate="true">Customer ID</label>
                <sorting>asc</sorting>
            </settings>
        </column>
        <column name="customer_email">
            <settings>
                <filter>textRange</filter>
                <label translate="true">Customer Email</label>
                <sorting>asc</sorting>
            </settings>
        </column>

        <column name="referrer_email">
            <settings>
                <filter>textRange</filter>
                <label translate="true">Referrer Email</label>
                <sorting>asc</sorting>
            </settings>
        </column>
        <column name="order_number">
            <settings>
                <filter>textRange</filter>
                <label translate="true">Order Number</label>
                <sorting>asc</sorting>
            </settings>
        </column>
        <column name="check_date">
            <settings>
                <filter>textRange</filter>
                <label translate="true">Check Date</label>
                <sorting>asc</sorting>
            </settings>
        </column>




    </columns>

</listing>

/app/code/VoltLighting/FriendsAndFamily/etc/di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="rewards_listing_data_source" xsi:type="string">VoltLightingFriendsAndFamilyModelResourceModelCustomerDataGridCollection</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="VoltLightingFriendsAndFamilyModelResourceModelCustomerDataGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider">
        <arguments>
            <argument name="mainTable" xsi:type="string">friends_and_family_rewards</argument>
            <argument name="resourceModel" xsi:type="string">VoltLightingFriendsAndFamilyModelResourceModelCustomerData</argument>
        </arguments>
    </virtualType>
</config>

/app/code/VoltLighting/FriendsAndFamily/Setup/InstallSchema.php

<?php


namespace VoltLightingFriendsAndFamilySetup;

use MagentoFrameworkDBDdlTable;
use MagentoFrameworkSetupInstallSchemaInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupSchemaSetupInterface;

class InstallSchema implements InstallSchemaInterface
{
    /**
     * {@inheritdoc}
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     */
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;
        $installer->startSetup();

        /**
         * Creating table trellis_customer
         */
        $table = $installer->getConnection()->newTable(
            $installer->getTable('friends_and_family_rewards')
        )->addColumn(
            'entity_id',
            Table::TYPE_INTEGER,
            null,
            ('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true),
            'Entity Id'
        )->addColumn(
            'purchase_date',
            Table::TYPE_DATETIME,
            1,
            ('nullable' => false,'default' => 0),
            'Purchase Date'
        )->addColumn(
            'amount',
            Table::TYPE_INTEGER,
            null,
            ('nullable' => true, 'unsigned' => true, 'default' => null),
            'Amount'
        )->addColumn(
            'customer_id',
            Table::TYPE_INTEGER,
            null,
            ('nullable' => true, 'unsigned' => true, 'default' => null),
            'Customer ID'
        )->addColumn(
            'customer_email',
            Table::TYPE_TEXT,
            null,
            ('nullable' => true,'default' => null),
            'Customer Email'
        )->addColumn(
            'referrer_email',
            Table::TYPE_TEXT,
            null,
            ('nullable' => true,'default' => null),
            'Referrer Email'
        )->addColumn(
            'order_number',
            Table::TYPE_TEXT,
            null,
            ('nullable' => true,'default' => null),
            'Order Number'
        )->addColumn(
            'check_date',
            Table::TYPE_DATETIME,
            1,
            ('nullable' => false,'default' => 0),
            'Check Date'
        )->setComment(
            'Friends And Family Table'
        );
        $installer->getConnection()->createTable($table);
        $installer->endSetup();
    }
}

I feel the issue is in my listing.xml with the datasource but I am unable to understand where I am going wrong. If anyone can help I will really appreciate it.