X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   New Field in product page (https://forum.x-cart.com/showthread.php?t=69245)

Kannan 05-27-2014 02:34 AM

New Field in product page
 
Hi,

How to create the new field in "xc_products" table?
Also field should reflect in the invoice page.

tony_sologubov 05-27-2014 03:04 AM

Re: New Field in product page
 
Hi!

The main process is as follows:
1) Create an empty module as described here: http://kb.x-cart.com/display/XDD/How+to+create+a+module
2) Create the file Model/Product.php script inside your module with the following content:
PHP Code:

<?php

namespace <YOUR-NAME-SPACE>;

class 
Product extends \XLite\Model\Product implements \XLite\Base\IDecorator
{
    
/**
      * @Column(type="integer")
      */
    
protected $my_int_property;

    
/**
      * @Column(type="string", length="32")
      */
    
protected $my_string_propery;
}


You should use your own namespace in the script, of course. Within the example, I created two properties: integer property and string one.

Once you rebuild cache X-Cart 5 will update tables and new field will appear in the database.

If you can give more details about how you want to display on invoice, I can help you with this part as well.

Tony.

Kannan 05-27-2014 06:59 AM

Re: New Field in product page
 
Hi,

Thanks. Its working. New field added in product table. We want to show that "added field value" in the invoice below the product name. Can you advice us.

Thanks in advance

tony_sologubov 05-28-2014 04:41 AM

Re: New Field in product page
 
Hi Kannan!

I will provide code sample within next two days.

Tony.

xcartwarrior 06-02-2014 05:56 AM

Re: New Field in product page
 
Hi,

Thanks. Now we added the field in invoice pages and its working. Can you advice how to show the categories and subcategories in Top menu bar like flyout menu.

Thanks in advance.

tony_sologubov 06-03-2014 01:44 PM

Re: New Field in product page
 
Hi!

First of all, you should check the last webinar doc for more details.

This section describes how you can replace menu items with your own ones:
http://kb.x-cart.com/pages/viewpage.action?pageId=7504837#Webinar2-10Apr2014-DesignchangesinX-Cart5(Custom...thmyownme nu?

Please, let me know if it helps.

Tony.

tony_sologubov 12-16-2014 12:10 PM

Re: New Field in product page
 
I have just written an article about how to accomplish task. Hopefully, it will help anybody:
http://kb.x-cart.com/display/XDD/Adding+new+property+to+product

Phil Richman 05-12-2015 07:12 AM

Re: New Field in product page
 
Based on your guide I was trying to add a product property and display it on my product page. I had no problem creating the field and storing a value in the xc product table, but when I tried to make add my .tpl so it would display on the product page I kept getting a Call to a member function get() on a non-object error. Any idea what I'm doing wrong here?

qualiteam 05-20-2015 12:49 AM

Re: New Field in product page
 
Hello Phil,

How do you display your template on the product page?

For each template file there is a PHP class that provides getSomething() methods to that template. If you do not specify such a class, it uses the class selected for the "parent" template file.

So, it looks like you display your template inside another template that doesn't have the necessary method (used in your template).

tony_sologubov 05-27-2015 10:53 AM

Re: New Field in product page
 
Hello Phil,

Could you post the code of your template here?

Thank you.

Tony

Quote:

Originally Posted by Phil Richman
Based on your guide I was trying to add a product property and display it on my product page. I had no problem creating the field and storing a value in the xc product table, but when I tried to make add my .tpl so it would display on the product page I kept getting a Call to a member function get() on a non-object error. Any idea what I'm doing wrong here?


Phil Richman 05-28-2015 07:14 AM

Re: New Field in product page
 
