def admin_index
      return if !user_is_allowed('products', 'view')
      
      # Temporary patch for vendor name sorting; Fix this
      params[:sort] = 'store_vendors.name' if params[:sort] == 'vendor'
      
      @gen = Caboose::PageBarGenerator.new(params, {
        'vendor_name'  => '',
        'search_like'  => '', 
        'price'        => params[:filters] && params[:filters][:missing_prices] ? 0 : ''
      }, {
        'model'          => 'CabooseStore::Product',
        'sort'           => 'title',
        'desc'           => false,
        'base_url'       => '/admin/products',
        'items_per_page' => 25,
        'use_url_params' => false,
        
        'abbreviations' => {
          'search_like' => 'store_products.title_concat_vendor_name_like'
        },
        
        'includes' => {
          'vendor_name'  => [ 'vendor'         , 'name'  ],
          'price'        => [ 'variants'       , 'price' ]
        }
      })
      
      # Make a copy of all the items; so it can be filtered more
      @all_products = @gen.all_records
      
      # Apply any extra filters
      if params[:filters]
        @all_products = @all_products.includes(:product_images).where('store_product_images.id IS NULL') if params[:filters][:missing_images]
        @all_products = @all_products.where('vendor_id IS NULL') if params[:filters][:no_vendor]
      end
      
      # Get the correct page of the results
      @products = @all_products.limit(@gen.limit).offset(@gen.offset)
      
      render :layout => 'caboose/admin'
    end
def admin_index
      return if !user_is_allowed('products', 'view')
      
      # Temporary patch for vendor name sorting; Fix this
      params[:sort] = 'store_vendors.name' if params[:sort] == 'vendor'
      
      @gen = Caboose::PageBarGenerator.new(params, {
        'vendor_name'  => '',
        'search_like'  => '', 
        'price'        => params[:filters] && params[:filters][:missing_prices] ? 0 : ''
      }, {
        'model'          => 'CabooseStore::Product',
        'sort'           => 'title',
        'desc'           => false,
        'base_url'       => '/admin/products',
        'items_per_page' => 25,
        'use_url_params' => false,
        
        'abbreviations' => {
          'search_like' => 'store_products.title_concat_vendor_name_like'
        },
        
        'includes' => {
          'vendor_name'  => [ 'vendor'         , 'name'  ],
          'price'        => [ 'variants'       , 'price' ]
        }
      })
      
      # Make a copy of all the items; so it can be filtered more
      @all_products = @gen.all_records
      
      # Apply any extra filters
      if params[:filters]
        @all_products = @all_products.includes(:product_images).where('store_product_images.id IS NULL') if params[:filters][:missing_images]
        @all_products = @all_products.where('vendor_id IS NULL') if params[:filters][:no_vendor]
      end
      
      # Get the correct page of the results
      @products = @all_products.limit(@gen.limit).offset(@gen.offset)
      
      render :layout => 'caboose/admin'
    end
GET /admin/products