2

I have created a catalog semi following the Habitat plugin, but using methods to create:

await _persistEntityPipeline.Run(new PersistEntityArgument(item), context);

The process seems to work correctly. I can see categories, their child categories and sellable items through the commerce business tools. After doing this, I was expecting to see these items on the front end.

I can find them in the database.

I can find them one at a time using PostMan:

{{ServiceHost}}/{{ShopsApi}}/SellableItems('ENV_Master,Entity-SellableItem-AA237_318,')?$expand=Components($expand=ChildComponents($expand=ChildComponents($expand=ChildComponents($expand=ChildComponents))))

Result:

{
    "@odata.context": "https://localhost:5000/Api/$metadata#SellableItems/$entity",
    "CompositeKey": null,
    "CreatedBy": null,
    "UpdatedBy": null,
    "DateCreated": "2018-09-04T21:06:34.3666257Z",
    "DateUpdated": "2018-09-04T20:24:36.3062164Z",
    "DisplayName": "2018 ICD-10-CM Expert for Physicians: The Complete Code Set",
    "FriendlyId": "AA237_318",
    "Id": "Entity-SellableItem-AA237_318",
    "Version": 3,
    "EntityVersion": 1,
    "Published": true,
    "IsPersisted": false,
    "Name": "AA237",
    "Policies": [
        {
            "@odata.type": "#Sitecore.Commerce.Plugin.Availability.AvailabilityAlwaysPolicy",
            "PolicyId": "b00ba625b47e41069814b1443c5a2bc1",
            "Models": []
        },
        {
            "@odata.type": "#Sitecore.Commerce.Plugin.Pricing.ListPricingPolicy",
            "PolicyId": "a29bbca4b22b4109a202ddf14ebbd8c7",
            "Models": [],
            "Prices": [
                {
                    "CurrencyCode": "USD",
                    "Amount": 81
                }
            ]
        },
        {
            "@odata.type": "#Sitecore.Commerce.Plugin.Pricing.PurchaseOptionMoneyPolicy",
            "PolicyId": "3bb4e6d567ad4fb58fd41a3b35b92e0b",
            "Models": [],
            "Expires": "2018-09-04T21:11:34.3706496Z",
            "SellPrice": {
                "CurrencyCode": "USD",
                "Amount": 81
            },
            "FixedSellPrice": false
        }
    ],
    "SitecoreId": "de7523d6-283a-49ef-833d-bc241365b750",
    "CatalogToEntityList": null,
    "ParentCatalogList": "b1da3bad-9621-7915-3ce6-a4457204798a",
    "ParentCategoryList": "a6f49394-1a07-25ce-6005-5e1bdfc0c78d",
    "ChildrenCategoryList": null,
    "ChildrenSellableItemList": null,
    "ItemVariations": null,
    "Description": "This essential book for diagnostic coding includes.",
    "ItemTemplate": null,
    "ProductId": "AA237_318",
    "Brand": "",
    "Manufacturer": "",
    "TypeOfGood": "",
    "Tags": [],
    "ListPrice": {
        "CurrencyCode": "USD",
        "Amount": 81
    },
    "Components": [
        {
            "@odata.type": "#Sitecore.Commerce.Plugin.Catalog.DisplayPropertiesComponent",
            "Id": "ac54aeb30ba5443bbb305625d9ddf02e",
            "Name": "",
            "Comments": "",
            "Policies": [],
            "DisambiguatingDescription": "",
            "DisplayOnSite": true,
            "DisplayInProductList": true,
            "Color": "",
            "Size": "",
            "Style": "",
            "ChildComponents": []
        },
        {
            "@odata.type": "#Sitecore.Commerce.Plugin.Workflow.WorkflowComponent",
            "Id": "7638fb8752bf4788b42d1ab46a5cd2c9",
            "Name": "",
            "Comments": "",
            "Policies": [],
            "Workflow": {
                "Name": "DefaultCommerceWorkflow",
                "EntityTarget": "Entity-Workflow-DefaultCommerceWorkflow",
                "Policies": []
            },
            "CurrentState": "Approved",
            "ChildComponents": []
        },
        {
            "@odata.type": "#Sitecore.Commerce.Core.LocalizedEntityComponent",
            "Id": "d769ba98786a4d0a8ecb9f3fb0af19ab",
            "Name": "",
            "Comments": "",
            "Policies": [],
            "Entity": {
                "Name": "",
                "EntityTarget": "Entity-LocalizationEntity-a339da44dd9d4d03a09c695576e3299a",
                "Policies": []
            },
            "ChildComponents": []
        },
        {
            "@odata.type": "#Sitecore.Commerce.Plugin.Catalog.CatalogsComponent",
            "Id": "1251ea730990445280bc89fef8bc0fed",
            "Name": "",
            "Comments": "",
            "Policies": [],
            "ChildComponents": [
                {
                    "@odata.type": "#Sitecore.Commerce.Plugin.Catalog.CatalogComponent",
                    "Id": "bdd3ba9911a84b2eabbb4a6ca1725a0e",
                    "Name": "ENV_Master",
                    "Comments": "",
                    "Policies": [],
                    "CatalogLanguages": [],
                    "DefaultLanguage": null,
                    "ItemDefinition": "",
                    "ChildComponents": []
                }
            ]
        },
        {
            "@odata.type": "#Sitecore.Commerce.Core.MessagesComponent",
            "Id": "598a1e8a15ec4b5a8e49d479545229b7",
            "Name": "",
            "Comments": "",
            "Policies": [],
            "Messages": [
                {
                    "Code": "Pricing",
                    "Text": "ListPrice<=PricingPolicy: Price=$81.00"
                },
                {
                    "Code": "Pricing",
                    "Text": "SellPrice<=ListPrice: Price=$81.00"
                }
            ],
            "ChildComponents": []
        },
        {
            "@odata.type": "#Sitecore.Commerce.Plugin.Inventory.InventoryComponent",
            "Id": "7464711206624a29890fc2aa293e9c0a",
            "Name": "",
            "Comments": "",
            "Policies": [],
            "InventoryAssociations": [],
            "ChildComponents": []
        }
    ]
}

However, I get no items back using PostMan to retrieve all sellable items:

{{ServiceHost}}/{{ShopsApi}}/SellableItems

Result:

{
    "@odata.context": "https://localhost:5000/Api/$metadata#SellableItems",
    "value": []
}

I assume this is the reason why I am not getting any items on the front end, but I cannot figure out why none are returning. How can I go about troubleshooting this?

Note: I have not added any inventory for these items. Is that required to return results?

What about variations? Must there be at least one variant? I would assume no, but I am not sure. I see when creating inventory information it has a parameter of variant Id. I would assume this could be empty.

Is there any kind of checklist of things that must be in place in order to return sellable items?

1

After runnging sellable item all variations on a habitat item versus one that I created, I noticed it was missing the following block:

{
            "@odata.type": "#Sitecore.Commerce.Plugin.ManagedLists.ListMembershipsComponent",
            "Id": "55c6a9d0c6da4eeb88ace11249a72336",
            "Name": "",
            "Comments": "",
            "Policies": [],
            "Memberships": [
                "SellableItems",
                "CatalogItems"
            ],
            "ChildComponents": []
        }

Adding this block of code before running the persist method resolved the issue:

var listMembershipComponent = new ListMembershipsComponent();
listMembershipComponent.Memberships.Add("SellableItems");
listMembershipComponent.Memberships.Add("CatalogItems");
item.Components.Add(listMembershipComponent);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.