New answers tagged

0

You can just hide the price for that product and add a custom block to the price section. This will fulfill your problem.


1

Try before plugin with below code <?php declare(strict_types=1); namespace Vendor\MyModule\Plugin\Frontend\Magento\Contact\Controller\Index; class Post { public function beforeExecute( \Magento\Contact\Controller\Index\Post $subject ) { $comment = $subject->getRequest()->getParam('comment', false); $subject->...


1

use before plugin instead of after plugin. public function beforeExecute(\Magento\Contact\Controller\Index\Post $subject) { $comment = $subject->getRequest()->getParam('comment', false); $subject->getRequest()->setParam('comment', 'testing: '.$comment); } try this.


1

Get your attribute like this. No need to load repository, you already have the product model with $productInfo public function beforeAddProduct($subject, $productInfo, $requestInfo = null) { try { $attr = $productInfo->getResource()->getAttribute('my_tshirt'); $myTshirt = (string)$attr->getFrontend()->getValue($productInfo); ...


-1

1)Create di.xml in app/code/[Vendor]/[Module]/etc and add the following code: <?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="Magento\Checkout\Model\Cart"> &...


0

I can't say what exactly causes this, but using @magentoAppIsolation enabled works around the problem.


1

You can use below code. <?php namespace MyVendor\MyModule\Plugin; class Streichpreis { public function __construct( \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency) { $this->priceCurrency = $priceCurrency; } public function afterGetProductPriceHtml( \Magento\Catalog\Block\Product\AbstractProduct $...


1

You can use constructor like this: <?php namespace MyVendor\MyModule\Plugin; class Streichpreis { public function __construct( \Magento\Backend\Block\Template\Context $context, array $data = [] ) { parent::__construct( $context, $data ); } public function afterGetProductPriceHtml( \Magento\Catalog\Block\...


0

Please try with the below code. <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Quote\Model\Cart\Data; class CartItem extends \Magento\Quote\Model\Cart\Data\CartItem { /** * @var string */ private $sku; /** * @var float */ private $...


1

you can try plugin for the Magento\Catalog\Block\Product\AbstractProduct class. All other class like Crosssell Upsell NewWidget are extending this class and AbstractProduct class has getProductPrice() as public function so you can make plugin. UPDATE In widget phtml file getProductPriceHtml() used so you have to make plugin for the getProductPriceHtml()


1

Interceptor classes are used in the implementation of the plugin mechanism in Magento 2. These classes are automatically generated when you run bin/magento setup:di:compile and you will find them in the 'generated' folder of your Magento installation. In your particular case, this means you will find your physical file as <magento_root_folder>/...


1

You're "plugging in" to the toHtml method called inside the \Magento\Payment\Block\Info, this generates an interceptor class which intercepts all calls that can be intercepted and searches any associated plugins for methods defined with the before, after, or around pattern. So when the \Magento\Payment\Block\Info block calls toHtml (which is most ...


1

toHtml function defined in "Magento/Framework/View/Element/Template.php" file in which "Magento/Payment/Block/Info.php" file extends. Check below screenshot:


0

I think this should work, but you added the same plugin name on both instances plugin name="order_repository" and according to the doc, we have: <plugin name="{pluginName}" type="{PluginClassName}" sortOrder="1" disabled="false" /> -> plugin name - an arbitrary plugin name that identifies a plugin. ...


0

If you want to change the 'create account' label with XML the code you have to paste Go to app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml and place below code <referenceBlock name="register-link"> <arguments> <argument name="label" xsi:type="string" translate="true">...


Top 50 recent answers are included