Giter Site home page Giter Site logo

solidusio-contrib / solidus_related_products Goto Github PK

View Code? Open in Web Editor NEW
33.0 15.0 45.0 445 KB

🍴 Related products extension for Solidus

License: BSD 3-Clause "New" or "Revised" License

Ruby 83.57% JavaScript 0.81% HTML 11.87% CoffeeScript 1.91% Shell 1.84%
solidus coupons discount ecommerce ecommerce-platform

solidus_related_products's Introduction

Solidus Related Products

CircleCI codecov

This extension provides a generic way for you to define different types of relationships between your products, by defining a RelationType for each type of relationship you'd like to maintain.

You can manage RelationTypes via the admin configuration menu, and you can maintain product relationships via Related Products tab on the edit product UI or via Related Products section on the edit variant UI.

Possible uses

  • Accessories
  • Cross Sells
  • Up Sells
  • Compatible Products
  • Replacement Products
  • Warranty & Support Products

Installation

Add solidus_related_products to your Gemfile:

gem 'solidus_related_products'

To get the latest changes, we suggest using the Github version:

gem 'solidus_related_products', github: 'solidusio-contrib/solidus_related_products'

Bundle your dependencies and run the installation generator:

bin/rails generate solidus_related_products:install

Usage

Relation Types

You can create four different RelationTypes:

Applies From Applies To Bi-Directional available
Spree::Product Spree::Product Yes
Spree::Product Spree::Variant No
Spree::Variant Spree::Product No
Spree::Variant Spree::Variant Yes

Bi-Directional You can optionally set the bi-directional flag (if available) to automatically create the inverse relation, the flag can be set only on the type creation and can't be changed later, this is needed to avoid unpredictable behavior in the case that the flag is changed. Keep in mind that if you remove one side of the relation, also the other hand will be removed, the same way happens for the description. The discounts are disabled for Bi-Directional by setting the discount amount to be only zero, this is needed because it's not clear how this feature should behave in this case.

The following examples use a Spree::Product -> Spree::Product relation type.

When you create a RelationType you can access that set of related products by referencing the relation_type name, see below for an example:

rt = Spree::RelationType.create(name: 'Accessories', applies_from: 'Spree::Product', applies_to: 'Spree::Product')
 => #<Spree::RelationType id: 4, name: "Accessories" ...>
product = Spree::Product.last
 => #<Spree::Product id: 1060500592 ...>
product.accessories
 => []

Since respond_to? will not work in this case, you can test whether a relation_type method exists with has_related_products?(method):

product.has_related_products?('accessories')
# => true

if product.has_related_products?('accessories')
  # Display an accessories box..
end

You can access all related products regardless of RelationType by:

product.relations
 => []

Discounts You can optionally specify a discount amount to be applied if a customer purchases both products.

Note: In order for the coupon to be automatically applied, you must create a promotion leaving the code value empty, and adding an Action of type : RelatedProductDiscount (blank codes are required for coupons to be automatically applied).

Development

Testing the extension

First bundle your dependencies, then run bin/rake. bin/rake will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using bin/rake extension:test_app.

bin/rake

To run Rubocop static code analysis run

bundle exec rubocop

When testing your application's integration with this extension you may use its factories. Simply add this require statement to your spec_helper:

require 'solidus_related_products/factories'

Running the sandbox

To run this extension in a sandboxed Solidus application, you can run bin/sandbox. The path for the sandbox app is ./sandbox and bin/rails will forward any Rails commands to sandbox/bin/rails.

Here's an example:

$ bin/rails server
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
* Listening on tcp://127.0.0.1:3000
Use Ctrl-C to stop

Updating the changelog

Before and after releases the changelog should be updated to reflect the up-to-date status of the project:

bin/rake changelog
git add CHANGELOG.md
git commit -m "Update the changelog"

Releasing new versions

Please refer to the dedicated page on Solidus wiki.

License

Copyright (c) 2010-2015 Brian Quinn and contributors, released under the New BSD License

solidus_related_products's People

Contributors

aitbw avatar ajjahn avatar aldesantis avatar alepore avatar alessiorocco avatar bdq avatar benjaminwil avatar blocknotes avatar brchristian avatar chischaschos avatar christianrimondi avatar citrus avatar danielepalombo avatar dependabot-preview[bot] avatar dividedharmony avatar florianguenther avatar futhr avatar graygilmore avatar gudata avatar jarednorman avatar jdutil avatar jhawthorn avatar jsqu99 avatar kennyadsl avatar lbrapid avatar nishant-cyro avatar patrickmcelwee avatar radar avatar schof avatar vassalloandrea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

