| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | Mark Forums Read | User manuals | Login |
Adding a new property to a category | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Adding a new property to a category
Greetings.
I recently read this tutorial which shows how to add a new custom property to a product: https://devs.x-cart.com/basics/adding_new_property_to_a_product/ I am now attempting to do the same thing but for a category. However, I have yet to find the correct viewer class to decorate so that the new property is displayed in the admin page. Basically, I would like to know where I can find the Info.php file for Category. Thank you.
__________________
X-Cart 5.3.4 Add-ons: 2Checkout.com, Authorize.Net SIM, Barclaycard ePDQ e-Commerce, Bestsellers, Bulk Editing, CloudSearch & CloudFilters, Concierge, Contact us, Coupons, Fast Lane Checkout, Featured Products, FedEx, Flyout Categories Menu, Free Shipping and Shipping freights, Froala WYSIWYG editor integration, Go Social, Google Analytics, iDEAL Payments, MailChimp Integration with E-commerce support, Multicurrency, News, Newsletter subscriptions, Not Finished Orders, Onboarding Wizard, PayPal, Product Advisor, Product reviews, QuantumGateway, Related Products, Sage Pay (Form), Sale, Sales Tax, Simple CMS, Skrill, Social Login, Stripe, Theme tweaker, Translation: British English, Update Inventory, UPS, User permissions, Value Added Tax / Goods and Services Tax, Volume Discounts, X-Payments connector, XML sitemap |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Adding a new property to a category
Only Product uses DTO. Category - depends on what you need
classes/XLite/View/Model/Category.php classes/XLite/View/Form/Category/Modify/Single.php classes/XLite/Controller/Admin/Category.php
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#3
|
|||||||
|
|||||||
Re: Adding a new property to a category
I see. What I would like to do is adding a new field in the Category info form in the admin page so that the user can change a new string attribute of said category. Which file should I therefore decorate to achieve that?
And if Category doesn't use DTO, how can I make Xcart save the changes to the database?
__________________
X-Cart 5.3.4 Add-ons: 2Checkout.com, Authorize.Net SIM, Barclaycard ePDQ e-Commerce, Bestsellers, Bulk Editing, CloudSearch & CloudFilters, Concierge, Contact us, Coupons, Fast Lane Checkout, Featured Products, FedEx, Flyout Categories Menu, Free Shipping and Shipping freights, Froala WYSIWYG editor integration, Go Social, Google Analytics, iDEAL Payments, MailChimp Integration with E-commerce support, Multicurrency, News, Newsletter subscriptions, Not Finished Orders, Onboarding Wizard, PayPal, Product Advisor, Product reviews, QuantumGateway, Related Products, Sage Pay (Form), Sale, Sales Tax, Simple CMS, Skrill, Social Login, Stripe, Theme tweaker, Translation: British English, Update Inventory, UPS, User permissions, Value Added Tax / Goods and Services Tax, Volume Discounts, X-Payments connector, XML sitemap |
|||||||
#4
|
|||||||||
|
|||||||||
Re: Adding a new property to a category
You may need to decorate all of the files I listed. To make changes to categories table you need to decorate classes/XLite/Model/Category.php.
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#5
|
|||||||
|
|||||||
Re: Adding a new property to a category
Alas, I have tried decorating all three classes using the tutorial as rough guide, but without avail.
To clarify, this is what I'm trying to do: I want to create a new property called Genre for Category. First, I decorated classes/XLite/View/Model/Category.php like so: <?php namespace XLite\Module\XCExample\DesignChangesDemo\Model; abstract class Category extends \XLite\Model\Category implements \XLite\Base\IDecorator { /** * @Column (type="string") */ protected $genre; public function getGenre() { return $this->genre; } public function setGenre($value) { $this->genre = $value; return $this; } } I would now like to have the field with the new genre property to show up in the admin Category info page. Following the tutorial, this is the code I came up with: <?php // vim: set ts=4 sw=4 sts=4 et: namespace XLite\Module\XCExample\DesignChangesDemo\Controlle r\Admin; /** * Product form model */ abstract class Category extends \XLite\Controller\Admin\Category implements \XLite\Base\IDecorator { protected function defineFields() { $schema = parent::defineFields(); $schema['default']['genre'] = [ 'label' => static::t('Genre'), 'position' => 900, ]; return $schema; } } I also adapted and pasted the previous code for classes/XLite/View/Form/Category/Modify/Single.php Nothing has worked so far. Any ideas?
__________________
X-Cart 5.3.4 Add-ons: 2Checkout.com, Authorize.Net SIM, Barclaycard ePDQ e-Commerce, Bestsellers, Bulk Editing, CloudSearch & CloudFilters, Concierge, Contact us, Coupons, Fast Lane Checkout, Featured Products, FedEx, Flyout Categories Menu, Free Shipping and Shipping freights, Froala WYSIWYG editor integration, Go Social, Google Analytics, iDEAL Payments, MailChimp Integration with E-commerce support, Multicurrency, News, Newsletter subscriptions, Not Finished Orders, Onboarding Wizard, PayPal, Product Advisor, Product reviews, QuantumGateway, Related Products, Sage Pay (Form), Sale, Sales Tax, Simple CMS, Skrill, Social Login, Stripe, Theme tweaker, Translation: British English, Update Inventory, UPS, User permissions, Value Added Tax / Goods and Services Tax, Volume Discounts, X-Payments connector, XML sitemap |
|||||||
#6
|
|||||||||
|
|||||||||
Re: Adding a new property to a category
Neither \XLite\Controller\Admin\Category, nor \XLite\Controller\Admin\Category classes control what fields are displayed on the "Edit category" page.
It is \XLite\View\Model\Category (and it's parent \XLite\View\Model\AModel). Please check how the existing classes configure fields for the page, and decorate \XLite\View\Model\Category from your module.
__________________
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 |
|||||||||
#7
|
|||||||
|
|||||||
Re: Adding a new property to a category
Hello,
Was this ever figured out? I'm trying to add a custom field 'ie: Test' to my Category page, so I can then use that field value and output it wherever I want. |
|||||||
#8
|
|||||||
|
|||||||
Re: Adding font-awesome icons to category sidebar
Hi Alex,
This is something I would only want on the backend. I added a new field to XLite/View/Model/Category.php HTML Code:
Still a bit confused on all the files/etc I'd need to edit. To summarize what I really want to do: - Admin navigates to 'Catalog -> Our Products' - Admin clicks on a category to edit. - Where the field 'Category name' is, I'd like to add my own custom field -- for example 'Navigation Icon'. Then the field becomes usable to call, ie: how {{ this._category.name }} is used in the sidebar menu. So then I'd have a {{ this._category.nav_icon }} or something similar. |
|||||||
#9
|
|||||||||
|
|||||||||
Re: Adding a new property to a category
Hi @mcupka,
There is an article that describes how to add new property to product in X-Cart 5.1 - 5.2: https://devs.x-cart.com/basics/model_editing_page.html The same principle works for editing category page in X-Cart 5.3. Basically, you will only need to decorate \XLite\View\Model\Category class and define its constructor method as follows: Code:
Please, let us know, if it helps.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#10
|
|||||||
|
|||||||
Re: Adding a new property to a category
Quote:
I have a ticket in with support to see what they say now that I've seen a few examples, thought about it more, have a better understanding etc.. Perhaps a better way to word what I'm looking for is this: I'm trying to place certain elements throughout the site and it'd be nice if there was a module where I could input text into a field, have it display as raw HTML (this can be set with |raw, I know), and call it anywhere I'd like. Basically a global 'variable'. Kind of like how the language fields and labels work. So instead of creating a module for every small task, I could manage multiple edits on the site with this 1 module. So then I'd basically just be editing .twig files to use the 'variable' into the custom HTML with {{ customlabel_1 }} to let's say "Hello world". {{customlabel_2}} says "Hey there", etc. Could place 1 in the header, 1 in footer, wherever I want within the .twig files really. Would give designers and developers a lot more flexibility and efficiency. More complex tweaks would of course require a custom module. |
|||||||
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|