{**
* @ListChild (list="product.details.page.info", weight="50")
*}
<li class="product-availability">
<span class="name">{t(#Availability#)}</span>
<span class="product-availability-value">{item.product.getProductAvailability()}</span>
</li>

Phil Richman 05-28-2015 07:49 AM

Re: New Field in product page
 
1 Attachment(s)
Here are the files in my mod if you want to take a look Tony. I have no doubt that I'm overlooking something simple. I'm still trying to learn the ins and outs of xcart 5.

tony_sologubov 05-29-2015 03:19 AM

Re: New Field in product page
 
Hello Phil,

I see. Your code should be as follows:
Code:

{**
 * @ListChild (list="product.details.page.info", weight="50")
 *}
<li class="product-availability">
  <span class="name">{t(#Availability#)}</span>
  <span class="product-availability-value">{product.getProductAvailability()}</span>
</li>


In other words, I replaced item.product. construction with just product. one.

Tony

Quote:

Originally Posted by Phil Richman
{**
* @ListChild (list="product.details.page.info", weight="50")
*}
<li class="product-availability">
<span class="name">{t(#Availability#)}</span>
<span class="product-availability-value">{item.product.getProductAvailability()}</span>
</li>


Phil Richman 05-29-2015 05:03 PM

Re: New Field in product page
 
Tony,

Thank you very much for your help. Your fix worked perfect. I decided that I also wanted to display the sku field in this template. So I modified my .tpl to


{**
* @ListChild (list="product.details.page.info", weight="50")
*}
<li class="product-availability">
<span class="product-availability-name">{t(#Availability:#)}</span>
<span class="product-availability-value">{product.getProductAvailability()}</span>
</li>
<li class="product-availability">
<span class="product-availability-name">{t(#SKU:#)}</span>
<span class="product-availability-value">{product.getSKU()}</span>
</li>


This works except for items that have variants. It shows the base sku and not the variant sku. How can I modify this so that it will reflect the sku of the selected variant?

tony_sologubov 06-03-2015 03:49 AM

Re: New Field in product page
 
Do I understand you correctly that you want to display this widget on product details page? If so, could you please try to call getSKU() instead of product.getSKU() and let me know if does the trick.

Thank you.

dharmendralko 01-12-2017 01:55 AM

Re: New Field in product page
 
Hi Tony,

i had added some new fields to product by using my custom module and follow your doc http://devs.x-cart.com/en/basics/model_editing_page.html in X-Cart Business 5.2.13

when i upgrade X-Cart Business 5.2.13 to X-Cart Business 5.3.1.2, product fields are here but not show into admin area. While in old version (X-Cart Business 5.2.13) its working fine. Fields are showing and we can can edit its value

please let me know how get my custom fields and it value into admin area on product edit page.

Thanks

dharmendralko 01-12-2017 02:25 AM

Re: New Field in product page
 
Hello X-cart Team,

i have show my custom field by using XLite\Module\XC\CustomSkin\ProductField\View\FormM odel\Product Info class extends by \XLite\View\FormModel\Product\Info implements \XLite\Base\IDecorator

i have show all fields into new section by using function defineSections() in my XLite\Module\XC\CustomSkin\ProductField\View\FormM odel\Product Info class

so now i can see my custom field into admin on product edit page.

please let me know how i can fetch its value from database and edit that values from admin product edit page


Thanks

qualiteam 01-15-2017 10:09 PM

Re: New Field in product page
 
Please check this article on customizing product fields:
http://devs.x-cart.com/en/basics/adding_new_property_to_a_product/adding_product_property_via_formmodel_api.html

dharmendralko 01-15-2017 10:37 PM

Re: New Field in product page
 
Hi,

i have completed this, but i want to know that how i can set product priority (orderby) manually to set ordering of product for product listing page in front-end?

there are no area to set this in back-end
How i can do this?

Thanks

qualiteam 01-17-2017 02:32 AM

Re: New Field in product page
 
1 Attachment(s)
You can configure the order in which products appear on category pages as follows:
1. Go to Categories
2. Click on the number of products in the category that you want to change (see the screenshot)
3. Use the handle icon to the left of products to move them and change their order

xgarb 01-17-2017 08:43 AM

Re: New Field in product page
 
I've followed the article and added a new field (I'm replacing the standard x-cart tab with an custom html one).

Code:

class Info extends \XLite\View\FormModel\Product\Info implements \XLite\Base\IDecorator
{
    /**
    * @return array
    */
    protected function defineFields()
    {
        $schema = parent::defineFields();

        $schema[self::SECTION_DEFAULT]['specification'] = [
            'label'      => static::t('Specification'),
            'position'  => 600,
                        'type'    => 'XLite\View\FormModel\Type\TextareaAdvancedType',
        ];

        return $schema;
    }
}


It all works but when I enter HTML all the tags are stripped out. Is there something else I should be defining somewhere?

qualiteam 01-18-2017 02:23 AM

Re: New Field in product page
 
Did you decorate \XLite\Model\DTO\Product\Info as well?

Check how the class reads and writes the "full_description" field (that uses the WYSIWYG editor too) to the product model.

xgarb 01-19-2017 03:12 AM

Re: New Field in product page
 
yep I had that decorated as well but with this...

$object->setSpecification($this->default->specification);

when I needed this...

$object->setSpecification((string) $rawData['default']['specification']);


All times are GMT -8. The time now is 12:21 PM.

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