Saturday, January 26, 2019

Sitecore commere - Can't see any item in search


If you can't see any product in the SXA -

Fix - Reindexing for master and web index have resolved the issue.


after reindex, I can see the result



Sunday, January 20, 2019

Sitecore commerece - Fix for Install-SitecoreConfiguration : The service cannot accept control messages at this time.



Error - Install-SitecoreConfiguration : The service cannot accept control messages at this time. (Exception from HRESULT: 0x80070425)
At C:\deploy\SIF.Sitecore.Commerce.3.0.28\Deploy-Sitecore-Commerce.ps1:95 char:1
+ Install-SitecoreConfiguration @params -Verbose *>&1 | Tee-Object "$PS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-SitecoreConfiguration

[TIME] 00:03:57
Invoke-ManageAppPoolTask : The service cannot accept control messages at this time. (Exception from HRESULT: 0x80070425)
At C:\Program Files\WindowsPowerShell\Modules\SitecoreInstallFramework\2.1.0\Public\Install-SitecoreConfiguration.ps1:641 char:25
+                         & $entry.Task.Command @paramSet | Out-Default
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-ManageAppPoolTask

Fix -

Please make sure you are not accessing any SXA site locally, Stop and restart the IIS, Please check all window services related to Sitecore has stopped.

Friday, January 18, 2019

Sitecore Commerce - Fix for Index rebuild failure

While rebuilding the web index for the commerce instance which contained a number of categories and sellable items,

We got the below error -

