Skip to content

Instantly share code, notes, and snippets.

@AnkurVyas-BTC
Created August 29, 2019 14:30
Show Gist options
  • Save AnkurVyas-BTC/d9bc828c9bffc6fe5ea46a6c214298a4 to your computer and use it in GitHub Desktop.
Save AnkurVyas-BTC/d9bc828c9bffc6fe5ea46a6c214298a4 to your computer and use it in GitHub Desktop.
paste below content at app/views/spree/admin/products/index.html.erb
# paste below content at app/views/spree/admin/products/index.html.erb
<% content_for :page_title do %>
<%= plural_resource_name(Spree::Product) %>
<% end %>
<% content_for :page_actions do %>
<%= button_link_to Spree.t(:new_product), new_object_url, { class: "btn-success", icon: 'add', id: 'admin_new_product' } %>
<% end if can?(:create, Spree::Product) %>
<% content_for :table_filter do %>
<div data-hook="admin_products_sidebar">
<%= search_form_for [:admin, @search] do |f| %>
<%- locals = {f: f} %>
<div data-hook="admin_products_index_search" class="row">
<div class="col-md-6">
<div class="form-group">
<%= f.label :name_cont, Spree.t(:name) %>
<%= f.text_field :name_cont, size: 15, class: "form-control js-quick-search-target" %>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<%= f.label :variants_including_master_sku_cont, Spree.t(:sku) %>
<%= f.text_field :variants_including_master_sku_cont, size: 15, class: "form-control" %>
</div>
</div>
<div class="col-md-12">
<div class="field checkbox">
<label>
<%= f.check_box :deleted_at_null, { checked: params[:q][:deleted_at_null] == '0' }, '0', '1' %>
<%= Spree.t(:show_deleted) %>
</label>
</div>
<div class="field checkbox">
<label>
<%= f.check_box :not_discontinued, { checked: params[:q][:not_discontinued] == '0' }, '0', '1' %>
<%= Spree.t(:show_discontinued ) %>
</label>
</div>
</div>
</div>
<div data-hook="admin_products_index_search_buttons" class="form-actions">
<%= button Spree.t(:search), 'search' %>
</div>
<% end %>
</div>
<% end %>
<%= render partial: 'spree/admin/shared/index_table_options', locals: { collection: @collection } %>
<% if @collection.any? %>
<table class="table" id="listing_products">
<thead>
<tr data-hook="admin_products_index_headers">
<th><%= Spree.t(:sku) %></th>
<th><%= Spree.t(:status) %></th>
<th colspan="2"><%= sort_link @search,:name, Spree.t(:name), { default_order: "desc" }, { title: 'admin_products_listing_name_title' } %></th>
<th class="text-center">
<%= sort_link @search, :master_default_price_amount, Spree.t(:master_price), {}, { title: 'admin_products_listing_price_title' } %>
</th>
<% if current_spree_user.respond_to?(:has_spree_role?) && current_spree_user.has_spree_role?(:admin) %>
<th><%= Spree.t(:vendor_name) %>
<% end %>
<th data-hook="admin_products_index_header_actions" class="actions"></th>
</tr>
</thead>
<tbody>
<% @collection.each do |product| %>
<tr <%== "style='color: red;'" if product.deleted? %> id="<%= spree_dom_id product %>" data-hook="admin_products_index_rows" class="<%= cycle('odd', 'even') %>">
<td class="sku"><%= product.sku rescue '' %></td>
<td class="status"><%= available_status(product) %> </td>
<td class="image"><%= mini_image product %></td>
<td><%= link_to product.try(:name), edit_admin_product_path(product) %></td>
<td class="text-center"><%= product.display_price.to_html rescue '' %></td>
<% if current_spree_user.respond_to?(:has_spree_role?) && current_spree_user.has_spree_role?(:admin) %>
<td><%= product.vendor.try(:name) %>
<% end %>
<td class="actions actions-3 text-right" data-hook="admin_products_index_row_actions">
<%= link_to_edit product, no_text: true, class: 'edit' if can?(:edit, product) && !product.deleted? %>
<%= link_to_clone product, no_text: true, class: 'clone' if can?(:clone, product) %>
<%= link_to_delete product, no_text: true if can?(:delete, product) && !product.deleted? %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<div class="alert alert-info no-objects-found">
<%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Product)) %>,
<%= link_to Spree.t(:add_one), new_object_url %>!
</div>
<% end %>
<%= render partial: 'spree/admin/shared/index_table_options', locals: { collection: @collection } %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment