Magento V2 API Filters in C# – Simple Example

Here’s how to filter on a multi-select attribute using the Magento V2 API. The attribute I’m filtering on is “NEMA Rating”. It can have any number of values shown here.

NemaAttribute

The easiest way to translate the text value to the numeric value stored in the database is by using your browser’s developer tools. Hit F12.

NemaAttributeDOM

Once you get the numeric translations. Here’s your code:

MagentoFiltersExample

Here is the same code in a format that you can cut and paste.

filters filters = new filters()
{
filter = new associativeEntity[] {
new associativeEntity()
{
key = “nema_rating”
, value = “129”
},
new associativeEntity()
{
key = “nema_rating”
, value = “126”
},
new associativeEntity()
{
key = “nema_rating”
, value = “127”
},
new associativeEntity()
{
key = “nema_rating”
, value = “128”
},
new associativeEntity()
{
key = “nema_rating”
, value = “125”
},
new associativeEntity()
{
key = “nema_rating”
, value = “124”
}
}
};
productList = client.catalogProductList(sessionID, filters, null);

Happy coding!

One thought on “Magento V2 API Filters in C# – Simple Example

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s