solidus_related_products's Issues

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'solidus_extension_dev_tools' in git://github.com/solidusio-contrib/solidus_extension_dev_tools.git (at master@27a4e38).
The source does not contain any versions of 'solidus_extension_dev_tools'

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Relation empty on console but visible on admin

using solidud_related_products master branch.
Having this related products on the backend admin
image

when consulting on the rails console find out that the relation is empty

image

But checking the table directly there seem to be related products, but related to a different ID.

image

relatable_id should be 1, which is the product id, not 2 - where does this 2 comes from? how is it actually working on the admin?

Migrations do not specify Rails release the migration was written for

Upon fresh install during the upgrade of my solidus store I found that the generated migration files do not work because the migration does not specify the rails version it was written for.

For me it worked after specifying 4.2 like so:

class AddPositionToSpreeRelations < ActiveRecord::Migration[4.2]
Instead of:

class AddPositionToSpreeRelations < ActiveRecord::Migration

undefined method `empty?' for nil:NilClass

At initial installation, everything was working fine. After a month of using it, there is an issue when viewing Admin - Products - Related Products Tab:

ActionView::Template::Error (undefined method `empty?' for nil:NilClass):

  • <%= csrf_meta_tag %>

  • <% if @relation_types.empty? %>

  • <%= Spree.t(:no_relation_types) %>

Not sure what is the reason. After Googling for the answer, the same issue happened for SpreeCommerce related product extension and the solution is to roll back the older code due to Scoping Issue.

See here: spree-contrib/spree_related_products#127

and here: spree-contrib/spree_related_products#149

So my solution is to use back old code and fixed the issue. Thanks.

Autoloading deprecation warning

Hello, I'm trying to install this gem onto my project and I get this warning:
Warning
which I believe is causing the error on the last few lines because it unloads that constant
I have tried wrapping the initializer code in a the callback as stated in the warning to the same result, I have tried a few more things like requiring the gem in the project's initializers/spree.rb but the result is still the same
Any help would be appreciated

Backend selector disappeared after PR merged

After #29 was merged, our backend view went from this:

screen shot 2018-06-20 at 9 59 32 pm

To this:

screen shot 2018-06-20 at 10 00 04 pm

Note that the selector field does not display, so we can no longer add relations between products.

Are we missing something else we need to do other than pulling these commits? I don’t know enough about #29 to know offhand why this functionality would be broken.

(We’re running Solidus 2.4 if that’s helpful.)

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "solidus_core":
  In Gemfile:
    solidus was resolved to 3.1.0.alpha, which depends on
      solidus_core (= 3.1.0.alpha)

    solidus_related_products was resolved to 0.0.1, which depends on
      solidus_core (>= 2.0.0, < 3)

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "codecov":
  In Gemfile:
    solidus_dev_support was resolved to 1.5.0, which depends on
      codecov (~> 0.1.16)

Could not find gem 'codecov (~> 0.1.16)', which is required by gem 'solidus_dev_support', in any of the sources.

Bundler could not find compatible versions for gem "rubocop":
  In Gemfile:
    solidus_dev_support was resolved to 1.5.0, which depends on
      rubocop-performance (~> 1.5) was resolved to 1.6.1, which depends on
        rubocop (>= 0.71.0)

    solidus_dev_support was resolved to 1.5.0, which depends on
      rubocop-rspec (~> 1.36) was resolved to 1.41.0, which depends on
        rubocop (>= 0.68.1)

    solidus_dev_support was resolved to 1.5.0, which depends on
      rubocop (~> 0.76.0)

Bundler could not find compatible versions for gem "solidus_backend":
  In Gemfile:
    solidus was resolved to 2.11.0.alpha, which depends on
      solidus_backend (= 2.11.0.alpha)

    solidus_related_products was resolved to 0.0.1, which depends on
      solidus_backend (>= 1.0, < 3)

Bundler could not find compatible versions for gem "solidus_core":
  In Gemfile:
    solidus was resolved to 2.11.0.alpha, which depends on
      solidus_core (= 2.11.0.alpha)

    solidus_auth_devise was resolved to 2.4.0, which depends on
      solidus_core (>= 2.6, < 3)

    solidus_dev_support was resolved to 1.5.0, which depends on
      solidus_core (>= 2.0, < 3)

    solidus_related_products was resolved to 0.0.1, which depends on
      solidus_core (>= 1.0, < 3)

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'solidus_extension_dev_tools' in git://github.com/solidusio-contrib/solidus_extension_dev_tools.git (at master@fe57891).
The source does not contain any versions of 'solidus_extension_dev_tools'

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'solidus_extension_dev_tools' in git://github.com/solidusio-contrib/solidus_extension_dev_tools.git (at master@8140198).
The source does not contain any versions of 'solidus_extension_dev_tools'

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Not possible to configure relations between variants

