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

Adding new property to a product (radio button) for Xcart 5

 
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 07-19-2018, 09:04 PM
 
gior_08 gior_08 is offline
 

Member
  
Join Date: Sep 2008
Posts: 23
 

Default Adding new property to a product (radio button) for Xcart 5

Hello


I found a great help in this link https://devs.x-cart.com/basics/adding_new_property_to_a_product/ so I can add extra properties to products.

This implementation adds a text field in product page (Admin Area).

I want to ask, If I would like to add a radio button what I should change in the code?


Thanks
__________________
Xcart 4.x.x
Xcart 5.x.x
Reply With Quote
  #2  
Old 07-22-2018, 12:40 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Adding new property to a product (radio button) for Xcart 5

Quote:
Originally Posted by gior_08
Hello


I found a great help in this link https://devs.x-cart.com/basics/adding_new_property_to_a_product/ so I can add extra properties to products.

This implementation adds a text field in product page (Admin Area).

I want to ask, If I would like to add a radio button what I should change in the code?


Thanks


Hi there.

I am assuming you are referring to a Yes/No button.
If so, you should make the following change to the module.

1. View/FormModel/Product/Info.php
Add the following line

Code:
$schema['default']['myMessage'] = [ 'label' => static::t('My message'), + 'type' => 'XLite\View\FormModel\Type\SwitcherType', 'position' => 900, ];


2. Model/Product.php
Change from


Code:
@Column (type="string")
to
Code:
@Column (type="boolean")


That's pretty much it.
If you already have the demo module installed in your store, don't forget to drop the existing 'myMessage' column from the database before re-deploying. Otherwise it will most likely produce an error that data format is incorrect.
__________________
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
  #3  
Old 07-22-2018, 01:17 AM
 
gior_08 gior_08 is offline
 

Member
  
Join Date: Sep 2008
Posts: 23
 

Default Re: Adding new property to a product (radio button) for Xcart 5

Dear Alex,


thanks a lot!!!!!!!!!
By the way these articles are a great help to understand Xcart 5!!!!!
__________________
Xcart 4.x.x
Xcart 5.x.x
Reply With Quote
  #4  
Old 07-22-2018, 01:18 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Adding new property to a product (radio button) for Xcart 5

Quote:
Originally Posted by gior_08
Dear Alex,


thanks a lot!!!!!!!!!
By the way these articles are a great help to understand Xcart 5!!!!!


Was glad to help
__________________
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
  #5  
Old 08-06-2018, 07:02 PM
 
gior_08 gior_08 is offline
 

Member
  
Join Date: Sep 2008
Posts: 23
 

Default Re: Adding new property to a product (radio button) for Xcart 5

I want to ask again, If I want to add a list menu (drop down) what I should do? I cannot find any article to read about.
__________________
Xcart 4.x.x
Xcart 5.x.x
Reply With Quote
  #6  
Old 08-07-2018, 11:40 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Adding new property to a product (radio button) for Xcart 5

Quote:
Originally Posted by gior_08
I want to ask again, If I want to add a list menu (drop down) what I should do? I cannot find any article to read about.


I would suggest to find a module that does what you need in your X-Cart installation and then search through the code to find the piece of code that does the thing.
__________________
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
  #7  
Old 04-29-2020, 03:54 PM
 
siddharth.puri@wheelandba siddharth.puri@wheelandba is offline
 

Advanced Member
  
Join Date: Nov 2019
Posts: 66
 

Default Re: Adding new property to a product (radio button) for Xcart 5

Hi, following the same method as mentioned int he docs - https://devs.x-cart.com/basics/adding_new_property_to_a_product/ ; I added a new property to the product.
How can I now include that property to import and export of products?
__________________
Version 5.3.6.6
Reply With Quote
  #8  
Old 04-29-2020, 08:31 PM
 
gior_08 gior_08 is offline
 

Member
  
Join Date: Sep 2008
Posts: 23
 

Default Re: Adding new property to a product (radio button) for Xcart 5

You must extend the \XLite\Logic\Export\Step\Products to export and the \XLite\Logic\Import\Processor\Products to import you new property. For example to import:

Quote:
abstract class Products extends \XLite\Logic\Import\Processor\Products implements \XLite\Base\IDecorator
{
protected function defineColumns()
{
$columns = parent::defineColumns();

$columns['tester'] = array();

return $columns;
}


protected function importTester(\XLite\Model\Product $model, $value, array $column)
{
$model->setTester($this->normalizeValueAsString($value));
}


}

Quote:
Originally Posted by siddharth.puri@wheelandba
Hi, following the same method as mentioned int he docs - https://devs.x-cart.com/basics/adding_new_property_to_a_product/ ; I added a new property to the product.
How can I now include that property to import and export of products?
__________________
Xcart 4.x.x
Xcart 5.x.x
Reply With Quote

The following user thanks gior_08 for this useful post:
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 12:05 PM.

   

 
X-Cart forums © 2001-2020