magento2.4.1 – How to override core files into custom module app/code?

I am added a custom attribute in my wishlist knockout core file,

Code : https://codeshare.io/5ZlEv7 Line Number: 142

I want to override into my custom module,

I am created a custom module, how to properly included my changes

app/code/Vendor/Wishlist/etc/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="MagentoWishlistCustomerDataWishlist">
        <plugin disabled="false" name="Vendor_Wishlist_Plugin_Magento_Wishlist_CustomerData_Wishlist" sortOrder="10" type="VendorWishlistPluginMagentoWishlistCustomerDataWishlist"/>
    </type>
</config>

app/code/Vendor/Wishlist/Plugin/Magento/Wishlist/CustomerData/Wishlist.php

  <?php
/**
 * Copyright ©  All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace VendorWishlistPluginMagentoWishlistCustomerData;


class Wishlist
{

    protected $wishlistHelper;

    public function __construct(
        MagentoWishlistHelperData $wishlistHelper
    )
    {
        $this->wishlistHelper = $wishlistHelper;
    }


    public function afterGetSectionData(
        MagentoWishlistCustomerDataWishlist $subject,
        $result
    ) {

        // Your code here

        return $result;
    }
}

My question, how to include my changes into app/code/Vendor/Wishlist/Plugin/Magento/Wishlist/CustomerData/Wishlist.php

Should i add the whole function, code : https://codeshare.io/29AL38

or

should i add a specific line of change?

'product_brand' => $product->getResource()->getAttribute('brand')->getFrontend()->getValue($product),

New to module customization, anyone help thanks.

8 – How to override version of drupal-library (JavaScript library) included with composer merge-plugin?

I’m using Webform with the composer-merge plugin to bring in its libraries:

Relevant parts of my composer.json file:

    "extra": {
         "installer-paths": {
             "public_html/core": ("type:drupal-core"),
             "public_html/libraries/{$name}": ("type:drupal-library"),
             "public_html/modules/contrib/{$name}": ("type:drupal-module")
         },
         "merge-plugin": {
             "include": (
                 "public_html/modules/contrib/webform/composer.libraries.json"
             )
         }
     }

I can define my own version of the same library successfully, by using the same code as Webform’s composer.libraries.json does but changing the version— successful in that it is recognized:

    "repositories": {
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        "jquery.inputmask": {
            "type": "package",
            "package": {
                "name": "jquery/inputmask",
                "version": "5.0.6-beta.45",
                "type": "drupal-library",
                "extra": {
                    "installer-name": "jquery.inputmask"
                },
                "dist": {
                    "url": "https://github.com/RobinHerbots/jquery.inputmask/archive/5.0.5.zip",
                    "type": "zip"
                },
                "require": {
                    "composer/installers": "~1.0"
                }
            }
        }
    },

But unsuccessful in that it does not have priority over the one defined in webform:

  • Root composer.json requires jquery/inputmask 5.0.6-beta.45, it is satisfiable by jquery/inputmask(5.0.6-beta.45) from package repo (defining 1 package) but jquery/inputmask(5.0.5) from package repo (defining 1 package) has higher repository priority. The packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.

But i don’t know how to take priority.

magento2.3.3 – Magebto 2: Override shipment save controller magento 2 Error

I have to override the Admin shipment save controller. Overridden it in my custom module and it’s calling. But when I’m going to create the shipment I’m getting an error.

Fatal error: Uncaught Error: Call to a member function validate() on null

<preference for="MagentoShippingControllerAdminhtmlOrderShipmentSave" type="VendorModuleControllerAdminhtmlOrderShipmentSave" />

<?php
namespace VendorModuleControllerAdminhtmlOrderShipment;

use MagentoFrameworkAppActionHttpPostActionInterface;
use MagentoFrameworkControllerResultFactory;
use MagentoSalesModelOrderShipmentValidationQuantityValidator;

Class Save extends MagentoShippingControllerAdminhtmlOrderShipmentSave implements HttpPostActionInterface
{

/**
 * @var MagentoShippingControllerAdminhtmlOrderShipmentLoader
 */
protected $shipmentLoader;

/**
 * @var MagentoShippingModelShippingLabelGenerator
 */
protected $labelGenerator;

/**
 * @var MagentoSalesModelOrderEmailSenderShipmentSender
 */
protected $shipmentSender;

/**
 * @var MagentoSalesModelOrderShipmentShipmentValidatorInterface
 */
private $shipmentValidator;

