Categories
CMS Magento Mastering Development

MAgento2 how can I get which page I am when cache is enabled

MAgento2 how can I get which page I am when cache is enabled. I am facing issue to get which page I am or current page URL when cache is enabled <?php $urlInterface = \Magento\Framework\App\ObjectManager::getInstance()->get(‘Magento\Framework\UrlInterface’); $CurrentUrl = $urlInterface->getCurrentUrl(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $request = $objectManager->get(‘Magento\Framework\App\Action\Context’)->getRequest(); echo $request->getFullActionName(); // echo "<pre>"; // echo $this->getBaseUrl(); // echo strcmp($CurrentUrl, […]

Categories
CMS Magento Mastering Development

Magento 2 href to Add product link from template phtml

I Have made custom admin page view module, now i want add button there click on which should take user to add product URL . i tried below but it is not working <a href=”<?PHP echo $resultRedirect->setPath(‘catalog/product/edit’, [‘id’ => 10, ‘_current’ => true,’next’=>”1″]);

Categories
CMS Magento Mastering Development

Magento2 serialize data before displaying in grid

How can i unserialize data before displaying in Grid public function _construct() { parent::_construct(); $this->setId(‘inquiryGrid’); $this->setDefaultSort(‘inquiry_id’); $this->setDefaultDir(‘DESC’); $this->setUseAjax(true); $this->setSaveParametersInSession(true); } public function _prepareCollection() { $collection = $this->collectionFactory->create(); $this->setCollection($collection); return parent::_prepareCollection(); } public function _prepareColumns() { $this->addColumn( ‘inquiry_id’, [ ‘header’ => __(‘ID’), ‘index’ => ‘inquiry_id’, ] ); $this->addColumn(‘product_id’, [‘header’ => __(‘Product Id’), ‘index’ => ‘product_id’]); $this->addColumn(‘product_name’, […]

Categories
CMS Magento Mastering Development

Magento2 serialize data before displaying in grid

How can i unserialize data before displaying in Grid public function _construct() { parent::_construct(); $this->setId(‘inquiryGrid’); $this->setDefaultSort(‘inquiry_id’); $this->setDefaultDir(‘DESC’); $this->setUseAjax(true); $this->setSaveParametersInSession(true); } public function _prepareCollection() { $collection = $this->collectionFactory->create(); $this->setCollection($collection); return parent::_prepareCollection(); } public function _prepareColumns() { $this->addColumn( ‘inquiry_id’, [ ‘header’ => __(‘ID’), ‘index’ => ‘inquiry_id’, ] ); $this->addColumn(‘product_id’, [‘header’ => __(‘Product Id’), ‘index’ => ‘product_id’]); $this->addColumn(‘product_name’, […]

Categories
CMS Magento Mastering Development

Product grid checkbox input at sales rule form Magento 2 not working

I’m using Magento 2.3.4 and want to add product grid with checkbox as an input for sales rule form (shopping cart price rule), i follow the instruction to add product grid input from here but when I print the $_POST value the input data does not exist. Here’s my code: app/code/Becom/Freegift/Block/Adminhtml/Products/Edit/Tab/Product.php namespace Becom\Freegift\Block\Adminhtml\Products\Edit\Tab; use Magento\Backend\Block\Widget\Grid; […]

Categories
CMS Magento Mastering Development

Product grid checkbox input at sales rule form Magento 2 not working

I’m using Magento 2.3.4 and want to add product grid with checkbox as an input for sales rule form (shopping cart price rule), i follow the instruction to add product grid input from here but when I print the $_POST value the input data does not exist. Here’s my code: app/code/Becom/Freegift/Block/Adminhtml/Products/Edit/Tab/Product.php namespace Becom\Freegift\Block\Adminhtml\Products\Edit\Tab; use Magento\Backend\Block\Widget\Grid; […]

Categories
CMS Development Magento

Change customer group based on custom checkbox magento 2?

<form class=”form create account form-create-account” action=”<?= $block->escapeUrl($block->getPostActionUrl()) ?>” method=”post” id=”form-validate” enctype=”multipart/form-data” autocomplete=”off”> <?= /* @noEscape */ $block->getBlockHtml(‘formkey’); ?> <fieldset class=”fieldset create info”> <legend class=”legend”><span><?= $block->escapeHtml(__(‘Personal Information’)) ?></span></legend><br> <input type=”hidden” name=”success_url” value=”<?= $block->escapeUrl($block->getSuccessUrl()) ?>”> <input type=”hidden” name=”error_url” value=”<?= $block->escapeUrl($block->getErrorUrl()) ?>”> <input type=”hidden” name=”invitecode” value=”<?= $this->getUrl(‘*/*/*’, [‘_current’ => true, ‘_use_rewrite’ => true]) ?>”> <?= $block->getLayout()->createBlock(‘Magento\Customer\Block\Widget\Name’)->setObject($block->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?> <?php […]

Categories
CMS Development Magento

Magento 2 Remove Total from report table

I have overridden the Sales report in my custom report file but I want to remove footer which is automatically added that I don’t need how to remove that footer My layout xml file is <?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=”reports_sales”/> <body> <referenceContainer name=”page.main.actions”> <block class=”Magento\Backend\Block\Store\Switcher” template=”Magento_Backend::store/switcher.phtml” name=”store.switcher”> <action method=”setStoreVarName”> <argument name=”var_name” xsi:type=”string”>store_ids</argument> </action> […]

Categories
CMS Development Magento

Magento 2 Remove Total from report table

I have overridden the Sales report in my custom report file but I want to remove footer which is automatically added that I don’t need how to remove that footer My layout xml file is <?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=”reports_sales”/> <body> <referenceContainer name=”page.main.actions”> <block class=”Magento\Backend\Block\Store\Switcher” template=”Magento_Backend::store/switcher.phtml” name=”store.switcher”> <action method=”setStoreVarName”> <argument name=”var_name” xsi:type=”string”>store_ids</argument> </action> […]

Categories
CMS Development Magento

Magento 2 Remove Total from report table

I have overridden the Sales report in my custom report file but I want to remove footer which is automatically added that I don’t need how to remove that footer My layout xml file is <?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=”reports_sales”/> <body> <referenceContainer name=”page.main.actions”> <block class=”Magento\Backend\Block\Store\Switcher” template=”Magento_Backend::store/switcher.phtml” name=”store.switcher”> <action method=”setStoreVarName”> <argument name=”var_name” xsi:type=”string”>store_ids</argument> </action> […]