shopinvader / locomotive-shopinvader

LocomotiveCMS Plugin for Shopinvader
https://shopinvader.com
MIT License
12 stars 15 forks source link
shopinvader

ShopInvader

Build Status Maintainability Test Coverage

Installation

Wagon

Add this line to your Wagon site's Gemfile:

group :misc do
  gem 'shop_invader', path: '<local version of the ShopInvader gem>'
end

Very important. Use the very last commits of both Wagon and Steam.

And then execute:

$ bundle

Modify the config/site.yml to include Algolia's settings:

metafields:
  algolia:
    application_id: '<YOUR ALGOLIA APPLICATION ID>'
    api_key: '<YOUR ALGOLIA API KEY>'
    public_role: >
      [
        { "name": "category", "index": "category", "template_handle": "category" },
        { "name": "product", "index": "public_tax_inc", "template_handle": "product" }
      ]

Notes:

Locomotive Engine (Rails app)

Add this line to your Rails app's Gemfile:

gem 'shop_invader', path: '<local version of the ShopInvader gem>'

Inside your config/application.rb file, add the following lines.

module MyApp
  class Application < Rails::Application

    ...

    # Steam
    initializer 'station.steam', after: 'steam' do |app|
      Locomotive::Steam.configure do |config|
        ShopInvader.setup
      end
    end

    ...
  end
end

Usage

Templatized page

If you request the http://mysite.com/ page and no Locomotive page matches this url, then the gem will look for Algolia resources based on their url_key and redirect_url_key properties.

Liquid

List all the categories

{% for category in store.category %}
  <h2>{{ category.name }}</h2>
{% endfor %}

List the products and filter them

{% with_scope rating_value.gt: 4.7 %}
  {% for product in store.product %}
    <h2>{{ product.name }}</h2>
  {% endfor %}
{% endwith_scope %}

Paginate a list of products belonging to a category

{% with_scope categories_ids: [category.objectID] %}
  {% paginate store.product by 3 %}
    {% for product in paginate.collection %}
      <h2>{{ product.name }}</h2>
      <img src="https://github.com/shopinvader/locomotive-shopinvader/raw/v4.0.x/{{ product.images.first.medium }}" />
      {{ product.short_description }}
    {% endfor %}
  {% endpaginate %}
{% endwith_scope %}

TODO

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/did/shop_invader.

License

The gem is available as open source under the terms of the MIT License.