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

Adding multiple new properties to a product trouble

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 03-02-2023, 10:52 AM
 
galoadm galoadm is offline
 

Advanced Member
  
Join Date: Dec 2013
Posts: 36
 

Default Adding multiple new properties to a product trouble

I am following the "Add a New Property to a Product" instructions and am having a little trouble adding multiple properties in X-Cart 5.4. Adding a single property works fine, but adding multiple properties is making the product description, name, images, and category disappear from the back and front end while displaying all the new properties.

My code for decorating viewer class:

Code:
<?php // vim: set ts=4 sw=4 sts=4 et: namespace XLite\Module\*******\*******\View\FormModel\Product; /** * Product form model */ abstract class Info extends \XLite\View\FormModel\Product\Info implements \XLite\Base\IDecorator { protected function defineFields() { $schema = parent::defineFields(); $schema = ['default' => [ 'myBrand' => [ 'label' => static::t('Brand'), 'position' => 900, ], 'myCountryOrigin' => [ 'label' => static::t('Country of Origin'), 'position' => 910, ], 'myCountryAssembly' => [ 'label' => static::t('Assembly Location'), 'position' => 920, ], 'myItemCondition' => [ 'label' => static::t('Item Condition'), 'position' => 930, ], 'myMaterial' => [ 'label' => static::t('Made of'), 'position' => 940, ], ], ]; return $schema; } }


Instructions code for decorating viewer class:

Code:
<?php // vim: set ts=4 sw=4 sts=4 et: namespace XLite\Module\XCExample\ProductPropertyDemo\View\FormModel\Product; /** * Product form model */ abstract class Info extends \XLite\View\FormModel\Product\Info implements \XLite\Base\IDecorator { protected function defineFields() { $schema = parent::defineFields(); $schema['default']['myMessage'] = [ 'label' => static::t('My message'), 'position' => 900, ]; return $schema; } }


Any help will be most appreciated.
__________________
X-Cart Business 5.4
Reply With Quote
  #2  
Old 03-02-2023, 12:06 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,197
 

Default Re: Adding multiple new properties to a product trouble

Code:
$schema = parent::defineFields(); $schema = ['default' => [......


You are overriding $schema with your custom line. You should be adding to it your new fields whether you want them to show
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 03-02-2023, 01:14 PM
 
galoadm galoadm is offline
 

Advanced Member
  
Join Date: Dec 2013
Posts: 36
 

Default Re: Adding multiple new properties to a product trouble

Thank you. Could you elaborate on how to do that?
__________________
X-Cart Business 5.4
Reply With Quote
  #4  
Old 03-02-2023, 01:24 PM
 
galoadm galoadm is offline
 

Advanced Member
  
Join Date: Dec 2013
Posts: 36
 

Default Re: Adding multiple new properties to a product trouble

Would I just add each separately like this:

Code:
$schema = parent::defineFields(); $schema['default']['myBrand'] = [ 'label' => static::t('Brand'), 'position' => 900, ]; $schema['default']['myCountryOrigin'] = [ 'label' => static::t('Country of Origin'), 'position' => 910, ];

etc.
__________________
X-Cart Business 5.4
Reply With Quote
  #5  
Old 03-03-2023, 06:33 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,197
 

Default Re: Adding multiple new properties to a product trouble

You can do that, you can use array_merge as well
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
galoadm (03-03-2023)
  #6  
Old 03-03-2023, 07:39 AM
 
galoadm galoadm is offline
 

Advanced Member
  
Join Date: Dec 2013
Posts: 36
 

Default Re: Adding multiple new properties to a product trouble

Thank you. I appreciate the assistance.
__________________
X-Cart Business 5.4
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 04:13 PM.

   

 
X-Cart forums © 2001-2020