Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Help with "creating interface" in admin on 5.3

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 09-08-2016, 08:21 AM
  GlasPak's Avatar 
GlasPak GlasPak is offline
 

eXpert
  
Join Date: May 2015
Posts: 241
 

Default Help with "creating interface" in admin on 5.3

So most of my module is working now (except my new database column data got erased when I upgraded my dev site from 5.2 to 5.3)

The only part that isn't working is


Code:
Creating interface for editing this field Now we need to be able to specify value of this property on product details page in admin area. We decorate \XLite\View\Model\Product class and create <X-Cart>/classes/XLite/Module/Tony/ProductFieldDemo/View/Model/Product.php file with the following content: <?php // vim: set ts=4 sw=4 sts=4 et: namespace XLite\Module\Tony\ProductFieldDemo\View\Model; class Product extends \XLite\View\Model\Product implements \XLite\Base\IDecorator { public function __construct(array $params = array(), array $sections = array()) { parent::__construct($params, $sections); $this->schemaDefault += array ( 'testField' => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', self::SCHEMA_LABEL => 'Test field', self::SCHEMA_REQUIRED => false, ), ); } } Such code will add a new field to the product details page in admin area. This field will be named Test field and its value will be saved into testField field of xc_products MySQL table. The FormField class that defines an input field in the interface is default \XLite\View\FormField\Input\Text one. Note: see an example of creating model editing form with more detailed explanation here: Model editing page.


I tried using the kb for upgrading modules to 5.3 from 5.2 but it doesn't seem to work. Any help on the changes needed here?
__________________
Business License
https://glaspak.com
GoDaddy VPS - Apache with WHM
2GB ECC DDR3 1600MHz
2x Intel E5-2630L v2 Hex Core 2.4/2.8ghz
15 MB proc cache
60 GB 10k RPM hdd
PHP 7.0.15
MariaDB 10.1.21 with InnoDB engine
Reply With Quote
  #2  
Old 09-12-2016, 01:32 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Help with "creating interface" in admin on 5.3

\XLite\View\Model\Product is not used anymore since the 5.3.0 version.

You should look into decorating the following two classes:
- \XLite\View\FormModel\Product\Info - defines form fields (for examples search in the soruce code for defineFields() method and how it uses static::compose() to combine existing and custom fields into groups)
- \XLite\Model\DTO\Product\Info - translates model properties/methods to form fields and back (look into init() and populateTo() methods and how these use static::compose() and static::deCompose() methods when fields are to be grouped into lines).

You don't need compose() and deCompose() methods if your custom fields appear as new lines (you use these methods only when your custom fields should appear along with other field in a single line, next to each other).
__________________
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

Last edited by qualiteam : 09-12-2016 at 01:34 AM.
Reply With Quote

The following user thanks qualiteam for this useful post:
divya (01-11-2018)
  #3  
Old 09-14-2016, 07:28 AM
  GlasPak's Avatar 
GlasPak GlasPak is offline
 

eXpert
  
Join Date: May 2015
Posts: 241
 

Default Re: Help with "creating interface" in admin on 5.3

Quote:
Originally Posted by qualiteam
\XLite\View\Model\Product is not used anymore since the 5.3.0 version.

You should look into decorating the following two classes:
- \XLite\View\FormModel\Product\Info - defines form fields (for examples search in the soruce code for defineFields() method and how it uses static::compose() to combine existing and custom fields into groups)
- \XLite\Model\DTO\Product\Info - translates model properties/methods to form fields and back (look into init() and populateTo() methods and how these use static::compose() and static::deCompose() methods when fields are to be grouped into lines).

You don't need compose() and deCompose() methods if your custom fields appear as new lines (you use these methods only when your custom fields should appear along with other field in a single line, next to each other).

I am at a complete loss...

I have looked over the areas you mentioned and looked at other modules and this should be working

Code:
<?php // vim: set ts=4 sw=4 sts=4 et: /** * Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved. * See https://www.x-cart.com/license-agreement.html for license details. */ namespace XLite\Module\EBLIEB\GlasPak\View\FormModel\Product; class Info extends \XLite\View\FormModel\Product\Info implements \XLite\Base\IDecorator { /** * @return array */ protected function defineFields() { $schema = parent::defineFields(); $schema = static::compose( $schema, [ 'PPCField' => [ 'label' => static::t('Pieces Per Case'), 'required' => false, ], 'position' => 900, ] ); return $schema; } }

But it isn't adding it to the self::SECTION_DEFAULT or anywhere for that matter...
__________________
Business License
https://glaspak.com
GoDaddy VPS - Apache with WHM
2GB ECC DDR3 1600MHz
2x Intel E5-2630L v2 Hex Core 2.4/2.8ghz
15 MB proc cache
60 GB 10k RPM hdd
PHP 7.0.15
MariaDB 10.1.21 with InnoDB engine
Reply With Quote
  #4  
Old 09-15-2016, 09:00 AM
  GlasPak's Avatar 
GlasPak GlasPak is offline
 

eXpert
  
Join Date: May 2015
Posts: 241
 

Default Re: Help with "creating interface" in admin on 5.3

Quote:
Originally Posted by qualiteam
\XLite\View\Model\Product is not used anymore since the 5.3.0 version.

You should look into decorating the following two classes:
- \XLite\View\FormModel\Product\Info - defines form fields (for examples search in the soruce code for defineFields() method and how it uses static::compose() to combine existing and custom fields into groups)
- \XLite\Model\DTO\Product\Info - translates model properties/methods to form fields and back (look into init() and populateTo() methods and how these use static::compose() and static::deCompose() methods when fields are to be grouped into lines).

You don't need compose() and deCompose() methods if your custom fields appear as new lines (you use these methods only when your custom fields should appear along with other field in a single line, next to each other).

http://devs.x-cart.com/en/basics/adding_new_property_to_a_product/ - Is this KB ever going to be updated? Was told all of them would be updated by the time 5.3 went out of beta.


Nevermind.. After a week or so of headaches I finally got it working (can't figure out how to do it with compose but atleast it is working).
__________________
Business License
https://glaspak.com
GoDaddy VPS - Apache with WHM
2GB ECC DDR3 1600MHz
2x Intel E5-2630L v2 Hex Core 2.4/2.8ghz
15 MB proc cache
60 GB 10k RPM hdd
PHP 7.0.15
MariaDB 10.1.21 with InnoDB engine
Reply With Quote
  #5  
Old 09-22-2016, 09:39 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Help with "creating interface" in admin on 5.3

The mentioned article is for X-Cart 5.2.x only.
For X-Cart 5.3.x you should check this one: http://devs.x-cart.com/en/basics/adding_new_property_to_a_product/adding_product_property_via_formmodel_api.html

"Compose" methods are used to "group" multiple fields into a single line. For example, you want to add a custom field and display it to the right of the existing Price field. In this case you "compose" your custom field with the Price field.

If your custom field should be displayed alone on a new form line, you don't need "compose" methods.
__________________
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
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:04 AM.

   

 
X-Cart forums © 2001-2020