Custom logic for BasketAddProductBehaviour app server configuration - intershop

Is there a way to add/implement custom logic for BasketAddProductBehaviour configuration value different from DisallowRepeats, MergeQuantities and AllowRepeats (https://support.intershop.com/kb/index.php/Display/2809G2#Concept-BasketHandlingandCheckout-Introduction)?
For example add logic that only one product from one catalog can be added to basket?
Tnx

Starting with IS 7.6 add to basket functionality is implemented as chain of so called handler classes. Each handler class fulfills a particular purpose and is wired to the chain by the Java Extension Point mechanism of Intershop ICM. The com.intershop.component.basket.orm.internal.handlers.BehaviorHandler controls the add-to-basket behavior. This handler can be replaced by another implementation.

Related

How to use EventSubscriber in TYPO3 e.g. for symfony/workflow events?

How is it possible to use Symfony\Component\EventDispatcher\EventSubscriberInterface to implement a subscriber-class, listening for events dispatched by TYPO3s PSR-14 EventDispatcher?
Let's see an example by using symfony/workflow for a TYPO3 extension, which works great until it comes to events. Because of typo3/symfony-psr-event-dispatcher-adapter, the TYPO3 default EventDispatcher can be smoothly added to the Workflow class. So far so good.
Now I've several problems:
Problem 1: The event-names such as 'workflow.myname.leave'
The events dispatched by Workflow using a string name, instead of a FQCN like all other events dispatched in the TYPO3 life-cycle. This makes it impossible to use the common way of EventListeners registered inside the services.yaml, because the configuration requires a FQCN of the event-class.
# this will not work because the "event" needs to be a FQCN
Vendor\MyExt\EventListener\MyWorkflowEventListener:
tags:
- name: event.listener
identifier: 'vendor-myext/MyWorkflowEventListener'
event: 'workflow.myname.leave'
method: 'onLeave'
Problem 2: Trying to use an EventSubscriber
The doc recomments an EventSubscriber. IMO using an EventSubscriber (Symfony\Component\EventDispatcher\EventSubscriberInterface) would also solve problem #1, because the configuration of events is defined as key-value array inside getSubscribedEvents(). (BTW this seems to be also much easier for lots of events like in this case of workflow-events, because one class can be responsible handling multiple "similar" events and will not mess-up the services.yaml).
Also the Symfony doc says, that implementing this interface while autowire and autoconfigure is set to true will be enough; the EventSubscriber should be available and listening. Maybe this is true in a plain Symfony environment, but it seems not in a context of TYPO3. Unfortunately I can't figure out why (the subscriber classes doesn't show up inside EventDispatcher->ListenerProvider->listeners array).
How to continue here?
The TYPO3 core EventDispatcher is not able to handle or register Subscribers (yet). So for now I ended up using the Symfony\Component\EventDispatcher\EventDispatcher in parallel to the TYPO3 default one. The Symfony EventDispatcher handles only the workflow-events in this case. It feels not as clean as I'd like to, but it works.

Custom Header with token in PASOE Business Class Entity with Web Service?

I have a PASOE Business Class Entity setup as a Web Service. I'm trying to determine how to create a custom header that will allow me to pass in a hashed token. Is this something that I need to upgrade to 11.7.4 for DOH(OpenEdge.Web.DataObject.DataObjectHandler)? Or is this something that I simply add into a method that's defined in the class? Apologies, for the lack of code to illustrate my situation, but I'm not sure where to begin.
If you're using a Business Entity with the web transport then you're using the DOH, and the below applies. If you're using the rest transport then you are not using the DOH, and are more limited in your choices.
There is doc available on the DOH at https://documentation.progress.com/output/oe117sp/index.html#page/gssp4/openedge-data-object-handler.html - it's for 11.7.4 but largely applies to all versions (that is, from 11.6.3+). This describes the JSON mapping file, which you'll need to create an override to the default, generated one.
If you want to use the header's value for all operations, then you may want to use one of the DOH's events. There's an example of event handlers at https://github.com/PeterJudge-PSC/http_samples/blob/master/web_handler/data_object_handler/DOHEventHandler.cls ; you will need to start that handler in a session startup procedure using new DOHEventHandler() (the way that code is written is that it makes itself a singleton).
You can now add handling code for the Invoking event which fires before the business logic is run.
If you want to pass the header value into the business logic you will need to
Copy the generated mapping file <service>.gen to a <service.map> , in the same folder. "gen" files are generated and will be overwritten by the tooling
In the .map file, add a new arg entry. This must be in the same order as the parameters to the BE's method.
The JSON should look something like the below. this will read the value of the header and pass it as an input parameter into the method.
{ "ablName": "<parameter_name>",
"ablType": "CHARACTER",
"ioMode": "INPUT",
"msgElem": {"type": "HEADER", "name": "<http-header-name>"}
}

Symfony event vs service

Hi I have a question about symfony application architecture,
In my application I create different user, but when a user is created, updated, deleted, or his picture change, I need to do some action.
What is the best way to do this ? I excluded to do this on a controller action. There is 2 others solutions :
Create differents events like user.created, user.updated, ... And dispatch it on the controller action and make different listener to do the different action like MailListener (for user.created) TaskListener (for user.created) for add a task.
Use a service like UserManager and on this service have a method like userCreated() and on this method call differents actions like sendMailOnCreated, addTaskOnCreated for example.
For you what is the best method ?
For me, your first solution is the best one. It's clearly a use case for the Event component. It will be easier to maintain and more readable.
Moreover, if you need to add more listener you just need to create another one and bind it to your event. You don't need to modify your controller anymore.

how to implement source filter property page?

I have followed the instructions at http://msdn.microsoft.com/en-us/library/windows/desktop/dd375010%28v=vs.85%29.aspx to create a property page for my CSourceStream based stream.
When testing with amcap I can see that amcap now shows the menu item to show the capture pin properties (ISpecifyPropertyPages::GetPages is queried). The problem is that when amcap calls OleCreatePropertyFrame it returns with E_FAIL and I am not sure why, it does not seem to even get to the stage of quering my dll for the factory method to instantiate the CBasePropertyPage based property class.
The problem was my DllRegisterServer only registered my filter.
I can use AMovieDllRegisterServer2 to register all components in g_Templates but that function does not register source filters properly so for the moment I am just calling AMovieDllRegisterServer2 and then re-registering my filter with source filter specific code.

How to write "Intercepting Filter Pattern" like Java's servlet filter in Flex?

I want to know how to write "Intercepting Filter Pattern" like Java's servlet filter in Flex.
And I want to insert it into the classes which have a role of server communicating.
Please show me any sample codes if any...
Create a class which will play a role of connector between your program and server. Put there event listener for server events. Create a constant types for different types of events that server could send to your program. Put a switch into event listener that receive these events, and re dispatch them to the specific places, depending on which type of the event it was.

Resources