How to Generate a Frontend Item Model in SuiteCommerce

in , August 7th, 2024

When using items in SuiteCommerce, it is highly encouraged to use Item Models to represent them.

What are Item Models?

Item Models refer to the SuiteCommerce Backbone object defined in the “Items.Models.tsx” file. This object, along with the Product Model, is used all over the site to represent items, and using it can simplify your code and make it work smoothly with a multitude of other features.

Best Practice: Whenever you are using items in the front end you should use Item Models and/or Item Collections to represent the item data.

Working With Item Models

Load in the Item Model backbone object ('Item.Model'). You can then use this object to define new item models like this:

let itemModel = new ItemModel();
let itemId = 100;


itemModel.fetch({
	data: {
		id: itemId
	},
	killerId: AjaxRequestsKiller.getKillerId()
});

Running a simple fetch will use the native item’s API to return all the expected data from the defined fields sets. You can then use this item throughout the site like any other, displaying views, prices, adding to cart, etc.

Author: Sam Gagliardi


Got stuck on a step in this article?

We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!


Oracle NetSuite Alliance Partner & Commerce Partner

If you have general questions about SuiteCommerce or more specific questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!

We are a premium SuiteCommerce agency that creates powerful customer portals. Unlike our competitors, we have already solved your problems.

 
 

Want to keep learning?

Our team of NetSuite professionals has written articles on a wide variety of NetSuite topics, from SuiteCommerce tips, to recommended NetSuite solutions, to available support services, and more! 

Your cart