New answers tagged

1

As per your screenshot, you can add your custom class in the footer block by copying /vendor/magento/module-theme/view/frontend/templates/html/footer.phtml file in your theme with below content. <div class="footer-container"> <div class="footer"> <?= $block->getChildHtml() ?> <p class="bugs"><?= /* @...


-1

You can add a custom class using xml by- Adding a class to block Magento 2 To add class using js, Try this code in your js file require(['jquery', 'jquery/ui'],function($){ jQuery('your_div_class').addClass('custom_class'); });


0

You Want to display the block message on the controller so Follow Below Steps. 1) Create Controller namespace Namespace\Testing\Controller\Payment; class Failure extends \Magento\Framework\App\Action\Action { protected $_pageFactory; public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\View\...


0

You have used the wrong function getBlock. GetBlock is called a block if it exists. I guess that you want to create a block and return it content then use below code. $layout = $this->_view->getLayout(); $layout->createBlock({YourBlockClass},'mycustom.block') ; $response = $layout->getBlock('mycustom.block')->toHtml(); $this-&...


0

Try This $block = $resultPage->getLayout()->getBlock('Namespace\Tesing\Block\Failure'); echo $block->_toHtml(); I suggest you should use layout (.xml) file to achieve this. That is the right way to do.


0

public function test(){ $ruleArray = $this->adventCollectionFactory->create()->getData(); $ruleArray = array_column($ruleArray,'promo_rule_id'); $array= implode($ruleArray); print_r($array); } I get 1 and 2 - which is correct


0

You have typo I guess, $customer remove $ symbol. <?php namespace WorldSynergy\LoginPortal\Block; use Magento\Customer\Model\Url; use Magento\Framework\App\Http\Context; use Magento\Framework\View\Element\Template; use Magento\Sales\Model\ResourceModel\Order\Customer\Collection; { class Portal extends Template { protected $_customerUrl; ...


0

Replace isLoggedIn() Funtion With This And Try public function isLoggedIn() { if ($this->$_customer->create()->addAttributeToSelect('is_allowed',array('eq'=>1))) { return $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH); } }


0

I could solve the issue editing the layout XML file: /app/design/frontend/Mgs/claue/Magento_Customer/layout/customer_account_login.xml <?xml version="1.0"?> <!-- /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" ...


2

Supravat. I guess that you want to get Content from www.example.com/sales/order/view/order_id/{OrderId}/ when clicking into <h4> In that, I suggest is that implement ajaxContent of Collapsible widget that call www.example.com/sales/order/view/order_id/{OrderId}/ and get content of HTML out of Block sales.order.view. <block class="Magento\Sales\...


1

As always, it depends ;) I‘ve used the approach you describe, but I prefer to use method arguments instead, e.g. $viewModel->getSomeFoo($block->getProduct()); This decouples the view model from the block. However, if there are many public methods on the view model and many values from the block are required the setting the block on the view model ...


3

If you want to some specific product to a cms page. Then go to admin>Content>CMS page,Select your cms page,then open that cms page. Then go to the Content tab, click open widget icon. Please follow my step and check, please. I hope it will help you.


0

Try Below Code:- $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); $productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory'); $collection = $productCollection->create() ->...


0

Please check with the following code $productId = "10"; //Product Id $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('Magento\Catalog\Model\Product')->load($productId); echo $product->getName(); //Get Product Name I hope it will help you.


0

<?php $objectManager = Magento\Framework\App\ObjectManager::getInstance(); $products = $objectManager->get('Magento\Catalog\Model\Product') ->getCollection() ->addAttributeToFilter('entity_id',array('product_id1','product_id2')); echo "<pre>"; print_r($products->getData()); ?>


0

please try with below code : ( you are using M1 code ) $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('Magento\Catalog\Model\Product')->load($productId);


0

Try This :- <?php namespace YourCompanyName\YourModuleName\Block; class YourCustomBlock extends \Magento\Framework\View\Element\Template { protected $_customerSession; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Model\SessionFactory $customerSession, array $...


1

Replace your block code with the following code: class Edit extends \Magento\Framework\View\Element\Template { protected $request; protected $customerSession; protected $objectManager; public function __construct( \Magento\Framework\View\Element\Template\Context $context, array $data = [], \FM\Quick\Model\...


1

Try this. Ref. https://sohel.dev/2017/05/05/how-to-get-customer-id-from-block-when-full-page-cache-enable-in-magento-2/ namespace SR\CustomerSession\Model\Customer; class Context { /** * Customer authorization cache context */ const CONTEXT_CUSTOMER_ID = 'logged_in_customer_id'; } di.xml [SR/CustomerSession/etc/frontend/di.xml] <?...


0

Add This :- {{block class="Magento\Framework\View\Element\Template" template="Magento_Theme::myphp/myphpcode.phtml"}}


Top 50 recent answers are included