Sha256: 74dfd9e0e45ffeffb8b81ae7cc8c4e4635bed8cf62a17555a93dac4706d7a487

Contents?: true

Size: 657 Bytes

Versions: 1

Compression:

Stored size: 657 Bytes

Contents

module Gemgento
  module ProductsHelper

    def next_product
      @next_product ||= begin
        current_index = current_category_products.index(@product)
        current_index < current_category_products.length ? current_category_products[current_index + 1] : nil
      end
    end

    def previous_product
      @previous_product ||= begin
        current_index = current_category_products.index(@product)
        current_index > 0 ? current_category_products[current_index - 1] : nil
      end
    end

    def current_category_products
      @current_category_product_ids ||= @current_category.products.active.catalog_visible.to_a
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemgento-2.8.0 app/helpers/gemgento/products_helper.rb