Magento 2 delete search term through sql queryComplex SQL query to MagentoGet users address through sql queryMagento orm model and direct SQL queryRun an SQL query from the Magento Admin PanelGet all Magento Categories using SQL queryHow to find and replace product title using sql querySQL Query While uploading sql fileMagento 2: Get Product URL and SKU using SQL QueryGet list of disabled products in Magento 2 with SQL query?Direct Query delete with error: SQLSTATE[21000]: Cardinality violation

Tiptoe or tiphoof? Adjusting words to better fit fantasy races

How to be diplomatic in refusing to write code that breaches the privacy of our users

How to Reset Passwords on Multiple Websites Easily?

Is this apparent Class Action settlement a spam message?

Sort a list by elements of another list

How do scammers retract money, while you can’t?

Customer Requests (Sometimes) Drive Me Bonkers!

Lay out the Carpet

How does it work when somebody invests in my business?

What does this 7 mean above the f flat

Trouble understanding the speech of overseas colleagues

How does buying out courses with grant money work?

How easy is it to start Magic from scratch?

Go Pregnant or Go Home

What is the difference between "behavior" and "behaviour"?

Is expanding the research of a group into machine learning as a PhD student risky?

Anatomically Correct Strange Women In Ponds Distributing Swords

What does "I’d sit this one out, Cap," imply or mean in the context?

How to check is there any negative term in a large list?

Do sorcerers' subtle spells require a skill check to be unseen?

How can a function with a hole (removable discontinuity) equal a function with no hole?

How to safely derail a train during transit?

Two monoidal structures and copowering

How many times can American Tourist re-enter UK in same 6 month period?



Magento 2 delete search term through sql query


Complex SQL query to MagentoGet users address through sql queryMagento orm model and direct SQL queryRun an SQL query from the Magento Admin PanelGet all Magento Categories using SQL queryHow to find and replace product title using sql querySQL Query While uploading sql fileMagento 2: Get Product URL and SKU using SQL QueryGet list of disabled products in Magento 2 with SQL query?Direct Query delete with error: SQLSTATE[21000]: Cardinality violation













2















I want to delete search terms with 0 search results from magento 2 database by writing sql query in file. How can I do this?










share|improve this question






















  • We do have an option delete the search terms from the admin , On the Admin sidebar, tap Marketing. Then under SEO & Search, choose Search Terms. here we have option to filter results in the grid and delete it.

    – Purnendar Gattu
    yesterday











  • I want to create a file in magento which I will run through cron job everyday to delete the search terms automatically. I am asking for solution in code file.

    – chanchal
    yesterday












  • Delete the records from the 'search_query' whose 'num_results = 0'.

    – Purnendar Gattu
    yesterday















2















I want to delete search terms with 0 search results from magento 2 database by writing sql query in file. How can I do this?










share|improve this question






















  • We do have an option delete the search terms from the admin , On the Admin sidebar, tap Marketing. Then under SEO & Search, choose Search Terms. here we have option to filter results in the grid and delete it.

    – Purnendar Gattu
    yesterday











  • I want to create a file in magento which I will run through cron job everyday to delete the search terms automatically. I am asking for solution in code file.

    – chanchal
    yesterday












  • Delete the records from the 'search_query' whose 'num_results = 0'.

    – Purnendar Gattu
    yesterday













2












2








2








I want to delete search terms with 0 search results from magento 2 database by writing sql query in file. How can I do this?










share|improve this question














I want to delete search terms with 0 search results from magento 2 database by writing sql query in file. How can I do this?







magento-2.1 database sql






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









chanchalchanchal

356




356












  • We do have an option delete the search terms from the admin , On the Admin sidebar, tap Marketing. Then under SEO & Search, choose Search Terms. here we have option to filter results in the grid and delete it.

    – Purnendar Gattu
    yesterday











  • I want to create a file in magento which I will run through cron job everyday to delete the search terms automatically. I am asking for solution in code file.

    – chanchal
    yesterday












  • Delete the records from the 'search_query' whose 'num_results = 0'.

    – Purnendar Gattu
    yesterday

















  • We do have an option delete the search terms from the admin , On the Admin sidebar, tap Marketing. Then under SEO & Search, choose Search Terms. here we have option to filter results in the grid and delete it.

    – Purnendar Gattu
    yesterday











  • I want to create a file in magento which I will run through cron job everyday to delete the search terms automatically. I am asking for solution in code file.

    – chanchal
    yesterday












  • Delete the records from the 'search_query' whose 'num_results = 0'.

    – Purnendar Gattu
    yesterday
















We do have an option delete the search terms from the admin , On the Admin sidebar, tap Marketing. Then under SEO & Search, choose Search Terms. here we have option to filter results in the grid and delete it.

– Purnendar Gattu
yesterday





We do have an option delete the search terms from the admin , On the Admin sidebar, tap Marketing. Then under SEO & Search, choose Search Terms. here we have option to filter results in the grid and delete it.

– Purnendar Gattu
yesterday













I want to create a file in magento which I will run through cron job everyday to delete the search terms automatically. I am asking for solution in code file.

