Magentp 2 Issue Observer Calling only One Time when Get Search Term Using Observer The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Facing issue with catalogsearch_query table when using Magento searchMagento 2.3 Can't view module's front end page output?how to get welcome Email when creating customer using custom API in magento 2
How to determine omitted units in a publication
Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?
Do working physicists consider Newtonian mechanics to be "falsified"?
Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?
Variable with quotation marks "$()"
What aspect of planet Earth must be changed to prevent the industrial revolution?
Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?
Am I ethically obligated to go into work on an off day if the reason is sudden?
"... to apply for a visa" or "... and applied for a visa"?
Can the Right Ascension and Argument of Perigee of a spacecraft's orbit keep varying by themselves with time?
different output for groups and groups USERNAME after adding a username to a group
Is there a writing software that you can sort scenes like slides in PowerPoint?
Sub-subscripts in strings cause different spacings than subscripts
What's the point in a preamp?
Does Parliament need to approve the new Brexit delay to 31 October 2019?
Do ℕ, mathbbN, BbbN, symbbN effectively differ, and is there a "canonical" specification of the naturals?
Deal with toxic manager when you can't quit
60's-70's movie: home appliances revolting against the owners
What is the padding with red substance inside of steak packaging?
Button changing its text & action. Good or terrible?
Why are PDP-7-style microprogrammed instructions out of vogue?
Word to describe a time interval
How do you keep chess fun when your opponent constantly beats you?
Loose spokes after only a few rides
Magentp 2 Issue Observer Calling only One Time when Get Search Term Using Observer
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Facing issue with catalogsearch_query table when using Magento searchMagento 2.3 Can't view module's front end page output?how to get welcome Email when creating customer using custom API in magento 2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to get the search term of current user. And according to that search term get products using custom query.
My observer is calling only one time when Cache is enabled.
Please provide me some help or suggestion.
<event name="controller_action_postdispatch_catalogsearch_result_index">
<observer name="searchObserver" instance="VendorModuleObserverSearchData" />
</event>
<?php
namespace VendorModuleObserverSearch;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
use MagentoFrameworkStdlibCookieCookieMetadataFactory;
use MagentoFrameworkStdlibCookieManagerInterface;
class Data implements ObserverInterface
const COOKIE_NAME = 'categoryId';
const COOKIE_DURATION = 86400; // One day (86400 seconds)
protected $_cookieManager;
/**
* @var CookieMetadataFactory
*/
protected $_cookieMetadataFactory;
protected $_queryFactory;
protected $_filterBuilder;
protected $_searchCriteriaBuilder;
protected $_searchInterface;
public function __construct(
CookieManagerInterface $cookieManager, CookieMetadataFactory $cookieMetadataFactory, MagentoSearchModelQueryFactory $queryFactory, MagentoFrameworkApiFilterBuilder $filterBuilder, MagentoFrameworkApiSearchSearchCriteriaBuilder $searchCriteriaBuilder, MagentoSearchApiSearchInterface $searchInterface
)
$this->_cookieManager = $cookieManager;
$this->_cookieMetadataFactory = $cookieMetadataFactory;
$this->_queryFactory = $queryFactory;
$this->_filterBuilder = $filterBuilder;
$this->_searchCriteriaBuilder = $searchCriteriaBuilder;
$this->_searchInterface = $searchInterface;
/**
* Below is the method that will fire whenever the event runs!
*
* @param Observer $observer
*/
public function execute(Observer $observer)
$data = $observer->getData();
$searchTerm = $this->_queryFactory->get()->getQueryText();
$this->_filterBuilder->setField('search_term')
->setValue($searchTerm)
->setConditionType("like");
$this->_searchCriteriaBuilder->addFilter($this->_filterBuilder->create());
$searchCriteria = $this->_searchCriteriaBuilder->create();
$searchCriteria->setRequestName("quick_search_container");
$searchResults = $this->_searchInterface->search($searchCriteria);
print_r($searchResults->getItems());
$products = $searchResults->getItems();
foreach ($products as $product)
echo $id = $product->getId();
$result[] = $id;
exit;
return $this;
magento2.3 search-terms
add a comment |
I want to get the search term of current user. And according to that search term get products using custom query.
My observer is calling only one time when Cache is enabled.
Please provide me some help or suggestion.
<event name="controller_action_postdispatch_catalogsearch_result_index">
<observer name="searchObserver" instance="VendorModuleObserverSearchData" />
</event>
<?php
namespace VendorModuleObserverSearch;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
use MagentoFrameworkStdlibCookieCookieMetadataFactory;
use MagentoFrameworkStdlibCookieManagerInterface;
class Data implements ObserverInterface
const COOKIE_NAME = 'categoryId';
const COOKIE_DURATION = 86400; // One day (86400 seconds)
protected $_cookieManager;
/**
* @var CookieMetadataFactory
*/
protected $_cookieMetadataFactory;
protected $_queryFactory;
protected $_filterBuilder;
protected $_searchCriteriaBuilder;
protected $_searchInterface;
public function __construct(
CookieManagerInterface $cookieManager, CookieMetadataFactory $cookieMetadataFactory, MagentoSearchModelQueryFactory $queryFactory, MagentoFrameworkApiFilterBuilder $filterBuilder, MagentoFrameworkApiSearchSearchCriteriaBuilder $searchCriteriaBuilder, MagentoSearchApiSearchInterface $searchInterface
)
$this->_cookieManager = $cookieManager;
$this->_cookieMetadataFactory = $cookieMetadataFactory;
$this->_queryFactory = $queryFactory;
$this->_filterBuilder = $filterBuilder;
$this->_searchCriteriaBuilder = $searchCriteriaBuilder;
$this->_searchInterface = $searchInterface;
/**
* Below is the method that will fire whenever the event runs!
*
* @param Observer $observer
*/
public function execute(Observer $observer)
$data = $observer->getData();
$searchTerm = $this->_queryFactory->get()->getQueryText();
$this->_filterBuilder->setField('search_term')
->setValue($searchTerm)
->setConditionType("like");
$this->_searchCriteriaBuilder->addFilter($this->_filterBuilder->create());
$searchCriteria = $this->_searchCriteriaBuilder->create();
$searchCriteria->setRequestName("quick_search_container");
$searchResults = $this->_searchInterface->search($searchCriteria);
print_r($searchResults->getItems());
$products = $searchResults->getItems();
foreach ($products as $product)
echo $id = $product->getId();
$result[] = $id;
exit;
return $this;
magento2.3 search-terms
Magento does not save customer details with the search term,So you cannot get the current customer search term from default Magento. You have to build an extension of your self.
– Amit Bera♦
yesterday
Please check my question I have updated. Observer is calling only one time when Cache is enabled.
– Magecode
yesterday
add a comment |
I want to get the search term of current user. And according to that search term get products using custom query.
My observer is calling only one time when Cache is enabled.
Please provide me some help or suggestion.
<event name="controller_action_postdispatch_catalogsearch_result_index">
<observer name="searchObserver" instance="VendorModuleObserverSearchData" />
</event>
<?php
namespace VendorModuleObserverSearch;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
use MagentoFrameworkStdlibCookieCookieMetadataFactory;
use MagentoFrameworkStdlibCookieManagerInterface;
class Data implements ObserverInterface
const COOKIE_NAME = 'categoryId';
const COOKIE_DURATION = 86400; // One day (86400 seconds)
protected $_cookieManager;
/**
* @var CookieMetadataFactory
*/
protected $_cookieMetadataFactory;
protected $_queryFactory;
protected $_filterBuilder;
protected $_searchCriteriaBuilder;
protected $_searchInterface;
public function __construct(
CookieManagerInterface $cookieManager, CookieMetadataFactory $cookieMetadataFactory, MagentoSearchModelQueryFactory $queryFactory, MagentoFrameworkApiFilterBuilder $filterBuilder, MagentoFrameworkApiSearchSearchCriteriaBuilder $searchCriteriaBuilder, MagentoSearchApiSearchInterface $searchInterface
)
$this->_cookieManager = $cookieManager;
$this->_cookieMetadataFactory = $cookieMetadataFactory;
$this->_queryFactory = $queryFactory;
$this->_filterBuilder = $filterBuilder;
$this->_searchCriteriaBuilder = $searchCriteriaBuilder;
$this->_searchInterface = $searchInterface;
/**
* Below is the method that will fire whenever the event runs!
*
* @param Observer $observer
*/
public function execute(Observer $observer)
$data = $observer->getData();
$searchTerm = $this->_queryFactory->get()->getQueryText();
$this->_filterBuilder->setField('search_term')
->setValue($searchTerm)
->setConditionType("like");
$this->_searchCriteriaBuilder->addFilter($this->_filterBuilder->create());
$searchCriteria = $this->_searchCriteriaBuilder->create();
$searchCriteria->setRequestName("quick_search_container");
$searchResults = $this->_searchInterface->search($searchCriteria);
print_r($searchResults->getItems());
$products = $searchResults->getItems();
foreach ($products as $product)
echo $id = $product->getId();
$result[] = $id;
exit;
return $this;
magento2.3 search-terms
I want to get the search term of current user. And according to that search term get products using custom query.
My observer is calling only one time when Cache is enabled.
Please provide me some help or suggestion.
<event name="controller_action_postdispatch_catalogsearch_result_index">
<observer name="searchObserver" instance="VendorModuleObserverSearchData" />
</event>
<?php
namespace VendorModuleObserverSearch;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
use MagentoFrameworkStdlibCookieCookieMetadataFactory;
use MagentoFrameworkStdlibCookieManagerInterface;
class Data implements ObserverInterface
const COOKIE_NAME = 'categoryId';
const COOKIE_DURATION = 86400; // One day (86400 seconds)
protected $_cookieManager;
/**
* @var CookieMetadataFactory
*/
protected $_cookieMetadataFactory;
protected $_queryFactory;
protected $_filterBuilder;
protected $_searchCriteriaBuilder;
protected $_searchInterface;
public function __construct(
CookieManagerInterface $cookieManager, CookieMetadataFactory $cookieMetadataFactory, MagentoSearchModelQueryFactory $queryFactory, MagentoFrameworkApiFilterBuilder $filterBuilder, MagentoFrameworkApiSearchSearchCriteriaBuilder $searchCriteriaBuilder, MagentoSearchApiSearchInterface $searchInterface
)
$this->_cookieManager = $cookieManager;
$this->_cookieMetadataFactory = $cookieMetadataFactory;
$this->_queryFactory = $queryFactory;
$this->_filterBuilder = $filterBuilder;
$this->_searchCriteriaBuilder = $searchCriteriaBuilder;
$this->_searchInterface = $searchInterface;
/**
* Below is the method that will fire whenever the event runs!
*
* @param Observer $observer
*/
public function execute(Observer $observer)
$data = $observer->getData();
$searchTerm = $this->_queryFactory->get()->getQueryText();
$this->_filterBuilder->setField('search_term')
->setValue($searchTerm)
->setConditionType("like");
$this->_searchCriteriaBuilder->addFilter($this->_filterBuilder->create());
$searchCriteria = $this->_searchCriteriaBuilder->create();
$searchCriteria->setRequestName("quick_search_container");
$searchResults = $this->_searchInterface->search($searchCriteria);
print_r($searchResults->getItems());
$products = $searchResults->getItems();
foreach ($products as $product)
echo $id = $product->getId();
$result[] = $id;
exit;
return $this;
magento2.3 search-terms
magento2.3 search-terms
edited yesterday
Magecode
asked yesterday
MagecodeMagecode
556421
556421
Magento does not save customer details with the search term,So you cannot get the current customer search term from default Magento. You have to build an extension of your self.
– Amit Bera♦
yesterday
Please check my question I have updated. Observer is calling only one time when Cache is enabled.
– Magecode
yesterday
add a comment |
Magento does not save customer details with the search term,So you cannot get the current customer search term from default Magento. You have to build an extension of your self.
– Amit Bera♦
yesterday
Please check my question I have updated. Observer is calling only one time when Cache is enabled.
– Magecode
yesterday
Magento does not save customer details with the search term,So you cannot get the current customer search term from default Magento. You have to build an extension of your self.
– Amit Bera♦
yesterday
Magento does not save customer details with the search term,So you cannot get the current customer search term from default Magento. You have to build an extension of your self.
– Amit Bera♦
yesterday
Please check my question I have updated. Observer is calling only one time when Cache is enabled.
– Magecode
yesterday
Please check my question I have updated. Observer is calling only one time when Cache is enabled.
– Magecode
yesterday
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269631%2fmagentp-2-issue-observer-calling-only-one-time-when-get-search-term-using-observ%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269631%2fmagentp-2-issue-observer-calling-only-one-time-when-get-search-term-using-observ%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Magento does not save customer details with the search term,So you cannot get the current customer search term from default Magento. You have to build an extension of your self.
– Amit Bera♦
yesterday
Please check my question I have updated. Observer is calling only one time when Cache is enabled.
– Magecode
yesterday