| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Adding form to new order details tab | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Adding form to new order details tab
I need to create following module on admin page:
1. It must add new table OrderItemActivations to DB, as I understand if my module located in XLite\Module\Romas\ProductActivation I must add ProductActivation.php(with table schema) to XLite\Module\Romas\ProductActivation\Model folder, am I right? Here is what I write in XLite\Module\Romas\ProductActivation\Model\OrderIt emActivation.php: PHP Code:
2. It must add a new tab to order details, I can make it following instructions http://kb.x-cart.com/display/XDD/Adding+tabs, but instead of decorating \XLite\Controller\Admin\Product I must decorate \XLite\Controller\Admin\Order class. But also tell me please how to create viewer class for this tab(where must it be located and how to connect this viewer class to template that is used for new tab)? 3. In created tab it must add a form which adds new record to ProductActivation table, how can I create such form, where should be a handler of this form and how should it look? Please clarify
__________________
xcart5 |
|||||||
#2
|
|||||||
|
|||||||
Re: Adding form to new order details tab
Also I need to add OneToMany relation from OrderItem to OrderItemActivation entity, as I understand I must create decorator
PHP Code:
Please tell me what should I write in @OneToMany section: how can I set what column in OrderItems table to add?
__________________
xcart5 |
|||||||
#3
|
|||||||||
|
|||||||||
Re: Adding form to new order details tab
Quote:
Although the class name can be anything you want, it is recommended to name it as the table name. So, it makes sense to name the class OrderItemActivation instead of ProductActivation (so the file will be OrderItemActivation.php, not ProductActivation.php). The path can be any too, but it is recommended to keep model entity classes inside the Model subdirectory. You can check this article on creating custom models: http://kb.x-cart.com/display/XDD/Understanding+Models Quote:
You have missed the docblock with the class description. It should be something like this: PHP Code:
And you need the \XLite\Module\Romas\ProductActivation\Model\Repo\O rderItemActivation class too (however, it can be an empty class extending \XLite\Model\Repo\Base\I18n). Quote:
Please see how the two standard tabs ('info' and 'invoice') are added in the \XLite\Controller\Admin\Order controller class. You should decorate this class, add your tabs and add necessary View templates and classes. Quote:
This one will be a bit more complex. You need View\Model\OrderItemActivation class that will declare the form and a controller class that will handle your new actions and pass them to that "view model". Please use other \XLite\View\Model classes as the example. Also, the X-Cart 5 SDK (http://kb.x-cart.com/display/XDD/X-Cart+SDK) has a script (devkit/macros/create-crud-list.php) that can automate the process of creating back-end pages for new entities. The script create a page with the list of new entities and a page for creating/editing a new entity. Quote:
Yes, you should link OrderItem to OrdetItemActivation and back. To add your relation to OrderItem class you should decorate it from your custom module (search for "IDecorator" at http://kb.x-cart.com/ for articles/examples). Also, you can use \XLite\Model\Order and \XLite\Model\OrderItem as examples - these classes have the same relation that you need.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
#4
|
|||||||||
|
|||||||||
Re: Adding form to new order details tab
By the way, if your model don't have multilingual fields, you can extend it from \XLite\Model\AEntity class instead of \XLite\Model\Base\I18n (and the repository class from \XLite\Model\Repo\ARepo instead of \XLite\Model\Repo\Base\I18n).
If you need multilingual fields, extend the base model class from \XLite\Model\Base\I18n and put these fields into extra [BaseModelClass]Translation class.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
|
|||
X-Cart forums © 2001-2020
|