Magento 2: Run reindexer using REST API Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?No response from POST to custom REST Api routeCreate Custom Rest Api in Magento2 and solution for “InvalidArgumentException” errorMagento 2 Custom Web Api callMagento 2: Run reindexer programmaticallyMagento 1.9 - Create order using REST APIMagento 2 - Best approach for retrieving product data - REST API or Custom Endpoint?Magento 2.2.2 REST API - I need to change the customer password using REST APIMagento 2 Rest API using basic AuthMagento2 currency switcher using rest APIMagento2 REST API get all customers details
Help Recreating a Table
Can this water damage be explained by lack of gutters and grading issues?
Who can become a wight?
Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?
What were wait-states, and why was it only an issue for PCs?
Does using the Inspiration rules for character defects encourage My Guy Syndrome?
What's the connection between Mr. Nancy and fried chicken?
How to ask rejected full-time candidates to apply to teach individual courses?
Is my guitar’s action too high?
Why isn't everyone flabbergasted about Bran's "gift"?
Why aren't these two solutions equivalent? Combinatorics problem
Why do C and C++ allow the expression (int) + 4*5?
What kind of equipment or other technology is necessary to photograph sprites (atmospheric phenomenon)
Where is Bhagavad Gita referred to as Hari Gita?
Can the van der Waals coefficients be negative in the van der Waals equation for real gases?
What's the difference between using dependency injection with a container and using a service locator?
Trying to enter the Fox's den
What is the evidence that custom checks in Northern Ireland are going to result in violence?
Compiling and throwing simple dynamic exceptions at runtime for JVM
Why these surprising proportionalities of integrals involving odd zeta values?
"Destructive force" carried by a B-52?
What is the ongoing value of the Kanban board to the developers as opposed to management
Does the Pact of the Blade warlock feature allow me to customize the properties of the pact weapon I create?
How can I introduce the names of fantasy creatures to the reader?
Magento 2: Run reindexer using REST API
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?No response from POST to custom REST Api routeCreate Custom Rest Api in Magento2 and solution for “InvalidArgumentException” errorMagento 2 Custom Web Api callMagento 2: Run reindexer programmaticallyMagento 1.9 - Create order using REST APIMagento 2 - Best approach for retrieving product data - REST API or Custom Endpoint?Magento 2.2.2 REST API - I need to change the customer password using REST APIMagento 2 Rest API using basic AuthMagento2 currency switcher using rest APIMagento2 REST API get all customers details
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Is any one having tried to create REST API so using custom API one can trigger re-indexing?
which method do i have to mention in webapi.xml file as this is purely AREA::ADMIN activitiy. currently tried with POST (create) and PUT (Update).
Below is the webapi.xml
<route url="/V1/customapi" method="POST">
<service class="SarkCustomApiApiCustomRepositoryInterface" method="create"/>
<resources>
<resource ref="self"/>
</resources>
</route>
Further, for controller do i have to create API folder and interface mandatory or it is optional.
Index pro-grammatically code is as follows:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$indexerCollectionFactory = $objectManager->get("MagentoIndexerModelIndexerCollectionFactory");
$indexerFactory = $objectManager->get("MagentoIndexerModelIndexerFactory");
$indexerCollection = $indexerCollectionFactory->create();
$allIds = $indexerCollection->getAllIds();
foreach ($allIds as $id)
$indexer = $indexerFactory->create()->load($id);
$indexer->reindexAll();
It would be good if any other API is also there to do the same magic (except the direct custom script file).
Ref.: http://codetheatres.com/magento/creating-custom-api-in-magento2-using-rest-protocol/
api rest-api reindex
add a comment |
Is any one having tried to create REST API so using custom API one can trigger re-indexing?
which method do i have to mention in webapi.xml file as this is purely AREA::ADMIN activitiy. currently tried with POST (create) and PUT (Update).
Below is the webapi.xml
<route url="/V1/customapi" method="POST">
<service class="SarkCustomApiApiCustomRepositoryInterface" method="create"/>
<resources>
<resource ref="self"/>
</resources>
</route>
Further, for controller do i have to create API folder and interface mandatory or it is optional.
Index pro-grammatically code is as follows:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$indexerCollectionFactory = $objectManager->get("MagentoIndexerModelIndexerCollectionFactory");
$indexerFactory = $objectManager->get("MagentoIndexerModelIndexerFactory");
$indexerCollection = $indexerCollectionFactory->create();
$allIds = $indexerCollection->getAllIds();
foreach ($allIds as $id)
$indexer = $indexerFactory->create()->load($id);
$indexer->reindexAll();
It would be good if any other API is also there to do the same magic (except the direct custom script file).
Ref.: http://codetheatres.com/magento/creating-custom-api-in-magento2-using-rest-protocol/
api rest-api reindex
add a comment |
Is any one having tried to create REST API so using custom API one can trigger re-indexing?
which method do i have to mention in webapi.xml file as this is purely AREA::ADMIN activitiy. currently tried with POST (create) and PUT (Update).
Below is the webapi.xml
<route url="/V1/customapi" method="POST">
<service class="SarkCustomApiApiCustomRepositoryInterface" method="create"/>
<resources>
<resource ref="self"/>
</resources>
</route>
Further, for controller do i have to create API folder and interface mandatory or it is optional.
Index pro-grammatically code is as follows:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$indexerCollectionFactory = $objectManager->get("MagentoIndexerModelIndexerCollectionFactory");
$indexerFactory = $objectManager->get("MagentoIndexerModelIndexerFactory");
$indexerCollection = $indexerCollectionFactory->create();
$allIds = $indexerCollection->getAllIds();
foreach ($allIds as $id)
$indexer = $indexerFactory->create()->load($id);
$indexer->reindexAll();
It would be good if any other API is also there to do the same magic (except the direct custom script file).
Ref.: http://codetheatres.com/magento/creating-custom-api-in-magento2-using-rest-protocol/
api rest-api reindex
Is any one having tried to create REST API so using custom API one can trigger re-indexing?
which method do i have to mention in webapi.xml file as this is purely AREA::ADMIN activitiy. currently tried with POST (create) and PUT (Update).
Below is the webapi.xml
<route url="/V1/customapi" method="POST">
<service class="SarkCustomApiApiCustomRepositoryInterface" method="create"/>
<resources>
<resource ref="self"/>
</resources>
</route>
Further, for controller do i have to create API folder and interface mandatory or it is optional.
Index pro-grammatically code is as follows:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$indexerCollectionFactory = $objectManager->get("MagentoIndexerModelIndexerCollectionFactory");
$indexerFactory = $objectManager->get("MagentoIndexerModelIndexerFactory");
$indexerCollection = $indexerCollectionFactory->create();
$allIds = $indexerCollection->getAllIds();
foreach ($allIds as $id)
$indexer = $indexerFactory->create()->load($id);
$indexer->reindexAll();
It would be good if any other API is also there to do the same magic (except the direct custom script file).
Ref.: http://codetheatres.com/magento/creating-custom-api-in-magento2-using-rest-protocol/
api rest-api reindex
api rest-api reindex
asked 2 days ago
MageSoftechMageSoftech
14811
14811
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Using API indexing is not a good Idea.
As Indexing run on the command line and it takes much usage on memory & time, So it, not a good idea.
If you want then change the indexing status of each indexing to pending state and Magento cron automatically do indexing as it was in pending. That is the best Solution.
Create di.xml
at app/code/Sark/CustomApi/etc/
and where you will define a model class CustomRepository at app/code/Sark/CustomApi/Model/
which overrides SarkCustomApiApiCustomRepositoryInterface
.
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="SarkCustomApiApiCustomRepositoryInterface" type="SarkCustomApiModelCustomRepository"/>
</config>
And CustomRepository.php
code is
<?php
namespace SarkCustomApiModel;
class CustomRepository implements SarkCustomApiApiCustomRepositoryInterface
/**
* @var MagentoFrameworkIndexerIndexerRegistry
*/
private $indexerRegistry;
/**
* @var MagentoIndexerModelResourceModelIndexerStateCollectionFactory
*/
private $stateCollectionFactory;
public function __construct(
MagentoFrameworkIndexerIndexerRegistry $indexerRegistry,
MagentoIndexerModelResourceModelIndexerStateCollectionFactory $stateCollectionFactory
)
$this->indexerRegistry = $indexerRegistry;
$this->stateCollectionFactory = $stateCollectionFactory;
public function create()
$indexerStates = $this->stateCollectionFactory->create();
foreach ($indexerStates->getItems() as $indexerState)
$indexerState->getIndexerId();
$indexer = $this->indexerRegistry->get($indexerState->getIndexerId());
if ($indexer->getId() && !$indexer->isWorking())
$indexer->setScheduled(true);
Accepted! many thanks for the answer. yes i agreed it will use much resources at server end and it should run onCLI
. this will help a lot.
– MageSoftech
yesterday
add a comment |
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%2f270845%2fmagento-2-run-reindexer-using-rest-api%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
Using API indexing is not a good Idea.
As Indexing run on the command line and it takes much usage on memory & time, So it, not a good idea.
If you want then change the indexing status of each indexing to pending state and Magento cron automatically do indexing as it was in pending. That is the best Solution.
Create di.xml
at app/code/Sark/CustomApi/etc/
and where you will define a model class CustomRepository at app/code/Sark/CustomApi/Model/
which overrides SarkCustomApiApiCustomRepositoryInterface
.
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="SarkCustomApiApiCustomRepositoryInterface" type="SarkCustomApiModelCustomRepository"/>
</config>
And CustomRepository.php
code is
<?php
namespace SarkCustomApiModel;
class CustomRepository implements SarkCustomApiApiCustomRepositoryInterface
/**
* @var MagentoFrameworkIndexerIndexerRegistry
*/
private $indexerRegistry;
/**
* @var MagentoIndexerModelResourceModelIndexerStateCollectionFactory
*/
private $stateCollectionFactory;
public function __construct(
MagentoFrameworkIndexerIndexerRegistry $indexerRegistry,
MagentoIndexerModelResourceModelIndexerStateCollectionFactory $stateCollectionFactory
)
$this->indexerRegistry = $indexerRegistry;
$this->stateCollectionFactory = $stateCollectionFactory;
public function create()
$indexerStates = $this->stateCollectionFactory->create();
foreach ($indexerStates->getItems() as $indexerState)
$indexerState->getIndexerId();
$indexer = $this->indexerRegistry->get($indexerState->getIndexerId());
if ($indexer->getId() && !$indexer->isWorking())
$indexer->setScheduled(true);
Accepted! many thanks for the answer. yes i agreed it will use much resources at server end and it should run onCLI
. this will help a lot.
– MageSoftech
yesterday
add a comment |
Using API indexing is not a good Idea.
As Indexing run on the command line and it takes much usage on memory & time, So it, not a good idea.
If you want then change the indexing status of each indexing to pending state and Magento cron automatically do indexing as it was in pending. That is the best Solution.
Create di.xml
at app/code/Sark/CustomApi/etc/
and where you will define a model class CustomRepository at app/code/Sark/CustomApi/Model/
which overrides SarkCustomApiApiCustomRepositoryInterface
.
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="SarkCustomApiApiCustomRepositoryInterface" type="SarkCustomApiModelCustomRepository"/>
</config>
And CustomRepository.php
code is
<?php
namespace SarkCustomApiModel;
class CustomRepository implements SarkCustomApiApiCustomRepositoryInterface
/**
* @var MagentoFrameworkIndexerIndexerRegistry
*/
private $indexerRegistry;
/**
* @var MagentoIndexerModelResourceModelIndexerStateCollectionFactory
*/
private $stateCollectionFactory;
public function __construct(
MagentoFrameworkIndexerIndexerRegistry $indexerRegistry,
MagentoIndexerModelResourceModelIndexerStateCollectionFactory $stateCollectionFactory
)
$this->indexerRegistry = $indexerRegistry;
$this->stateCollectionFactory = $stateCollectionFactory;
public function create()
$indexerStates = $this->stateCollectionFactory->create();
foreach ($indexerStates->getItems() as $indexerState)
$indexerState->getIndexerId();
$indexer = $this->indexerRegistry->get($indexerState->getIndexerId());
if ($indexer->getId() && !$indexer->isWorking())
$indexer->setScheduled(true);
Accepted! many thanks for the answer. yes i agreed it will use much resources at server end and it should run onCLI
. this will help a lot.
– MageSoftech
yesterday
add a comment |
Using API indexing is not a good Idea.
As Indexing run on the command line and it takes much usage on memory & time, So it, not a good idea.
If you want then change the indexing status of each indexing to pending state and Magento cron automatically do indexing as it was in pending. That is the best Solution.
Create di.xml
at app/code/Sark/CustomApi/etc/
and where you will define a model class CustomRepository at app/code/Sark/CustomApi/Model/
which overrides SarkCustomApiApiCustomRepositoryInterface
.
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="SarkCustomApiApiCustomRepositoryInterface" type="SarkCustomApiModelCustomRepository"/>
</config>
And CustomRepository.php
code is
<?php
namespace SarkCustomApiModel;
class CustomRepository implements SarkCustomApiApiCustomRepositoryInterface
/**
* @var MagentoFrameworkIndexerIndexerRegistry
*/
private $indexerRegistry;
/**
* @var MagentoIndexerModelResourceModelIndexerStateCollectionFactory
*/
private $stateCollectionFactory;
public function __construct(
MagentoFrameworkIndexerIndexerRegistry $indexerRegistry,
MagentoIndexerModelResourceModelIndexerStateCollectionFactory $stateCollectionFactory
)
$this->indexerRegistry = $indexerRegistry;
$this->stateCollectionFactory = $stateCollectionFactory;
public function create()
$indexerStates = $this->stateCollectionFactory->create();
foreach ($indexerStates->getItems() as $indexerState)
$indexerState->getIndexerId();
$indexer = $this->indexerRegistry->get($indexerState->getIndexerId());
if ($indexer->getId() && !$indexer->isWorking())
$indexer->setScheduled(true);
Using API indexing is not a good Idea.
As Indexing run on the command line and it takes much usage on memory & time, So it, not a good idea.
If you want then change the indexing status of each indexing to pending state and Magento cron automatically do indexing as it was in pending. That is the best Solution.
Create di.xml
at app/code/Sark/CustomApi/etc/
and where you will define a model class CustomRepository at app/code/Sark/CustomApi/Model/
which overrides SarkCustomApiApiCustomRepositoryInterface
.
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="SarkCustomApiApiCustomRepositoryInterface" type="SarkCustomApiModelCustomRepository"/>
</config>
And CustomRepository.php
code is
<?php
namespace SarkCustomApiModel;
class CustomRepository implements SarkCustomApiApiCustomRepositoryInterface
/**
* @var MagentoFrameworkIndexerIndexerRegistry
*/
private $indexerRegistry;
/**
* @var MagentoIndexerModelResourceModelIndexerStateCollectionFactory
*/
private $stateCollectionFactory;
public function __construct(
MagentoFrameworkIndexerIndexerRegistry $indexerRegistry,
MagentoIndexerModelResourceModelIndexerStateCollectionFactory $stateCollectionFactory
)
$this->indexerRegistry = $indexerRegistry;
$this->stateCollectionFactory = $stateCollectionFactory;
public function create()
$indexerStates = $this->stateCollectionFactory->create();
foreach ($indexerStates->getItems() as $indexerState)
$indexerState->getIndexerId();
$indexer = $this->indexerRegistry->get($indexerState->getIndexerId());
if ($indexer->getId() && !$indexer->isWorking())
$indexer->setScheduled(true);
edited yesterday
answered 2 days ago
Amit Bera♦Amit Bera
60.2k1678178
60.2k1678178
Accepted! many thanks for the answer. yes i agreed it will use much resources at server end and it should run onCLI
. this will help a lot.
– MageSoftech
yesterday
add a comment |
Accepted! many thanks for the answer. yes i agreed it will use much resources at server end and it should run onCLI
. this will help a lot.
– MageSoftech
yesterday
Accepted! many thanks for the answer. yes i agreed it will use much resources at server end and it should run on
CLI
. this will help a lot.– MageSoftech
yesterday
Accepted! many thanks for the answer. yes i agreed it will use much resources at server end and it should run on
CLI
. this will help a lot.– MageSoftech
yesterday
add a comment |
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%2f270845%2fmagento-2-run-reindexer-using-rest-api%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