/**
 * @var MagentoFrameworkAppResourceConnection
 */
protected $resourceConnection;

public function __construct(
    MagentoBackendAppActionContext $context,
    MagentoShippingControllerAdminhtmlOrderShipmentLoader $shipmentLoader,
    MagentoShippingModelShippingLabelGenerator $labelGenerator,
    MagentoSalesModelOrderEmailSenderShipmentSender $shipmentSender,
    MagentoSalesModelOrderShipmentShipmentValidatorInterface $shipmentValidator = null,
    MagentoFrameworkAppResourceConnection $resourceConnection
) {
    $this->resourceConnection = $resourceConnection;
    parent::__construct(
        $context,
        $shipmentLoader,
        $labelGenerator,
        $shipmentSender,
        $shipmentValidator ?: MagentoFrameworkAppObjectManager::getInstance()
        ->get(MagentoSalesModelOrderShipmentShipmentValidatorInterface::class)
    );
}

public function execute()
{
    /** @var MagentoBackendModelViewResultRedirect $resultRedirect */
    $resultRedirect = $this->resultRedirectFactory->create();

    $formKeyIsValid = $this->_formKeyValidator->validate($this->getRequest());
    $isPost = $this->getRequest()->isPost();
    if (!$formKeyIsValid || !$isPost) {
        $this->messageManager->addErrorMessage(__('We can't save the shipment right now.'));
        return $resultRedirect->setPath('sales/order/index');
    }

    $data = $this->getRequest()->getParam('shipment');

    $connection = $this->resourceConnection->getConnection();

    if (!empty($data('comment_text'))) {
        $this->_objectManager->get(MagentoBackendModelSession::class)->setCommentText($data('comment_text'));
    }

    $isNeedCreateLabel = isset($data('create_shipping_label')) && $data('create_shipping_label');
    $responseAjax = new MagentoFrameworkDataObject();

    try {
        $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
        $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
        $this->shipmentLoader->setShipment($data);
        $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
        $shipment = $this->shipmentLoader->load();
        if (!$shipment) {
            return $this->resultFactory->create(ResultFactory::TYPE_FORWARD)->forward('noroute');
        }

        if (!empty($data('comment_text'))) {
            $shipment->addComment(
                $data('comment_text'),
                isset($data('comment_customer_notify')),
                isset($data('is_visible_on_front'))
            );

            $shipment->setCustomerNote($data('comment_text'));
            $shipment->setCustomerNoteNotify(isset($data('comment_customer_notify')));
        }
        $validationResult = $this->shipmentValidator->validate($shipment, (QuantityValidator::class));

        if ($validationResult->hasMessages()) {
            $this->messageManager->addErrorMessage(
                __("Shipment Document Validation Error(s):n" . implode("n", $validationResult->getMessages()))
            );
            return $resultRedirect->setPath('*/*/new', ('order_id' => $this->getRequest()->getParam('order_id')));
        }
        $shipment->register();

        $shipment->getOrder()->setCustomerNoteNotify(!empty($data('send_email')));

        if ($isNeedCreateLabel) {
            $this->labelGenerator->create($shipment, $this->_request);
            $responseAjax->setOk(true);
        }

        $this->_saveShipment($shipment);

        if (!empty($data('send_email'))) {
            $this->shipmentSender->send($shipment);
        }

        $shipmentCreatedMessage = __('The shipment has been created.');
        $labelCreatedMessage = __('You created the shipping label.');

        $this->messageManager->addSuccessMessage(
            $isNeedCreateLabel ? $shipmentCreatedMessage . ' ' . $labelCreatedMessage : $shipmentCreatedMessage
        );
        $this->_objectManager->get(MagentoBackendModelSession::class)->getCommentText(true);
    } catch (MagentoFrameworkExceptionLocalizedException $e) {
        if ($isNeedCreateLabel) {
            $responseAjax->setError(true);
            $responseAjax->setMessage($e->getMessage());
        } else {
            $this->messageManager->addErrorMessage($e->getMessage());
            return $resultRedirect->setPath('*/*/new', ('order_id' => $this->getRequest()->getParam('order_id')));
        }
    } catch (Exception $e) {
        $this->_objectManager->get(PsrLogLoggerInterface::class)->critical($e);
        if ($isNeedCreateLabel) {
            $responseAjax->setError(true);
            $responseAjax->setMessage(__('An error occurred while creating shipping label.'));
        } else {
            $this->messageManager->addErrorMessage(__('Cannot save shipment.'));
            return $resultRedirect->setPath('*/*/new', ('order_id' => $this->getRequest()->getParam('order_id')));
        }
    }
    if ($isNeedCreateLabel) {
        return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setJsonData($responseAjax->toJson());
    }

    return $resultRedirect->setPath('sales/order/view', ('order_id' => $shipment->getOrderId()));
}

}

magento2 – How to override adminhtml html file

I need to overwrite the file vendor/magento/module-customer/view/adminhtml/web/template/default-address.html. I have tried creating a custom module and adding the file in app/code/myvendor/mymodule/view/adminhtml/web/template/default-address.html but it is not working.

I have also tried adding the file directly in app/design/adminhtml/Magento/Magento_Customer/web/template but it’s not working either.

How can I overwrite html files from magento admin? I’m working in Magento 2.3.5 p-1.

Thanks in advance

c# – Unity: XR Interaction Toolkit: Best way to override XRRayInteractor from an interactable GameObject

I’m very new to C# and Unity. I’m adding some custom interactions to XR Interaction Toolkit, I’m trying to make it so when a user “grabs” a certain GameObject they can resize it with the thumbstick on the controller. However on other GameObjects using the thumbstick will rotate and move the object which is the default behavior when Anchor Control is turned on.

enter image description here

My first thought is override the Anchor Control method which appears to be called ProcessInteractor. But this is inside the XRRayInteractor script. Whereas because this functionality is specific to certain GameObjects I feel like I should be writing this code as part of XRGrabInteractable and placing it on the GameObject that’s interactable.

Am I correct in thinking this? And if so what’s the correct way to implement this, is it possible to override ProcessInteractor in XRRayInteractor from the GameObject that has the XRGrabInteractable on it without ending up with the entire XRRayInteractor attached to the GameObject? Can’t quite get my head around the best way to do this.

development – Using AweCsome Framework to override sharepoint user fields (Author)?

I need to create/update one item in SharePoint using AweCsome Framework (https://github.com/OleAlbers/aweCsome) changing author field.

How can I do this?

When I try to accomplish i define the entity field like this (ex AnyEntityBO):

public String Author { get; set; }

i got the item, modified author field and save:

IAweCsomeTable awecsomeTable = new AweCsomeTable(context);
AnyEntityBO anyEntity= awecsomeTable.SelectItemById<AnyEntityBO>(1);
anyEntity.Author = "xxx@xxx.onmicrosoft.com";
awecsomeTable.UpdateItem<AnyEntityBO>(anyEntity);

When I saved the item I got the error:

Invalid data has been used to update the list item. The field you are trying to update may be read only

Help please!

magento2 – I need to override the search term

I need override vendormagentomodule-catalog-searchModelLayerSearchPluginCollectionFilter.php File,
i need get the search term and replace “-” and “.” for nothing. Which a best method for make this?
I know how to override view files in my design theme but i don’t know how to override Model files.

Example:

<?php
/**
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace MagentoCatalogSearchModelLayerSearchPlugin;

use MagentoCatalogModelCategory;
use MagentoSearchModelQueryFactory;

/**
 * Catalog search plugin for search collection filter in layered navigation.
 */
class CollectionFilter
{
    /**
     * @var MagentoSearchModelQueryFactory
     */
    protected $queryFactory;

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

    /**
     * Add search filter criteria to search collection
     *
     * @param MagentoCatalogModelLayerSearchCollectionFilter $subject
     * @param null $result
     * @param MagentoCatalogSearchModelResourceModelFulltextCollection $collection
     * @param Category $category
     * @return void
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function afterFilter(
        MagentoCatalogModelLayerSearchCollectionFilter $subject,
        $result,
        $collection,
        Category $category
    ) {
        /** @var MagentoSearchModelQuery $query */
        $query = $this->queryFactory->get();
        if (!$query->isQueryTextShort()) {
            $text = $query->getQueryText();
            $text = str_replace(array("-","."),"",$text);
            $collection->addSearchFilter($text);
        }
    }
}

magento2 – Create a new admin theme and make an override of sales module template

I tried to create an admin theme and make an override to sales module template file but this don’t work, i followed those tutorials : create admin theme and Apply custom admin theme

in app/design/adminhtml/Vendor/customtheme, i created registration.php

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
use MagentoFrameworkComponentComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::THEME, 'adminhtml/Vendor/customtheme', __DIR__);

