X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Adding new property to a product (radio button) for Xcart 5 (https://forum.x-cart.com/showthread.php?t=76416)

gior_08 07-19-2018 09:04 PM

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

qualiteam 07-22-2018 12:40 AM

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.

gior_08 07-22-2018 01:17 AM

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!!!!!

qualiteam 07-22-2018 01:18 AM

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 :)

gior_08 08-06-2018 07:02 PM

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.

qualiteam 08-07-2018 11:40 AM

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.

siddharth.puri@wheelandba 04-29-2020 03:54 PM

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?

gior_08 04-29-2020 08:31 PM

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?



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

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.