Sha256: a08315c4eadc73a6f10b7b142c6463b9a5ef0ada34a3838392e5d28b89eeeaa7

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

json.cache! [category, current_store] do
  json.type 'categories'
  json.id category.id

  json.attributes do
    json.extract! category, :name, :created_at, :updated_at, :include_in_menu, :is_active, :magento_id, :position, :url_key
  end

  json.relationships do
    if category.parent
      json.parent do
        json.data do
          json.type 'categories'
          json.id category.parent.id
        end
      end
    end

    if category.children.any?
      json.children do
        json.data do
          json.array! category.children do |child|
            json.type 'categories'
            json.id child.id
          end
        end
      end
    end

    if category.products(current_store).any?
      json.products do
        json.data do
          json.array! category.products do |product|
            json.type 'products'
            json.id product.id
          end
        end
      end
    end

    if category.stores.any?
      json.stores do
        json.data do
          json.array! category.stores do |store|
            json.type 'stores'
            json.id store.id
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemgento-2.8.0 app/views/gemgento/api/v1/categories/_category.json.jbuilder