in app/design/adminhtml/Vendor/customtheme/theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
     <title>Custom Theme</title> <!-- your theme's name -->
     <parent>Magento/backend</parent> <!-- the parent theme. Example: Magento/backend -->
</theme>

In app/design/adminhtml/Vendor/customtheme/Module_Sales/templates/order/view/info.phtml i tried to add ‘ddddd’ in table header for customer acount data

  <?php foreach ($block->getCustomerAccountData() as $data):?>
                    <tr>
                        <th><?= $block->escapeHtml($data('label')) ?> ddddd</th>
                        <td><?= $block->escapeHtml($data('value'), ('br')) ?></td>
                    </tr>
                <?php endforeach;?>
                <?= $block->getChildHtml('extra_customer_info') ?>

After that i tried to create a module to apply the new theme admin

in app/code/Vendor/ThemeAdmin/registration.php

<?php

MagentoFrameworkComponentComponentRegistrar::register(
    MagentoFrameworkComponentComponentRegistrar::MODULE,
    'Wetag_ThemeAdmin',
    __DIR__
);

in Vendor/ThemeAdmin/composer.json

{
"name": "vendor/themeadmin",
"description": "new theme admin",
"require": {
    "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0"
},
"type": "magento2-module",
"license": (
    "OSL-3.0",
    "AFL-3.0"
),
"autoload": {
    "files": ( "registration.php" ),
    "psr-4": {
        "Vendor\ThemeAdmin\": ""
    }        
}
}

