Helpcenter +918010117117 https://cdn1.storehippo.com/s/573db3149f0d58741f0cc63b/ms.settings/5256837ccc4abf1d39000001/57614ef64256dc6851749879-480x480.png" support@storehippo.com https://www.facebook.com/StoreHippohttps://twitter.com/StoreHippohttps://www.linkedin.com/company/hippoinnovations/https://plus.google.com/+Storehippo/posts
B4,309-10 Spaze iTech Park, Sector 49, Sohna Road, 122001 Gurgaon India
call to replace anchor tags contains '/admin' in href

Commands and Hooks

All entities have standard commands that are used to perform standard CRUD operations.

Standard Commands

Following are standard commands that are available by default to all global or store entities.

  • get 
  • list
  • add
  • edit
  • delete
  • duplicate
  • import
  • export

Custom Commands

Custom commands are available only in Enterprise plan.


Apart from standard commands, the user can create custom commands for any entity. 

Adding a custom command

To create a custom command for an entity, please follow these steps:

  • Go to Advance Settings > Entities in StoreHippo Admin Panel.
  • Search the entity to which you want to add the command.
  • Click on the edit button.
  • On the edit page, go toCommandstab.

<Image for commands tab will go here>

Click on Add New button. A form will appear withfollowingfields:

name

Enter the name of the command

method

Enter the HTTP method that can be used for the command. Possible values are:

  • GET
  • POST
  • PUT
  • DELETE

handler

Handler is the function that gets executed when the command is called.  Please refer to the section below on how to write command handlers.

roles

Select the roles that have permission to call this command.
 

Extending standard commands

Hooks can be used to extend thebehaviourof standard commands. There are two types of hooks

Pre Hooks

pre hooks are executed before the command handler. If there are multiple pre hooks then they are executed in the order of priority.

Post Hooks

Post hooks are executed after the command is executed. If there are multiple pre hooks then they are executed in the order of priority.
 

Writing Command Handlers and Hooks

Both command handlers and hooks follow the same middleware syntax which looks as follows:

function(request, response, next) {

}

Request

sessionneed to see if we need to pass the session. We probably should but leave aside the sensitive information
headers
usercurrency, language, geolocation etc. will be part of this
appapp instance to call other APIs
moduleThird party installed apps.
substoresubstoreinstance
storeVariantstoreVariantinstance
entity
resourceId
command

 

Response

send(data)will stop the execution and return the control from the current handler/hook. It will also stop the execution of any subsequent handler/hooks.
error(data)will stop execution and also return error
next()will return control from current handler but enable execution of subsequent handlers/hooks.


 

Share:

2021-03-24T09:44:43.886Z