Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

New answers tagged

0

The example with observer, based on controller_action_predispatch event isn't well because of full page cache. When cache is warmed up and you are trying to open homepage your code inside observer will not be executed and it can be that you receive foreign locale. I tried to move the idea from above to another place. I added plugin on plugin: \Magento\...


1

There were multiple issues. For once port 80 was only accessible from a specific address I changed that in the firewall. Also the configuration mentioned is not redirecting for me even though I set Use Secure URLs on Storefront to Yes. The way I solved the issue is that I set the https url for base urls and base urls ( secure )


1

Magento has default functionality for set secure(https) and unsecure(http) url. Before update bellow setting backup core_config_data table. Go to Store-> Configuration-> General-> Web->Baseurl(secures) and update http to https. Update the value of Use Secure URLs on Storefront to Yes. Refresh cache php bin/magento cache:clean.


0

Use plugin concept and redirect to magento2 home page after login user successfully. /Vendor/Module/etc/frontend/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="\Magento\Customer\Controller\Account\...


0

namespace Adnan\Redirect\Observer; use Magento\Framework\Event\ObserverInterface; /** * Class Example * * phpcs:disable Generic.Files.LineLength * * @package Adnan\Example\Redirect */ class Example implements ObserverInterface { /** * @var \Magento\Framework\App\ActionFlag */ private $actionFlag; /** * @var \Magento\...


1

I am not sure why you are using "layout_generate_blocks_before" event to redirect to cart if current URL contains SID param. You can create a router file using following way. etc/frontend/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/...


0

$redirectionUrl = $this->url->getUrl('checkout/cart'); $this->responseFactory->create()->setRedirect($redirectionUrl)->sendResponse();


0

You can change you Observer's code with below code <?php namespace Demo\Test\Observer; use Psr\Log\LoggerInterface; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\Session\SessionManagerInterface; use Magento\Framework\App\Request\Http; use Magento\Framework\UrlInterface; use Magento\Framework\...


1

You can use this below script in your root file : <?php error_reporting(1); ini_set('max_execution_time', 0); use \Magento\Framework\App\Bootstrap; require __DIR__ . '/app/bootstrap.php'; $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); $state = $objectManager->get('\Magento\Framework\App\State'); $...


Top 50 recent answers are included