What is Solidus?

Solidus is a complete open source e-commerce solution built with Ruby on Rails Development Framework forked from Spree 2.4.

You can know more about solidus at https://github.com/solidusio/solidus and spree at https://en.wikipedia.org/wiki/Spree_Commerce and https://spreecommerce.org

Solidus provides great deal of built-in functionalities. Because of the different client requirements sometimes we need to customise solidus.

Here is the description of how to install solidus and write extension in it.

Solidus Installation

Create new rails project. PostgreSQL database was used here, you can choose as per your requirements.
rails new solidus-example - database=postgresql
Add the following to gemfile of your rails application.
gem 'solidus'

gem ‘solidus_auth_devise’
As we have added the gems to the gemfile we need to update bundle.
$ bundle install
In case you encounter nokogiri error you can refer to this link: http://stackoverflow.com/a/20006530

Add the necessary configurations in the config/database.yml like username password.

Create the database.
$ bundle exec rake db:create
After this you need to install spree.
$ bundle exec rails g spree:install
It will ask for email and password (enter you custom) else go with the default ones.
$ bundle exec rake railties:install:migrations
Now your solidus application is ready to be used. Now you can start your rails server and start exploring the feature and options available.

Creating Solidus Extension

To know more about extensions and how to write one in Spree refer http://guides.spreecommerce.org/developer/extensions_tutorial.html

Unlike Spree, it is not pretty straight forward in soldius, we need to add gem to our file.
gem 'solidus_cmd'
And then we need to update bundle.
$ bundle install
Now we need to move one directory back from the folder of our rails application and run following commands in the console.
$ cd.. # To move one directory back in Linux systems

$ gem install solidus_cmd

$ solidus extension my_extension

$ cd solidus_my_extension

$ bundle install
Make sure you are now in solidus_my_extension folder. All the customisation that we need to do in solidus we must do it in this folder without touching the solidus-master code.

Now let’s add new column named as sale_price in the Spree::Variant model.
bundle exec rails g migration add_sale_price_to_spree_variants sale_price:decimal
NOTE: Don’t run rake db:migrate in this folder.

First we need to update the. gemspec file of this extension. We need to add author, description, summary and email in. gemspec file. Below is sample.

Now move to the solidus-example folder.

Now we need to include our created extension in our main rails application. Add the following to the gemfile.
gem 'solidus_my_extension', :path => '../solidus_my_extension'
Then run following commands.
$ bundle install
$ rails g solidus_my_extension:install

It will prompt you run the migrations type ‘Y’ and after the successful migration completion you will have sale_price added.

For the customisation of the Views and Controller you can follow the steps as described after http://guides.spreecommerce.org/developer/extensions_tutorial.html#adding-a-controller-action-to-homecontroller

# NOTE: after every change in the extension we need to restart solidus-example server

That’s it!

You can get more information about solidus and spree from the links in the references section.

Thank you for reading!

Click here for more details…

At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.

We also specialize in Python, RPA, AI, Django, JavaScript and ReactJS.

Consulting is free – let us help you grow!


References:

solidusio/solidus
solidus – Solidus, Rails eCommerce System

github.com

solidusio/solidus_cmd
Contribute to solidus_cmd development by creating an account on GitHub.

github.com

Extensions – Developer Guide | Spree Commerce
This tutorial continues where we left off in the Getting Started tutorial. Now that we have a basic Spree store up and…

guides.spreecommerce.org

Introduction – Solidus Guides
Hosted on Github. The Solidus Guides is based on from DOCter from CFPB.

ashkamel.com