on 04-06-2015 7:56 AM
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.
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marshall, I have one more instance where the "Show only different Attributes" button being shown. Scenario: There is a customized section for visa, which will display the list of Visa content and descriptions. On trying to compare two visa content this button is being enabled. Please let me know which is the browser model that will listen on, so that I can change it accordingly to disable this button as previously done. It should not affect the existing changes whatever suggested. Please do the needful..... Waiting for your reply.
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);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Perfect solution
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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" />
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Checked source but looks like ootb configuration can't fix this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.