Exception: System.NullReferenceExceptionMessage: Object reference not set to an instance of an object.Source:
 Sitecore.Commerce.Engine.Connectat Sitecore.Commerce.Engine.Connect.Search.Crawlers.CatalogCrawlerBase`1.<>c__DisplayClass52_1.
b__0(CommerceCatalogIndexableItem indexable, ParallelLoopState loopState)

Fix - 

Open the content editor update the data commerce template and clearing the cache, this will fix the index rebuild issue.

Saturday, January 12, 2019

Sitecore commerce - Fix for the property 'Value' cannot be found on this object. Verify that the property exists.



[-------------------- CommerceEngine-Ops_CreateWebsiteForMinion [Skipped] : Website ----------------------------------------------------------------]

[----------------------------------------- CommerceEngine-Ops_StopWebsite : ManageWebsite ----------------------------------------------------------]
VERBOSE: Stops the website if it is running.
[CommerceEngine-Ops_StopWebsite]:[Stop] CommerceOps_Sc9
VERBOSE: Performing the operation "Stop-Website" on target "CommerceOps_Sc9".
VERBOSE: Checking state of Website 'CommerceOps_Sc9'
Install-SitecoreConfiguration : The property 'Value' cannot be found on this object. Verify that the property exists.
At C:\deploy\SIF.Sitecore.Commerce.3.0.28\Deploy-Sitecore-Commerce.ps1:95 char:1
+ Install-SitecoreConfiguration @params -Verbose *>&1 | Tee-Object "$PS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-SitecoreConfiguration

[TIME] 00:00:52
Invoke-ManageWebsiteTask : The property 'Value' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\SitecoreInstallFramework\2.1.0\Public\Install-SitecoreConfiguration.ps1:641 char:25
+                         & $entry.Task.Command @paramSet | Out-Default
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-ManageWebsiteTask

PS C:\deploy\SIF.Sitecore.Commerce.3.0.28>

FIx - In my case, my IIS was stop, I have restarted by IIS and it resolved the issue.

Sitecore commerce - Fix for Catalog Item of the Storefront catalog Configuration cannot be found

I got below error after Sitecore re-installation -

Catalog Item of the Storefront catalog Configuration cannot be found.

Fix - to resolve that issue I opened the Sitecore catalogs item, selected the Habitat_Master and published the item, It resolved the issue for me.

Friday, January 4, 2019

Sitecore Commerce 8.2.1 - Create a custom order number and few tips.


We got a requirement to generate a custom order number, Here are a few simple steps for that.

Steps 1  - Define a new environment variable in

\Environments\Shops-1.0.0.json


       

      {
        "$type": "Foundation.Commerce.PaymentsDataTest.Engine.Policies.OrderNumberPolicy, Foundation.Commerce.PaymentsData.Engine",
        "TestStoredProcedureName": "[dbo].[Test_GetNextOrderNumber]",
        "TestOrderNumberPrefix": "W",
        "TestDisableReGenerateOrderNumber": true
      },
       
 



Steps 2  - Define a new policy in the Commerce plugin -

Foundation.Commerce.PaymentsData\Engine\Foundation.Commerce.PaymentsData.Engine\Policies\OrderNumberPolicy.cs


       

    public class OrderNumberPolicy : Policy
    {
        /// 
        /// Stored procedure Inserting OrderNumber
        /// 
        public string TestStoredProcedureName { get; set; }

        /// 
        /// Prefix for Order Number
        /// 
        public string TestOrderNumberPrefix { get; set; }
        /// 
        /// Gets or sets a value indicating whether [disable re generate order number].
        /// 
        /// 
        ///   true if [disable re generate order number]; otherwise, false.
        /// 
        public bool TestDisableReGenerateOrderNumber { get; set; }
    }
       
 

Steps 3 - Extend the feature project - here

Feature.Commerce.Payments\Engine\Feature.Commerce.Payments.Engine\Pipelines\Blocks\GenerateOrderNumberBlock.cs



     

  public override async Task Run(Cart cart, CommercePipelineExecutionContext context)
        {
            

            try
            {
                TestOrderNumberPolicy ObjorderNumberPolicy = context.GetPolicy();

                TestorderNumberComponent.OrderNumber = _customComponent.GetNextOrderNumber(context.CommerceContext, orderNumberPolicy.TestStoredProcedureName, orderNumberPolicy.TestOrderNumberPrefix);
            }
            catch (Exception e)
            {
            }
            return cart;
        }
 


Steps 3 -  Custom table for the order number



     

 USE [Test.Website.CustomDetails]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Test.OrderNumberSequencer](
 [Id] [bigint] IDENTITY(10000000,1) NOT NULL,
 CONSTRAINT [PK_Test_Sequence_OrderNumber] PRIMARY KEY CLUSTERED 
(
 [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO


Steps 4 -  Sample store procedure to get the latest/incremental number -



     
USE [Test.Website.CustomDetails]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Test.OrderNumberSequencer](
 [Id] [bigint] IDENTITY(10000000,1) NOT NULL,
 CONSTRAINT [PK_Test_Sequence_OrderNumber] PRIMARY KEY CLUSTERED 
(
 [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
G


Steps 5- In case if we want to update the sequence of order number -

     
Steps 1 –  exec [dbo].[Test.OrderNumberSequencer] to check the current number
Step 2 – Run this script to update the sequence 

SET IDENTITY_INSERT dbo.Test.OrderNumberSequencer  ON
GO
-- Insert the record which you want to update with new value in identity column
INSERT INTO Test.OrderNumberSequencerId (Id) VALUES(300000)
GO
--Now set the idenetity_insert OFF to back to prevoius track
SET IDENTITY_INSERT Test.OrderNumberSequencerId OFF

Steps 3 Run this sp to see the current number - exec [dbo].[Test.OrderNumberSequencer] - Please take a note of that number


These are a very simple steps if you want to add a custom order number or any values/reference field in the Sitecore commerce engine,

Happy coding :)

Tuesday, January 1, 2019

How to delete replica manually - Solr Cloud.

We have been working on Solr cloud and it's very common issue that on your local system replicate may goes down.

Ideally, Local system should have only 1 replication factory but in case if you have crated multiple replica and those are not responding, Here are a few simple steps to remove those replica manually.

Go to that collection and expend the shard


Here you will see an option to delete the replica.