I tried to configure a relation between a master product "Rails Jr Spaghetti" to a variant product "RoR t-ringer shirt (in blue)". See screenshot. It works but the "related_to" product is the master product, not the variant (in blue).
Il tried also to define a relation_type "Spree:variant" instead of "Spree:product", but it does not appear in the list of available relation_types when defining the relation.
I wonder if this extension works only with master products, but not variants.

related products with variant

has_related_products? always returns true

product.has_related_products?('accessories') always returns true as soon as the relation type accessories has been created. I doesn't check that there are products associated to it. I'm using solidus 2.6.0.

Support for solidus_backend 3?

Currently receiving this error.

  In Gemfile:
    solidus_backend (~> 3.2)

    solidus_related_products (~> 1.1.0) was resolved to 1.1.0, which depends on
      solidus_backend (< 3, >= 1.0)

Is there a timeline for supporting solidus_backend 3? Not sure if this is because of a breaking change or we just need to bump the version?

i18n Pluralization issue

views/spree/admin/relation_types/index.html.erb:49
<%= I18n.t('spree.no_resource_found', resource: Spree::RelationType.model_name.human(count: :many)) %>,

Locale :fr

image

Migrations files needs to inherit from ActiveRecord::Migration[RAILS_VERSION]

When running bundle exec rails g solidus_related_products:install

I had the following error:

StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class CreateRelationTypes < ActiveRecord::Migration[4.2]

I had to add the my current rails app version to all the generated migration files like this for example:

class CreateRelationTypes < ActiveRecord::Migration[5.1]

See https://github.com/solidusio/solidus/wiki/Testing-extensions-against-multiple-Solidus-versions#migrations

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'solidus_extension_dev_tools' in git://github.com/solidusio-contrib/solidus_extension_dev_tools.git (at master@5b33a25).
The source does not contain any versions of 'solidus_extension_dev_tools'

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Cannot create new relations in new Solidus 2.10 store

I have been having some issues with this extension recently, and to try to reproduce some of them, I created a brand new Solidus store from scratch with all the default config:

ruby 2.7.1
Rails 2.6.0
Solidus 2.10.2

I then installed all of the railties migrations, etc.

To my surprise, I could not get this extension to work out of the box.

For example, if I create a relation called Foo, I cannot create a new instance of this relation between products. The product selector does not appear:

Screen Shot 2020-08-01 at 11 22 09 AM

Note that the Name or SKU field is blank. Inspecting the DOM shows a hidden field there. I’m assuming this is supposed to be replaced with a JS autocomplete interface, but nothing is there.

I can reproduce this behavior in the latest versions of both Safari and Chrome.

If I try to click the Add button anyway, I then get the following error screen:

Screen Shot 2020-08-01 at 11 26 19 AM

So it seems to me there are actually two related issues here. One is that the selector is not displaying, and two is that the error case of no product being present is not getting handled gracefully.

Would love help in figuring out what might be going on here!

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'solidus_extension_dev_tools' in git://github.com/solidusio-contrib/solidus_extension_dev_tools.git (at master@7c47ece).
The source does not contain any versions of 'solidus_extension_dev_tools'

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'solidus_extension_dev_tools' in git://github.com/solidusio-contrib/solidus_extension_dev_tools.git (at master@96208b9).
The source does not contain any versions of 'solidus_extension_dev_tools'

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Can't customize this gem with `rails g migration`

Hi,

I need to customize this gem to match with my project.

I i got error when trying this command rails g migration. The error is:

railties-5.0.0.1/lib/rails/engine/commands_tasks.rb:78:in require': cannot load such file -- /home/huy/Developments/gems/solidus_related_products/lib/spree_related_products/engine (LoadError) from /home/huy/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/engine/commands_tasks.rb:78:in load_generators'
from /home/huy/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/engine/commands_tasks.rb:72:in generate_or_destroy' from /home/huy/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/engine/commands_tasks.rb:44:in generate'
from /home/huy/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/engine/commands_tasks.rb:37:in run_command!' from /home/huy/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/engine/commands.rb:14:in <top (required)>'
from bin/rails:7:in require' from bin/rails:7:in

