View Single Post
  #41  
Old 04-07-2014, 03:59 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Webinar for X-Cart 5 developers on March,18th.

Happy to hear that you solved the problem with translation.

You fix basically meant that News model is now extends an abstract model that allows translation (i18n) and as soon as you create the NewsTranslation model, X-Cart 5 automatically creates the utility columns like id, so you only need to specify meaningful part: what field types to use for title and body columns.

As for your question about why use AEntity at all, many models does not need translations. Classic example is Inventory. There is simply nothing to translate, so using AEntity here saves your time because you do not need InventoryTranslation class. Also, you do not create excessive tables in your database.

You can check XLite/Model folder for more examples of models that created based on AEntity.

Finally, I am pretty happy that you are asking questions and I am even more happy to help you learn X-Cart 5 through your questions.

I am sorry, I cannot reply straight away, because of big amount of work at the moment, but I will do my best to answer on forums as quick as possible, so please keep asking with no hesitation : )

Tony.

Quote:
Originally Posted by totaltec
Thanks Ksenia!

Tony,
I solved the problem (thankfully I was stuck for hours!), but I would still like an explanation of why this works. I found that by modifying XLite\Module\Tony\News\Model\News.php and changing the line:
Code:
class News extends \XLite\Model\AEntity
To:
Code:
class News extends \XLite\Model\Base\I18n
Fixes the error that it was throwing, and the table "xc_news_translations" is successfully created. The functioning of the module appears unchanged besides that.

What is the difference here, and why should we ever use "\XLite\Model\AEntity" if it cannot be translated?
Reply With Quote