GTM snippet

Saturday, September 21, 2019

How to add Custom Node in Navigation Node


Make the following changes in the impex file, anything that starts with $ in impex are known as macros

File Name: cms-responsive-content.impex(sample data)
1.

INSERT_UPDATE CMSLinkComponent;$contentCV[unique=true];uid[unique=true];name;url;&linkRef;&componentRef; target(code)[default='sameWindow'];$category;$product;


;;PhoneLink;Phone Link;/phone;PhoneLink;PhoneLin;;;;

2. Now make a Controller for this in you storefront extension


@Controller
@RequestMapping("/phone")
@Scope("tenant")
public class PhonePageController extends AbstractPageController
{
              public static final String PHONE_CMS_PAGE = "phone";
              @RequestMapping(method = RequestMethod.GET)
              public String getPage(final Model model) throws CMSItemNotFoundException
              {
                  final ContentPageModel contentPageModel =                                                  getContentPageForLabelOrId(PHONE_CMS_PAGE);
                             storeCmsPageInModel(model, contentPageModel);
                             setUpMetaDataForContentPage(model, contentPageModel);
                             return getViewForPage(model);
              }
}

3. Create a navigation node


INSERT_UPDATE CMSNavigationNode;uid[unique=true];$contentCV[unique=true];name;parent(uid, $contentCV);links(&linkRef);&nodeRef

;PhoneNavNode;; Phone;ElectronicsNavNode;PhoneLink;PhoneNavNode


   4. Update the CMS Naviagtion node make the entry of our node"PhoneNavNode"

INSERT_UPDATE CMSNavigationNode;uid[unique=true];$contentCV[unique=true];name;parent(uid, $contentCV);&nodeRef;children(uid,$contentCV)


;ElectronicsCategoryNavNode;;Categories;ElectronicsNavNode;ElectronicsCategoryNavNode;BrandsNavNode,DigitalCamerasNavNode,FilmCamerasNavNode,HandheldCamcordersNavNode,WebcamsNavNode,PowerSuppliesNavNode,FlashMemoryNavNode,CameraAccessoriesNavNode, PhoneNavNode


INSERT_UPDATE CMSNavigationNode;uid[unique=true];$contentCV[unique=true];name;&nodeRef;children(uid,$contentCV);links(&linkRef);

;PhoneNavNode;;;PhoneNavNode

5. Now make an entry in CMS Navigation Entry
INSERT_UPDATE CMSNavigationEntry;uid[unique=true];$contentCV[unique=true];name;navigationNode(&nodeRef);item(CMSLinkComponent.uid,CMSLinkComponent.$contentCV);             

;PhoneNavNodeEntry;;Phone Nav Node;PhoneNavNode;PhoneLink;

Now make the following changes in another file 
File name : cms-responsive-content_en.impex(sample data)

1. Update the CMS link component

UPDATE CMSLinkComponent;$contentCV[unique=true];uid[unique=true];linkName[lang=$lang]

;;PhoneLink;"Phone"

 2. Update the CMS Navigation Node

UPDATE CMSNavigationNode;$contentCV[unique=true];uid[unique=true];title[lang=$lang]

;;PhoneNavNode;"Phone"





All Above steps  will add your node in Navigation node, now in next blog we will learn how to add page to this custom nav node.


















No comments:

Post a Comment