'

Please help me about that.

Thanks,
Huy

New rubygems release?

I notice that the last rubygems release of this extension was from 2016, and a lot has changed in the world of Solidus since then.

In fact, I cannot even install the most recent rubygems version!

If I create a brand new Ruby (2.6.6), Rails (5.1.7), Solidus (2.10.2), and solidus_related_products (1.1.0) application, I can’t run the migrations, as I get:

StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class CreateRelationTypes < ActiveRecord::Migration[4.2]
/[ruby_path]/ruby/2.6.6/gems/activerecord-5.1.7/lib/active_record/migration.rb:525:in `inherited'
/[app_path]/db/migrate/20200801224231_create_relation_types.solidus_related_products.rb:2:in `<top (required)>'

I suspect this can be fixed by simply cutting a newer version of the gem!

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "codecov":
  In Gemfile:
    solidus_dev_support was resolved to 1.5.0, which depends on
      codecov (~> 0.1.16)

Could not find gem 'codecov (~> 0.1.16)', which is required by gem 'solidus_dev_support', in any of the sources.

Bundler could not find compatible versions for gem "rubocop":
  In Gemfile:
    solidus_dev_support was resolved to 1.5.0, which depends on
      rubocop-rspec (~> 1.36) was resolved to 1.41.0, which depends on
        rubocop (>= 0.68.1)

    solidus_dev_support was resolved to 1.5.0, which depends on
      rubocop (~> 0.76.0)

Bundler could not find compatible versions for gem "solidus_backend":
  In Gemfile:
    solidus was resolved to 2.11.0.alpha, which depends on
      solidus_backend (= 2.11.0.alpha)

    solidus_related_products was resolved to 0.0.1, which depends on
      solidus_backend (>= 1.0, < 3)

Bundler could not find compatible versions for gem "solidus_core":
  In Gemfile:
    solidus was resolved to 2.11.0.alpha, which depends on
      solidus_core (= 2.11.0.alpha)

    solidus_auth_devise was resolved to 2.4.0, which depends on
      solidus_core (>= 2.6, < 3)

    solidus_dev_support was resolved to 1.5.0, which depends on
      solidus_core (>= 2.0, < 3)

    solidus_related_products was resolved to 0.0.1, which depends on
      solidus_core (>= 1.0, < 3)

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'solidus_extension_dev_tools' in git://github.com/solidusio-contrib/solidus_extension_dev_tools.git (at master@042f10b).
The source does not contain any versions of 'solidus_extension_dev_tools'

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Encountered 404 when accessing /api/products/:id/related(.:format)

After this gem is installed, there is such an entry in the rake routs result:

related_api_product GET  /api/products/:id/related(.:format)  spree/api/products#related {:format=>"json"}

However, there is no such an action called related in Spree::Api::ProductsController. Thus, this URL always responses 404.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'solidus_extension_dev_tools' in git://github.com/solidusio-contrib/solidus_extension_dev_tools.git (at master@d358b9a).
The source does not contain any versions of 'solidus_extension_dev_tools'

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Problem when customizing frontend product show.html

Using solidus1.2, I tried to customize frontend product page with related_products.
I get the following error:
Showing /Users/hapax94/sld/testum2/app/views/spree/products/show.html.erb where line #1 raised:
undefined local variable or method `current_pricing_options' for #<#Class:0x007fba4da55ed8:0x007fba43477c78>

When I removed the first instrcution <% cache [I18n.locale, current_pricing_options, @Product] do %>, it works.

Relationships are not destroyed when a product is removed

We removed a few products and discovered some errors caused by nil related_to items. I believe the relationships from a product should be removed together with the parent record.

Is there any particular reason we don't have this on the Relation model?
If not, I can provide a PR to fix it.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "solidus_backend":
  In Gemfile:
    solidus was resolved to 3.1.0.alpha, which depends on
      solidus_backend (= 3.1.0.alpha)

    solidus_related_products was resolved to 0.0.1, which depends on
      solidus_backend (>= 2.0.0, < 3)

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Tests fail under Ruby 2.1

The Travis test suite is checking both Ruby 2.1 and 2.2 but one of the gems requires 2.2:

Gem::InstallError: listen requires Ruby version ~> 2.2.

Travis doesn't finish bundling and therefor none of the tests actually run.

We need to either:

  1. Stop caring about Ruby 2.1, or
  2. See if we can use a version of listen that allows 2.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.