简体   繁体   中英

SuiteCommerce Advanced - Show a custom record on the PDP

I am looking to create a feature whereby a User can download any available documents related to the item from a tab on the PDP.

So far I have created a custom record called Documentation (customrecord_documentation) containing the following fields:

  • Related item : custrecord_documentation_related_item
  • Type : custrecord_documentation_type
  • Document : custrecord_documentation_document
  • Description : custrecord_documentation_description
  • Related Item ID : custrecord_documentation_related_item_id

The functionality works fine on the backend of NetSuite where I can assign documents to an Inventory item. The stumbling block is trying to fetch the data to the front end of the SCA webstore.

Any help on the above would be much appreciated.

I've come at this a number of ways.

One way is to create a Suitelet that returns JSON of the document names and urls. The urls can be the real Netsuite urls or they can be the urls of your suitelet where you set up the suitelet to return the doc when accessed with action=doc&id=_docid_ query params.

Add a target <div id="relatedDocs"></div> to the item_details.tpl

In your ItemDetailsView 's init_Plugins add

$.getJSON('app/site/hosting/scriptlet.nl...?action=availabledoc').
    then(function(data){
        var asHtml = format(data); //however you like
        $("#relatedDocs").html(asHtml);
    });

You can also go the whole module route. If you created a third party module DocsView then you would add DocsView as a child view to ItemDetailsView .

That's a little more involved so try the option above first to see if it fits your needs. The nice thing is you can just about ignore Backbone with this approach. You can make this a little more portable by using a service.ss instead of the suitelet. You can create your own ssp app for the function so you don't have to deal with SCAs url structure.

It's been a while, but you should be able to access the JSON data from within the related Backbone View class. From there, within the return context, output the value you're wanting to the PDP. Hopefully you're extending the original class and not overwriting / altering the core code :P.

The model associated with the PDP should hold all the JSON data you're looking for. Model.get('...') sort of syntax.

I'd recommend against Suitelets for this, as that's extra execution time, and is a bit slower.

I'm sure you know, but you need to set the documents to be available as public as well.

Hope this helps, thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM