Closed sidneylopes closed 4 years ago
@sidneylopes yes, you can.
if you take a look function getSearchCreteriaForCategoryAndChild
in src/magento/lib/admin/index.js
file, there is
const searchCriteria = {
groups: [
[{
field: 'visibility',
value: '4',
conditionType: 'eq',
}],
[{
field: 'status',
value: '1',
conditionType: 'eq',
}],
],
};
which is filtering products by visibility
and status
so you can modify filters whatever you need.
here are the docs on how to use Magento search criteria https://devdocs.magento.com/guides/v2.4/rest/performing-searches.html
thanks, problem solved
hey, I still have a problem. I need to hide the products that aren't in stock, but I am having trouble. Here is a part of the JSON of a product, the parameter that I need is "is_in_stock" in "stock_item":
"items": [ { "id": 5, "sku": "22-0001", "name": "Antena Chapa Ku Mini Parabólica 60cm - Bedin Sat", "attribute_set_id": 4, "price": 85.32, "status": 1, "visibility": 4, "type_id": "simple", "created_at": "2020-03-30 21:54:35", "updated_at": "2020-11-09 18:26:18", "weight": 0.888, "extension_attributes": { "website_ids": [ 1, 2 ], "category_links": [ { "position": 0, "category_id": "33" }, { "position": 0, "category_id": "48" }, { "position": 0, "category_id": "2" } ], "stock_item": { "item_id": 3, "product_id": 5, "stock_id": 1, "qty": 1468, "is_in_stock": true, "is_qty_decimal": false, "show_default_notification_message": false, "use_config_min_qty": true, "min_qty": 5, "use_config_min_sale_qty": 1, "min_sale_qty": 1, "use_config_max_sale_qty": true, "max_sale_qty": 10000, "use_config_backorders": true, "backorders": 0, "use_config_notify_stock_qty": true, "notify_stock_qty": 5, "use_config_qty_increments": true, "qty_increments": 0, "use_config_enable_qty_inc": true, "enable_qty_increments": false, "use_config_manage_stock": true, "manage_stock": true, "low_stock_date": null, "is_decimal_divided": false, "stock_status_changed_auto": 0 } },
Did you read the docs?
here are the docs on how to use Magento search criteria https://devdocs.magento.com/guides/v2.4/rest/performing-searches.html
yup, but still couldn't solve my problem
why?
I'm trying to use "is_in_stock" as a filter, but all the products disappear.
Can share what exactly you are trying to do?
const searchCriteria = { groups: [ [{ field: 'visibility', value: '4', conditionType: 'eq', }], [{ field: 'status', value: '1', conditionType: 'eq', }], [{ field: 'website_id', value: '1', conditionType: 'eq', }], [{ field: 'is_in_stock', value: true, conditionType: 'eq', }], ], };const searchCriteria = { groups: [ [{ field: 'visibility', value: '4', conditionType: 'eq', }], [{ field: 'status', value: '1', conditionType: 'eq', }], [{ field: 'website_id', value: '1', conditionType: 'eq', }], [{ field: 'is_in_stock', value: true, conditionType: 'eq', }], ], };
the "website_id" works, but the "is_in_stock" doesn't
@sidneylopes try to google about this issue. From what I can read field you trying to filter should be presented in Magento database https://magento.stackexchange.com/questions/158062/magento-2-api-filter-orders-by-extension-attribute
Is there any way for me to not show unavailable products?