Sha256: 5392db5da2f0e3928e69be37c034ed66612c7fa62ed3d50b9a9c549f6bfb1061

Contents?: true

Size: 1.7 KB

Versions: 2

Compression:

Stored size: 1.7 KB

Contents

module RoutesHelper
  def seo_product_type_path(*args)
    forgeos_commerce.product_type_path(extract_product_type_options(args)) rescue '/'
  end

  def seo_product_type_url(*args)
    forgeos_commerce.product_type_url(extract_product_type_options(args)) rescue '/'
  end

  def extract_product_type_options(args)
    options = args.dup.extract_options!
    object = args.first
    if object.kind_of?(ProductType)
      return options.merge(:product_type_url => object.url )
    else
      return args
    end
  end

  def seo_product_path(*args)
    super(extract_product_options(args)) rescue '/'
  end

  def seo_product_url(*args)
    super(extract_product_options(args))
  end

  def extract_product_options(args)
    options = args.dup.extract_options!
    object = args.first
    if object.kind_of?(Product)
      product_type_url = (object.product_type.nil?) ? 'articles' : object.product_type.url
      return options.merge( :url => object.url, :product_type => product_type_url )
    else
      return args
    end
  end

  def product_category_path(*args)
    forgeos_commerce.product_category_path(extract_product_category_options(args))
  end

  def product_category_url(*args)
    forgeos_commerce.product_category_url(extract_product_category_options(args))
  end

  def extract_product_category_options(args)
    options = args.dup.extract_options!
    object = args.first
    if object.kind_of?(ProductCategory)
      return options.merge(:id => nil, :category_name => object.name)
    else
      return args
    end
  end

  def seo_product_type_product_category_path(product_type,product_category)
    product_type_product_category_path(:product_type_url=>product_type.url,:category_url=>product_category.url)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
forgeos_commerce-1.9.1.rc1 app/helpers/routes_helper.rb
forgeos_commerce-1.9.0 app/helpers/routes_helper.rb