Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

A little help when upgrading from 11 to 13 (obsolete and removed object types and methods)

Vote:
 

I have tried to search for a guide and setup on how to replace our current logic when updating. So my last resort is to post on the forums here in hopes that you guys can guide me a bit.

We currently have some code in our inRiver Import Controller that is obsolete and removed. I would like to get some help to find the way to achieve something similar in Epi Commerce 13.

1st snippet: (Mediachase.Commerce.Catalog.Objects.Entry)

Entry entry = CatalogContext.Current.GetCatalogEntry(catalogEntryId);
                if (entry == null)
                {
                    Log.Warning($"Could not find catalog entry with id: {catalogEntryId}. No entry is deleted");
                    return false;
                }

                entryId = entry.CatalogEntryId;
                metaClassId = entry.MetaClassId;
                catalogId = entry.CatalogId;

2nd snippet: (Mediachase.Commerce.Catalog.Objects.CatalogNode)

Here we need cn.CatalogNodeId and cn.CatalogId

                CatalogNode cn = CatalogContext.Current.GetCatalogNode(catalogNodeId);

                if (cn == null || cn.CatalogNodeId == 0)
                {
                    Log.Warning($"Could not find catalog node with id: {catalogNodeId}. No node is deleted");
                    return false;
                }

                catalogId = cn.CatalogId;
                nodeId = cn.CatalogNodeId;

variation of 2nd Snipper:

foreach (CatalogRelationDto.NodeEntryRelationRow row in rel.NodeEntryRelation)
                    {

                        CatalogNode catalogNode = CatalogContext.Current.GetCatalogNode(row.CatalogNodeId);

                        if (updateEntryRelationData.RemoveFromChannelNodes.Contains(catalogNode.ID))
                        {
                            Log.Debug($"Removing relation to Node with id {catalogNode.CatalogNodeId} and code {catalogNode.ID}");
                            row.Delete();
                        }
                    }

3rd snippet: (Mediachase.Commerce.Catalog.Objects.Entry)

Here we want the "childEntry.ID".

                        foreach (CatalogRelationDto.CatalogEntryRelationRow row in rel3.CatalogEntryRelation)
                        {

                            Entry childEntry = CatalogContext.Current.GetCatalogEntry(row.ChildEntryId);

                            if (childEntry.ID == updateEntryRelationData.CatalogEntryIdString)
                            {
                                Log.Debug(
                                    $"Relations between entries {row.ParentEntryId} and {row.ChildEntryId} has been removed, saving new catalog releations");
                                row.Delete();
                                CatalogContext.Current.SaveCatalogRelationDto(rel3);
                                break;
                            }
                        }

#206360
Aug 16, 2019 13:02
Vote:
 

As the breaking change notes (and before that, the obsolete message) suggest, you should be using the content APIs to manipulate the entry/node information. There is not a 1:1 map between Entry and EntryContentBase, but it's quite close.

  1. You can use the ReferenceConverter to convert between the code and the content reference and the entryId/nodeId, and vice versa.
  2. You then can use IContentLoader to load the EntryContentBase or the NodeContent. They have CatalogId and MetaClassId fields that match with Entry/CatalogNode

For your snippets

  1. As above
  2. As above. You already have CatalogNodeId. For ID (which is Code), you can use ReferenceConverter
  3. As above. Once you have the entry id, use ReferenceConverter to get the content reference and use ReferenceConverter again to get the code.
#206362
Aug 16, 2019 13:36
Vote:
 

Hi Quan

I already had something like that implemented. But I was looking for something more specific.

But I accepted your answer because I already had that implemented so I am know I was on the right path.

Thank you

#206386
Edited, Aug 19, 2019 8:47
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.