Create a Custom Shopping World Element with Custom Backend Ext JS Template Window

Hello,

I’ve created a custom shopping world element, and I need to create a custom backend window for it similar to the listing item grid, with the ability to create, edit and delete entries. The default configuration fields does not have such abilities, so can anyone show me how to create appropriate model, view, store controller system, so it will be opened as a window of shopping world element?

Please send me some example plugin or solution that you have.

What I need for Shopping World Element:

 

Here’s a tutorial how to create a custom shopping world element: Custom shopping world elements .

It also describes how to create your own backend view and contains an example plugin at the end.

Yes but it only shows how to create a simple basic view, I want to know how to create a listing grid with doctrine entries. Something like this example Backend Components - Basics , but for shopping world elements 

@simkli‍ can you provide details how to do that ?

Yes but it only shows how to create a simple basic view,

But the process is all the same. Do you have concrete issues with create a grid view? If yes, just show where you’re stuck and we’ll try to help you. But of course, we won’t code the whole thing for you.  Wink
Custom shopping world elements
This describes how to start with your own component. You just have to add the grid. It just a bare component, everything can be added to it (also a grid view).

If you want an example, just have a look at the ProductSlider shopping world element. As you can see it inherits from the same class as in the tutorial I linked aboved. (extend: ‚Shopware.apps.Emotion.view.components.Base‘,) They also add a grid view in order to add products to the slider (-> a similar task, like yours).

So follow the tutorial above. Then you have your own component which inherits from Shopware.apps.Emotion.view.components.Base. Then you can add a GridView and many more things as you like.

https://github.com/shopware/shopware/blob/5.4/themes/Backend/ExtJs/backend/emotion/view/components/article\_slider.js

Best regards

 

 

@simkli‍ Thanks for that, but the example above isn’t what I need. I need to add a greed view like the Shopware>Backend>Items>overview, where I will be able to create and delete entries. In order to start I just want to know, whether I need to do the same thing like here Backend Components - Basics  or there are differences. Should I call my main window in the initComponent method? and how the directory structure should be here?

@simkli‍ Thanks for that, but the example above isn’t what I need. I need to add a greed view like the Shopware>Backend>Items>overview, where I will be able to create and delete entries. I

As I said you need to create a shopping world base component view exactly as in the tutorial. But then you need to add a grid view. A tutorial how to create Ext.JS views can be found on the internet.

On the other hand I think there are a few mistakes in the way you want to solve this issue:

  1. I think it does not make any sense to create new models (of your doctrine entity) inside the shopping world element. It makes more sense to create a new backend application for editing your entities (CRUD) and then just select the entries inside your shopping world element. (like the ProductSlider element. You can add new products via the Product-Editor and assign them later in the ProductSlider shopping world element)

  2. If you really want a 1:1 relation (a editor inside the shopping world element) a doctrine entity makes no sense. You can save the data in the same table as the shopping world element => Just serialize the data as json string and use a standard shopping world field. You won’t want todo any join statements or select statements on the serialized data so there are no objections to do it like this.

Best regards

1 „Gefällt mir“

@simkli‍ I decided to use your first suggestion and I created by backend window with my new entries, but after it two new questions arosed. 

  1. How to perform CRUD operations on my entries before passing them to DB, i.e. how to change one of the values with php ?

  2. How to create a multi-item selector in my shopping world element with my entries? Should I use the pushItemToElements method?

Thanks in advance.

@davit_sargsyan schrieb:

  1. How to perform CRUD operations on my entries before passing them to DB, i.e. how to change one of the values with php ?

I guess you’re using the Shopware backend components. So your backend controller inherits from Shopware_Controllers_Backend_Application. So just have a look the the parent class. There’s a save/delete/getList/… function. So just do:

/* ... inside your backend controller ... */
public function save($data)
{
    // manipulate $data here
    return parent::save($data);
}
/*...*/

https://github.com/shopware/shopware/blob/5.4/engine/Shopware/Controllers/Backend/Application.php#L395 

@davit_sargsyan schrieb:

  1. How to create a multi-item selector in my shopping world element with my entries? Should I use the pushItemToElements method?

You need some further knowledge about ExtJS here. I know it’s difficult but I won’t help if you don’t learn it. You need to understand the MVC pattern of ExtJS. This doesn’t have to be related with Shopware. Just google for some tutorials (but remember that Shopware use’s ExtJS version 4.2.). If you understood the principle of models, stores and grids in ExtJS, it might be helpful to use the grid/search component from Shopware: https://github.com/shopware/shopware/blob/5.4/themes/Backend/ExtJs/backend/base/attribute/field/Shopware.form.field.Grid.js
As I said, you might not get a finalized working solution here. Wink
But of course we’re here to help you on your way there!

Best regards

2 „Gefällt mir“