Skip to Content
author's profile photo Former Member
Former Member

how to customize the list view for "show only different attributes" in compare view

alt text

Using product cockpit the products are compared using compare button. In compare view we can show only different attributes of the compared products. Any customization done in editor area for the product attributes works fine in compare view but not in the "Show only different attributes view". Eg. Let's say ProductDescription is of type textArea in Editor area & compare view sections. But the same becomes text box in the Show only different attributes section. Please suggest how both views can be in synch. Is there any customized xml for configurations on show Only different attributes section Please do the needful.

Add a comment
10|10000 characters needed characters exceeded

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 09, 2015 at 05:27 AM

    Hi Anjaneya,

    Do the following if you want to hide "Show only different attributes" button in Product cockpit's compare view

    1, follow this guide to extend product cockpit https://wiki.hybris.com/display/release5/ycockpit+Template+-+Technical+Guide

    2, Add following codes

    
    public class MyCompareMainAreaBrowserComponent extends CompareMainAreaBrowserComponent
    {
        public MyCompareMainAreaBrowserComponent(final AbstractAdvancedBrowserModel model, final AbstractContentBrowser contentBrowser)
        {
            super(model, contentBrowser);
        }
        @Override
        protected Div createToolbar()
        {
            final Div toolbar = new Div();
            toolbar.setSclass("compareToolbar");
            final Hbox toolbarBox = new Hbox();
            toolbarBox.setSclass("compareToolbarBox");
            toolbar.appendChild(toolbarBox);
            return toolbar;
        }
    }
    

    
    public class MyCompareMainAreaComponentFactory extends CompareMainAreaComponentFactory
    {
        @Override
        public AbstractMainAreaBrowserComponent createInstance(final AdvancedBrowserModel model,
                final AbstractContentBrowser contentBrowser)
        {
            return new MyCompareMainAreaBrowserComponent((AbstractAdvancedBrowserModel) model, contentBrowser);
        }
    }
    

    
    public class MyDefaultProductSearchBrowserModel extends DefaultProductSearchBrowserModel
    {
        private List viewModes = null;
        @Override
        public List getAvailableViewModes()
        {
            if (viewModes == null)
            {
                viewModes = new ArrayList();
                viewModes.add(new GridMainAreaComponentFactory());
                viewModes.add(new ListMainAreaComponentFactory());
                viewModes.add(new MyCompareMainAreaComponentFactory());
            }
            return viewModes;
        }
    }
    
    3, Finally set bean in the XXX-spring-services.xml
     <alias alias="DefaultProductSearchBrowserModel" name="myDefaultProductSearchBrowserModel" />
     <bean id="myDefaultProductSearchBrowserModel"
         class="org.customizedcompareview.session.impl.MyDefaultProductSearchBrowserModel"
         scope="prototype" parent="defaultDefaultProductSearchBrowserModel">
     </bean>
    
    
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 10, 2015 at 04:58 AM

    finally figured that out. you need to add following codes.

     public class MyCollectionBrowserModel extends CollectionBrowserModel
     {
         @Override
         public List<MainAreaComponentFactory> getAvailableViewModes()
         {
             if (viewModes == null)
             {
                 viewModes = new ArrayList<MainAreaComponentFactory>();
                 viewModes.add(new GridMainAreaComponentFactory());
                 viewModes.add(new MultiTypeListMainAreaComponentFactory());
                 viewModes.add(new MyCompareMainAreaComponentFactory());
             }
             return viewModes;
         }
     }
    
    

    and

     public class MyDefaultProductPerspective extends ProductPerspective
     {
         private final MyNavigationAreaListener navListener = new MyNavigationAreaListener(this);
     
         @Override
         protected NavigationAreaListener getNavigationAreaListener()
         {
             return this.navListener;
         }
     
         private class MyNavigationAreaListener extends DefaultNavigationAreaListener implements ProductNavigationAreaListener
         {
             public MyNavigationAreaListener(final BaseUICockpitPerspective perspective)
             {
                 super(perspective);
             }
     
             @Override
             public void catalogItemSelectionChanged(final boolean doubleClicked)
             {
                 if (getBrowserArea() != null)
                 {
                     final BrowserModel browserModel = getBrowserArea().getFocusedBrowser();
                     if (browserModel instanceof SearchBrowserModel)
                     {
                         final SearchBrowserModel searchBrowser = (SearchBrowserModel) browserModel;
                         searchBrowser.setRootType(getTypeService().getObjectTemplate(ProductModel._TYPECODE));
                         searchBrowser.setSimpleQuery("");
                         getNavigationArea().update();
                         if (!CockpitBrowserAreaAutoSearchConfigurationUtil.isAutomaticSearchDisabled(Executions.getCurrent()))
                         {
                             searchBrowser.updateItems(0);
                         }
                     }
                 }
             }
     
             @Override
             protected SearchBrowserModel getSearchBrowserModel()
             {
                 final BrowserModelFactory factory = (BrowserModelFactory) SpringUtil.getBean(BrowserModelFactory.BEAN_ID);
                 return (SearchBrowserModel) factory.createBrowserModel(ProductcockpitConstants.PRODUCT_SEARCH_BROWSER_MODEL);
             }
     
             @Override
             public void collectionSelected()
             {
                 final CollectionBrowserModel collectionBrowserModel = new MyCollectionBrowserModel();
                 if (getNavigationArea().getSelectedCollection().getObjectCollection() instanceof ObjectCollectionImpl)
                 {
                     final CockpitObjectAbstractCollectionModel collectionModel = UISessionUtils.getCurrentSession().getModelService()
                             .get(getNavigationArea().getSelectedCollection().getObjectCollection().getPK());
                     ((ObjectCollectionImpl) getNavigationArea().getSelectedCollection().getObjectCollection()).setLabel(collectionModel
                             .getLabel());
                 }
                 collectionBrowserModel.setCollection(getNavigationArea().getSelectedCollection().getObjectCollection());
                 getBrowserArea().replaceBrowser(getBrowserArea().getFocusedBrowser(), collectionBrowserModel);
     
                 collectionBrowserModel.updateItems();
             }
     
             @Override
             public void collectionDoubleClicked()
             {
                 final CollectionBrowserModel collectionBrowserModel = new MyCollectionBrowserModel();
     
                 collectionBrowserModel.setCollection(getNavigationArea().getSelectedCollection().getObjectCollection());
                 collectionBrowserModel.updateItems();
                 getBrowserArea().show(collectionBrowserModel);
     
             }
         }
     }
    
    

    add add new bean

     <alias name="MyDefaultProductPerspective" alias="ProductPerspective" />
     <bean id="MyDefaultProductPerspective" class="org.customizedcompareview.session.impl.MyDefaultProductPerspective" scope="session" parent="defaultProductPerspective" />
     
    
    
    
    
    
    
    
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 07, 2015 at 09:27 AM

    Checked source but looks like ootb configuration can't fix this.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 15, 2015 at 09:32 AM

    Perfect solution

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 21, 2015 at 07:15 AM

    hi sorry for the late reply, please do the following

    MyDynamicQueryBrowserModel.java
     public class MyDynamicQueryBrowserModel extends DynamicQueryBrowserModel
     {
         public List<MainAreaComponentFactory> getAvailableViewModes()
         {
             if (viewModes == null)
             {
                 viewModes = new ArrayList<MainAreaComponentFactory>();
                 viewModes.add(new GridMainAreaComponentFactory());
                 viewModes.add(new ListMainAreaComponentFactory());
                 viewModes.add(new MyCompareMainAreaComponentFactory());
             }
             return viewModes;
         }
     }
    

    and add following part in MyDefaultProductPerspective.MyNavigationAreaListener

     public void dynamicQuerySelected()
                {
                    final MyDynamicQueryBrowserModel dynamicQueryBrowser = new MyDynamicQueryBrowserModel();
                    dynamicQueryBrowser.setDynamicQuery(getNavigationArea().getSelectedDynamicQuery().getQuery());
                    dynamicQueryBrowser.updateItems();
                    getBrowserArea().replaceBrowser(getBrowserArea().getFocusedBrowser(), dynamicQueryBrowser);
                }
    
    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Marshall, Thank you very much for the reply. This works fine for the required sections. I have one more issue as, when I compare the products from "last changes" section and go back to the compare the products in any one of the catalogues, I still see the "Show only different attributes" button. I hope some view is being overriding the earlier changes. For the first time when I try to compare the products, in a catalogue this works fine. But the issue is when I go from "last changes" or "duplicated products" to products compare in catalogue. Please do the needful, rest all are fine.

  • author's profile photo Former Member
    Former Member
    Posted on Apr 22, 2015 at 09:14 AM

    Hi Anjaneya

    Fix is as following. 1 new class

     public class MyProductNavigationArea extends NavigationArea
     {
         @Override
         public void setSelectedCatalogItems(final Collection<CatalogVersionModel> versions,
                 final Collection<CategoryModel> categories, final boolean doubleClicked)
         {
             //This is only ugly hack in order to pass currently selected catalog versions
             UISessionUtils.getCurrentSession().setSelectedCatalogVersions(new ArrayList(versions));
             final BrowserModel b = getPerspective().getBrowserArea().getFocusedBrowser();
             if (b instanceof MyDefaultProductSearchBrowserModel)
             {
                 final MyDefaultProductSearchBrowserModel prodSearchBrowser = (MyDefaultProductSearchBrowserModel) b;
                 prodSearchBrowser
                         .setSelectedCatalogVersions((versions.isEmpty() && categories.isEmpty()) ? getProductCockpitCatalogService()
                                 .getAllCatalogVersions(getSession().getUser()) : versions);
                 prodSearchBrowser.setSelectedCategories(categories);
     
     
                 fireCatalogItemSelectionChanged(doubleClicked);
             }
             else
             {
                 final MyDefaultProductSearchBrowserModel prodSearchBrowser = new MyDefaultProductSearchBrowserModel();
                 prodSearchBrowser
                         .setSelectedCatalogVersions((versions.isEmpty() && categories.isEmpty()) ? getProductCockpitCatalogService()
                                 .getAllCatalogVersions(getSession().getUser()) : versions);
                 prodSearchBrowser.setSelectedCategories(categories);
                 prodSearchBrowser.setShowCreateButton(true);
     
                 getPerspective().getBrowserArea().replaceBrowser(getPerspective().getBrowserArea().getFocusedBrowser(),
                         prodSearchBrowser);
                 fireCatalogItemSelectionChanged(doubleClicked);
             }
         }
     }
    
    
    

    2 new methods in MyDefaultProductSearchBrowserModel.java

         @Override
         protected void setSelectedCatalogVersions(final Collection<CatalogVersionModel> selectedCatalogVersions)
         {
             super.setSelectedCatalogVersions(selectedCatalogVersions);
         }
     
         @Override
         protected void setSelectedCategories(final Collection<CategoryModel> selectedCategories)
         {
             super.setSelectedCategories(selectedCategories);
         }
    
    

    and new config

         <bean id="ProductNavigationArea" class="org.customizedcompareview.session.impl.MyProductNavigationArea" scope="session"
             parent="BaseNavigationArea">
             <!-- <property name="width" value="300px"/> -->
             <property name="sectionModel">
                 <ref bean="ProductNavigationAreaModel" />
             </property>
             <property name="sections">
                 <list>
                     <ref bean="ProductSpecialCollectionsSection" />
                     <ref bean="ProductCatalogSelectorSection" />
                     <ref bean="ProductQuerySection" />
                     <ref bean="ProductUndoSection" />
                     <ref bean="ProductWorkflowSection" />
                 </list>
             </property>
             <property name="infoSlotAttachmentTypes">
                 <ref bean="WorkflowAttachmentData" />
             </property>
         </bean>
    
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 19, 2015 at 04:34 AM

    Hi Anjaneya,

    Please add the following codes.alt text


    3007-1.png (43.3 kB)
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.