1

I have a price integration pipeline where I want to associate prices with products by giving the product a pricecardpolicy to refer to its pricecard. I am however running into a problem where the addpolicy pipeline that is in sitecore.commerce throws and doesn’t add my policy, underneath is a code snippet and error log. I’m new to Sitecore and not well versed in it, any comments and hints are appreciated.

public class SynchronizePriceSnapshotsBlock : CommercePipelineBlock<SynchronizePriceCardArgument, SynchronizePriceCardArgument,
    CommercePipelineExecutionContext>
{
    private readonly IGetSellableItemsPipeline _getSellableItemsPipeline;
    protected override async Task<SynchronizePriceCardArgument> PerformRun(SynchronizePriceCardArgument arg,
            CommercePipelineExecutionContext context)
        {
            if (arg.PriceCard == null) throw new ArgumentNullException(nameof(arg.PriceCard));
            if (context?.CommerceContext == null) throw new ArgumentNullException(nameof(context.CommerceContext));

            var item = (await _getSellableItemsPipeline.Run(
                        new GetSellableItemsArgument(),
                        context)).Where(row => arg.ProductId.Equals(row.ProductId)).ToList().FirstOrDefault();
            var addPolicyArgumet = new AddPolicyToEntityArgument(item, new PriceCardPolicy(arg.PriceCard.Name));
            var result = await _AddPolicyToEntityPipeline.RunWithResult(addPolicyArgumet, context);

            return arg;
        }

I’m not quite sure why the getSellableItemsPipeline throws, items are returned and my block continues despite the error message.

I can also see that there is a localization error which I don’t understand why this is called nor what I can do to fix it.

Error log:

00022 13:49:16 INFO SynchronizePriceSnapshotsBlock running
00034 13:49:16 ERROR Pipeline completed with error System.Exception: Error processing block: Catalog.block.FormatComposerViewPropertyBlock ---> System.ArgumentException: Object of type 'System.Collections.Generic.List`1[Sitecore.Commerce.Plugin.Catalog.SellableItem]' cannot be converted to type 'Sitecore.Commerce.Plugin.Catalog.SellableItem'.
       at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
       at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
       at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Sitecore.Framework.Pipelines.ReflectionPipelineBlockRunner.<InvokeBlock>d__2.MoveNext()
       --- End of inner exception stack trace ---
       at Sitecore.Framework.Pipelines.ReflectionPipelineBlockRunner.<InvokeBlock>d__2.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Sitecore.Framework.Pipelines.BasePipelineBlockRunner.<Run>d__3`1.MoveNext()
    00026 13:49:16 INFO SQL:block:persistentity.LocalizationEntity: EntityId=Entity-LocalizationEntity-1004b56689d247be846809010358be2c
    00022 13:49:16 INFO SQL:block:persistentity.Category: EntityId=Entity-Category-Content Store   ImageBank-7344
    00022 13:49:16 WARN CtxMsg.ValidationError.EntityWasNotLocalized: Text=Entity '0e7a88a47cb74e8abe2ca5fb29d231b1' was not localized.|Shopper=[None]|Shop=|Correlation=02c748d3-474f-429c-b403-4811dff3bd5c
    00022 13:49:16 ERROR Pipeline completed with error
    System.Exception: Error processing block: SQL:block:persistentity ---> System.ArgumentNullException: SQL:block:persistentity: the argument cannot be null..
    Parameter name: value
       at Sitecore.Framework.Conditions.RequiresValidator`1.ThrowExceptionCore(String condition, String additionalMessage, ConstraintViolationType type)
       at Sitecore.Framework.Conditions.Throw.ValueShouldNotBeNull[T](ConditionValidator`1 validator, String conditionDescription)
       at Sitecore.Framework.Conditions.ValidatorExtensions.IsNotNull[T](ConditionValidator`1 validator, String conditionDescription)
       at Sitecore.Commerce.Plugin.SQL.PersistEntityBlock.<Run>d__6.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Sitecore.Framework.Pipelines.ReflectionPipelineBlockRunner.<InvokeBlock>d__2.MoveNext()
       --- End of inner exception stack trace ---
       at Sitecore.Framework.Pipelines.ReflectionPipelineBlockRunner.<InvokeBlock>d__2.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Sitecore.Framework.Pipelines.BasePipelineBlockRunner.<Run>d__3`1.MoveNext()

Doing debugging I did a throw to check the resulting output from the pipeline:

result.Value.Id = 0e7a88a47cb74e8abe2ca5fb29d231b1

Policy id = 5b568aeca5774140b028ec407af81854

Item.id = 0e7a88a47cb74e8abe2ca5fb29d231b1

item.ProductId = 10806

addPolicyArgumet.Entity.Id = 0e7a88a47cb74e8abe2ca5fb29d231b1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.