In Vendor/ThemeAdmin/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="Vendor_ThemeAdmin" setup_version="1.0.0">
        <sequence>>
            <module name="Magento_Theme"/>
        </sequence>
    </module>
</config>

In Wetag/ThemeAdmin/etc/adminhtml/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">

<!-- Admin theme. Start -->
<type name="MagentoThemeModelViewDesign">
    <arguments>
        <argument name="themes" xsi:type="array">
            <item name="adminhtml" xsi:type="string">Vendor/customtheme</item>
        </argument>
    </arguments>
</type>
<!-- Admin theme. End -->
</config>

magento2 – Create a new admin theme and make an override de modules sales

I tried to create an admin theme and make an override to sales module template file but this don’t work, i followed those tutorials : create admin theme and Apply custom admin theme

in app/design/adminhtml/Vendor/customtheme, i created registration.php

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
use MagentoFrameworkComponentComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::THEME, 'adminhtml/Vendor/customtheme', __DIR__);

in app/design/adminhtml/Vendor/customtheme/theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
     <title>Custom Theme</title> <!-- your theme's name -->
     <parent>Magento/backend</parent> <!-- the parent theme. Example: Magento/backend -->
</theme>

In app/design/adminhtml/Vendor/customtheme/Module_Sales/templates/order/view/info.phtml i tried to add ‘ddddd’ in table header for customer acount data

  <?php foreach ($block->getCustomerAccountData() as $data):?>
                    <tr>
                        <th><?= $block->escapeHtml($data('label')) ?> ddddd</th>
                        <td><?= $block->escapeHtml($data('value'), ('br')) ?></td>
                    </tr>
                <?php endforeach;?>
                <?= $block->getChildHtml('extra_customer_info') ?>

After that i tried to create a module to apply the new theme admin

in app/code/Vendor/ThemeAdmin/registration.php

<?php

MagentoFrameworkComponentComponentRegistrar::register(
    MagentoFrameworkComponentComponentRegistrar::MODULE,
    'Wetag_ThemeAdmin',
    __DIR__
);

in Vendor/ThemeAdmin/composer.json

{
"name": "vendor/themeadmin",
"description": "new theme admin",
"require": {
    "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0"
},
"type": "magento2-module",
"license": (
    "OSL-3.0",
    "AFL-3.0"
),
"autoload": {
    "files": ( "registration.php" ),
    "psr-4": {
        "Vendor\ThemeAdmin\": ""
    }        
}
}

In Vendor/ThemeAdmin/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="Vendor_ThemeAdmin" setup_version="1.0.0">
        <sequence>>
            <module name="Magento_Theme"/>
        </sequence>
    </module>
</config>

In Wetag/ThemeAdmin/etc/adminhtml/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">

<!-- Admin theme. Start -->
<type name="MagentoThemeModelViewDesign">
    <arguments>
        <argument name="themes" xsi:type="array">
            <item name="adminhtml" xsi:type="string">Vendor/customtheme</item>
        </argument>
    </arguments>
</type>
<!-- Admin theme. End -->
</config>