django-shop icon indicating copy to clipboard operation
django-shop copied to clipboard

Adding page as CMSPageAsCategory in admin

Open vivazzi opened this issue 8 years ago • 3 comments

Now if we add page in product change: cms_pages then we create page but without assigned application "Product List". And we get a mistake about incorrect value for cms_pages, because new page hasn't app "Product List". This is one moment. Other moment is difficult to understand how site administrator can add new page category. In fact, he should:

  1. Create page;
  2. Add app "Product List" to created page;
  3. Add Catalog List View to page
  4. Publish page

For inexperienced administrator is difficult. And I think that we can optimize this process to run commands before. And I do It in custom page in admin:

page = create_page(title=title, slug=get_unique_slug(title), template='default.html', language='ru',
                   parent='shop', apphook='ProductsListApp', in_navigation=True)
page.save()

placeholder = page.placeholders.get(slot='content')
add_plugin(placeholder, 'ShopCatalogPlugin', 'ru')

page.publish('ru')

Then I can see created page and added other plugins if I need.

Certainly, my code is custom for me. For example, we should take care about create_page(..., parent=''). Usially, I have next page structure:

  • main
  • shop | - jeans | - t-shirts | - socks
  • contacts

And page 'shop' is always parent. As resolve, we can create other app, say, 'shop' and find it in code. But if we want to have two or more shops in one site than we get problem to identify needed shop. Maybe I mistake that I think that we will want to have two shops in one site... And other problem is page.placeholders.get(slot='content'). My slot is 'content' - is custom.

As variant, I see the native form: create_page with choice of slots if we have some slots. Maybe we can add constant in settings like that: CATALOG_LIST_PLACEHOLDER = 'my_placeholder'

I think you understand my idea. Unfortunately, I cannot give pull request, because django shop mechanism is still difficult for me..

vivazzi avatar Jun 06 '16 14:06 vivazzi

Sounds like a good idea to me. We need to think a little about how to implement this in a clean fashion.

rfleschenberg avatar Jun 06 '16 15:06 rfleschenberg

It's great! I'm glad to listen that!

vivazzi avatar Jun 06 '16 15:06 vivazzi

In version 0.9.2 I've added a generic "Commodity". This is a "Product" with almost no properties. It's intended to be used as a kind of CMS-page which can sell products. There I've added a wizard, in order to add products via the frontend, instead of the backend. This wizard then adds the product (or commodity) to the appropriate CMS page. You could easily use that wizard for your own types of products.

jrief avatar Jun 14 '16 20:06 jrief