– chanchal
yesterday






I want to create a file in magento which I will run through cron job everyday to delete the search terms automatically. I am asking for solution in code file.

– chanchal
yesterday














Delete the records from the 'search_query' whose 'num_results = 0'.

– Purnendar Gattu
yesterday





Delete the records from the 'search_query' whose 'num_results = 0'.

– Purnendar Gattu
yesterday










1 Answer
1






active

oldest

votes


















1














The query should be like,



DELETE FROM `search_query` WHERE `num_results` = 0;


Or you can use following PHP code.



protected $queryCollectionFactrory;

public function __construct(
MagentoSearchModelResourceModelQueryCollectionFactory $queryCollectionFactrory
)

$this->queryCollectionFactrory = $queryCollectionFactrory;


public function removeZeroResults()

$collection = $this->queryCollectionFactrory->create();
$collection->addFieldToFilter('num_results', 0);

foreach($collection as $row)

$row->delete();







share|improve this answer

























  • where to place the above php code file ? I mean to say the path . Do I need to create a custom module for this ?

    – chanchal
    yesterday











  • You can create a custom module or you can place this code on whatever event you want to delete records with 0 search result.

    – Yash Shah
    yesterday










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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f267382%2fmagento-2-delete-search-term-through-sql-query%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The query should be like,



DELETE FROM `search_query` WHERE `num_results` = 0;


Or you can use following PHP code.



protected $queryCollectionFactrory;

public function __construct(
MagentoSearchModelResourceModelQueryCollectionFactory $queryCollectionFactrory
)

$this->queryCollectionFactrory = $queryCollectionFactrory;


public function removeZeroResults()

$collection = $this->queryCollectionFactrory->create();
$collection->addFieldToFilter('num_results', 0);

foreach($collection as $row)

$row->delete();







share|improve this answer

























  • where to place the above php code file ? I mean to say the path . Do I need to create a custom module for this ?

    – chanchal
    yesterday











  • You can create a custom module or you can place this code on whatever event you want to delete records with 0 search result.

    – Yash Shah
    yesterday















1














The query should be like,



DELETE FROM `search_query` WHERE `num_results` = 0;


Or you can use following PHP code.



protected $queryCollectionFactrory;

public function __construct(
MagentoSearchModelResourceModelQueryCollectionFactory $queryCollectionFactrory
)

$this->queryCollectionFactrory = $queryCollectionFactrory;


public function removeZeroResults()

$collection = $this->queryCollectionFactrory->create();
$collection->addFieldToFilter('num_results', 0);

foreach($collection as $row)

$row->delete();







share|improve this answer

























  • where to place the above php code file ? I mean to say the path . Do I need to create a custom module for this ?

    – chanchal
    yesterday











  • You can create a custom module or you can place this code on whatever event you want to delete records with 0 search result.

    – Yash Shah
    yesterday













1












1








1







The query should be like,



DELETE FROM `search_query` WHERE `num_results` = 0;


Or you can use following PHP code.



protected $queryCollectionFactrory;

public function __construct(
MagentoSearchModelResourceModelQueryCollectionFactory $queryCollectionFactrory
)

$this->queryCollectionFactrory = $queryCollectionFactrory;


public function removeZeroResults()

$collection = $this->queryCollectionFactrory->create();
$collection->addFieldToFilter('num_results', 0);

foreach($collection as $row)

$row->delete();







share|improve this answer















The query should be like,



DELETE FROM `search_query` WHERE `num_results` = 0;


Or you can use following PHP code.



protected $queryCollectionFactrory;

public function __construct(
MagentoSearchModelResourceModelQueryCollectionFactory $queryCollectionFactrory
)

$this->queryCollectionFactrory = $queryCollectionFactrory;


public function removeZeroResults()

$collection = $this->queryCollectionFactrory->create();
$collection->addFieldToFilter('num_results', 0);

foreach($collection as $row)

$row->delete();








share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered yesterday









Yash ShahYash Shah

53018




53018












  • where to place the above php code file ? I mean to say the path . Do I need to create a custom module for this ?

    – chanchal
    yesterday











  • You can create a custom module or you can place this code on whatever event you want to delete records with 0 search result.

    – Yash Shah
    yesterday

















  • where to place the above php code file ? I mean to say the path . Do I need to create a custom module for this ?

    – chanchal
    yesterday











  • You can create a custom module or you can place this code on whatever event you want to delete records with 0 search result.

    – Yash Shah
    yesterday
















where to place the above php code file ? I mean to say the path . Do I need to create a custom module for this ?

– chanchal
yesterday





where to place the above php code file ? I mean to say the path . Do I need to create a custom module for this ?

– chanchal
yesterday













You can create a custom module or you can place this code on whatever event you want to delete records with 0 search result.

– Yash Shah
yesterday





You can create a custom module or you can place this code on whatever event you want to delete records with 0 search result.

– Yash Shah
yesterday

















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f267382%2fmagento-2-delete-search-term-through-sql-query%23new-answer', 'question_page');

);

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







Popular posts from this blog

Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

БиармияSxpst500bh2ntaf! 3h2r