Module: Spree::Api::V3::BulkOperations

Extended by:
ActiveSupport::Concern
Included in:
Admin::CustomersController, Admin::PricesController, Admin::ProductsController
Defined in:
app/controllers/concerns/spree/api/v3/bulk_operations.rb

Overview

API-side counterpart to ‘Spree::Admin::BulkOperationsConcern`. Provides the shared tag bulk actions, the `bulk_collection` relation, and the `after_bulk_tags_change` hook controllers override (e.g. to reindex search + match automatic taxons). Shape mirrors the legacy concern so the two stay easy to keep in sync.

Instance Method Summary collapse

Instance Method Details

#bulk_add_tagsObject

POST /api/v3/admin/<resource>/bulk_add_tags Body: { ids: […], tags: [‘summer’, ‘sale’] }



20
21
22
23
24
25
26
27
# File 'app/controllers/concerns/spree/api/v3/bulk_operations.rb', line 20

def bulk_add_tags
  authorize! :update, model_class

  Spree::Tags::BulkAdd.call(tag_names: Array(params[:tags]), records: bulk_collection)
  after_bulk_tags_change

  render json: bulk_tags_response
end

#bulk_remove_tagsObject

POST /api/v3/admin/<resource>/bulk_remove_tags Body: { ids: […], tags: [‘summer’, ‘sale’] }



31
32
33
34
35
36
37
38
# File 'app/controllers/concerns/spree/api/v3/bulk_operations.rb', line 31

def bulk_remove_tags
  authorize! :update, model_class

  Spree::Tags::BulkRemove.call(tag_names: Array(params[:tags]), records: bulk_collection)
  after_bulk_tags_change

  render json: bulk_tags_response
end