Si të hapni redaktorin e backoffice për një artikull të veçantë në SAP hybris backoffice.

Kjo mbështetet OOTB me mbështetje për faqeshënuesit: https://help.sap.com/viewer/9b5366ff6eb34df5be29881ff55f97d2/v2105/en-US/7439bda571794d8c94768df86d739519.

Mënyra 1. Thjesht hapni URL-në specifike me PK: https://localhost:9002/backoffice/#open(8796106981877)

Mënyra 2. Në mënyrë programore nga brenda backoffice. p.sh. ne duam të shtojmë një buton të personalizuar në një redaktues artikulli për të hapur artikullin e lidhur me të në një redaktues kërcyes.

bin\custom\training\backoffice\src\org\training\panels\PopupEditorPanel.java

package org.training.panels;

import de.hybris.platform.core.model.ItemModel;

import org.springframework.beans.factory.annotation.Autowired;
import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.BookmarkEvent;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Button;
import org.zkoss.zul.Messagebox;

import com.hybris.cockpitng.core.config.impl.jaxb.editorarea.AbstractPanel;
import com.hybris.cockpitng.core.events.CockpitEventQueue;
import com.hybris.cockpitng.core.events.impl.DefaultCockpitEvent;
import com.hybris.cockpitng.dataaccess.facades.type.DataType;
import com.hybris.cockpitng.engine.WidgetInstanceManager;
import com.hybris.cockpitng.widgets.editorarea.renderer.impl.AbstractEditorAreaPanelRenderer;

public class PopupEditorPanel extends AbstractEditorAreaPanelRenderer<ItemModel> {

   @Autowired
   private CockpitEventQueue cockpitEventQueue;

   @Override
   public void render(final Component component, final AbstractPanel configuration, final ItemModel itemModel, final DataType dataType, final WidgetInstanceManager widgetInstanceManager) {
      final Button display = new Button(Labels.getLabel("item.display.parent"));
      display.addEventListener(Events.ON_CLICK, event -> displayParentItem(itemModel));
      display.setParent(component);
   }

   private void displayParentItem(final ItemModel itemModel) {
      final ItemModel parentItem = itemModel.getOwner();
      if (parentItem == null) {
         Messagebox.show(Labels.getLabel("item.parent.null"));
      } else {
         final String pk = parentItem.getPk().toString();
         final BookmarkEvent bookmark = new BookmarkEvent("", "open(" + pk + ")");
         final DefaultCockpitEvent openEditorEvent = new DefaultCockpitEvent(Events.ON_BOOKMARK_CHANGE, bookmark, null);
         cockpitEventQueue.publishEvent(openEditorEvent);
      }
   }
}

bin\custom\training\resources\training-backoffice-config.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://www.hybris.com/cockpit/config"
      xmlns:ea="http://www.hybris.com/cockpitng/component/editorArea">
   <context merge-by="type" parent="Media" type="LogFile" component="editor-area">
      <ea:editorArea name="">
         <ea:essentials>
            <ea:essentialSection name="hmc.essential">
               <ea:customPanel name="popupEditorPanel" spring-bean="popupEditorPanel" />
               <ea:attribute qualifier="code" />
               <ea:attribute qualifier="catalogVersion" />
            </ea:essentialSection>
         </ea:essentials>
      </ea:editorArea>
   </context>
</config>

bin\custom\training\resources\training-backoffice-labels\labels_en.properties

item.display.parent=Display parent
item.parent.null=Parent item is null

bin\custom\training\resources\training-backoffice-spring.xml

<bean id="popupEditorPanel" class="org.training.panels.PopupEditorPanel" parent="abstractEditorAreaComponentRenderer"/>