简体   繁体   English

如何定制狂欢商务?

[英]How to customize spree commerce?

I have installed Spree on a Windows machine, added sample data and accessed the admin. 我在Windows机器上安装了Spree,添加了示例数据并访问了管理员。

But now what? 但现在呢?

How do I create a new page or URL? 如何创建新页面或URL?

I don't find any controllers or files in my rails project folder. 我在rails项目文件夹中找不到任何控制器或文件。 Do I have to change the location where Spree is downloaded? 我是否必须更改Spree下载的位置?

But now what? 但现在呢?

Spree is "developer friendly", which means you'll need to use the developers mindset as you're building your application. Spree是“开发人员友好的”,这意味着您在构建应用程序时需要使用开发人员的思维模式。 To create a new page, you'll have to follow the Rails-Way. 要创建新页面,您必须遵循Rails-Way。 If you run bin/rake routes you'll see all of the routes generated for you. 如果您运行bin/rake routes您将看到为您生成的所有路线。

To generate a path in Spree, you need to call something like spree.root_path . 要在Spree中生成路径,您需要调用spree.root_path类的spree.root_path If you have the same path named in your main application, then you'll have to call main_app.root_path . 如果在主应用程序中具有相同的路径,则必须调用main_app.root_path This way rails knows you want your own root path, not Spree's. 这种方式rails知道你想要自己的根路径,而不是Spree的。

For some best practices, you should checkout this blog post: http://blog.benmorgan.io/post/102924399166/customizing-spree-some-best-practices . 对于一些最佳实践,您应该查看此博客文章: http//blog.benmorgan.io/post/102924399166/customizing-spree-some-best-practices (My blog also has a lot of Spree content in it.) (我的博客里面也有很多Spree内容。)

I don't find any controllers or files in my rails project folder. 我在rails项目文件夹中找不到任何控制器或文件。 Do I have to modify the location where the spree is downloaded? 我是否必须修改下载狂欢的位置?

Bundler installs Spree which is then stored via rvm or rbenv in its appropriate location. Bundler安装Spree,然后通过rvm或rbenv将其存储在适当的位置。 All you have to do is add: 您所要做的就是添加:

gem 'spree', github: 'spree', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'

Or you could use Solidus which I'm now using instead of Spree; 或者你可以使用我现在使用的Solidus而不是Spree; currently moving all active Spree projects over to this one. 目前正在将所有活跃的Spree项目移至此项目。

What I recommend: 我推荐的是什么:

  • Don't use the Spree Frontend. 不要使用狂欢前端。 Understanding how the models work should be enough for you to get started. 了解模型的工作原理应该足以让您开始使用。 Making a new Spree::Order object should be quite simple. 制作一个新的Spree::Order对象应该非常简单。 Then its just Spree::Order.next! 然后它只是Spree::Order.next! and you can start checking things out. 你可以开始检查。 To add products to an order, you just order.contents.add Spree::Variant.first, 1 and you've got a new line item in the DB. 要将产品添加到订单,您只需order.contents.add Spree::Variant.first, 1并且您在数据库中有一个新的订单项。
  • Read the source code. 阅读源代码。 Spree is, honestly, ~4 rails applications. 说实话,Spree是~4个rails应用程序。 1 for the models (core), 1 for the storefront (frontend), 1 for the admin (backend), and 1 for the API. 1表示模型(核心),1表示店面(前端),1表示管理员(后端),1表示API。
  • Use the V2 API. 使用V2 API。 Spree 4 is aiming to have a new, revamped API that follows the JSON API spec and fully Ember compatible. Spree 4的目标是拥有一个新的,经过改进的API,它遵循JSON API规范并完全兼容Ember。 For more information, please see the JSON API spec . 有关更多信息,请参阅JSON API规范 The Spree V2 API is located here . Spree V2 API位于此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM