Skip to main content
Register now for TDX! Join the must-attend event to experience what’s next and learn how to build it.

Deep Clone Products

After completing this unit, you’ll be able to:

  • Describe the significance of deep cloning products.
  • Configure deep clone settings.
  • Create products using the deep clone method.

Clone a Product

More often than not, a product catalog has many products with similar attributes. For product designers, it's too cumbersome to create these products one-by-one. With Product Catalog Management, you can clone products using these two methods.

  • Clone: Use this method to deep clone the product record. This method doesn’t clone the child components or associated entities such as attributes.
  • Deep Clone: Use this method to create copies of a product including related information such as attributes, child components, and product selling models.
Note

You can create multiple products with similar attributes using product classifications as well. However, you use product classifications to group together related attributes for a set of similar products. So, this method is different from deep cloning.

At InfinitraBytes, the team manages a wide range of laptop models with a few variations such as storage, color, and warranty. In this unit, follow Product Designer Manoj Wilson as he helps to manage the growing catalog. During festival season, he uses the deep clone method to create new product offerings that are similar to existing ones.

Explore How Deep Cloning Works

Product Catalog Management uses context definitions to map the objects to be deep cloned. The ProductDeepCloneContext context definition captures the child objects of the product and their attributes that are cloned by default. You extend this context definition to add additional attributes that the cloned object has.

Here’s an example of cloning a product bundle that has various fields including a custom field called AvailabilityDate. First, you extend the ProductDeepCloneContext context definition and map the respective fields.

The Extended context definition showing field mappings.

Here, the fields in the extended context definition, including the custom field AvailabilityDate, are mapped to the corresponding fields in sObject. This ensures that the cloned product contains all of the fields defined in the context definition.

Further, you can use expression sets to define rules to be applied to the cloned objects. For example, use the Calculation expression set to specify a different value for an attribute in the cloned product.

The expression set for setting availability date in a deep cloned product.

Here, the expression set is defined to set the AvailabilityDate field to the current date. This value is set for the respective attribute in the deep cloned product.

Set Up Context Definition and Expression Sets

Now, follow along as Manoj sets up the necessary context definition and the expression set required for deep cloning.

Extend the Context Definition

Start by extending the standard context definition.

  1. From Setup, in the Quick Find box, find and select Context Definitions.
  2. In the Standard Definitions tab, for ProductDeepCloneContext, click Dropdown and select Extend.Extend the context definition for product deep clone.
  3. In the Extend Context Definition window, enter the name as ProductDeepCloneContextCustom.
  4. Save your work.

You can view the new content definition in the Custom Definitions tab.

Add Custom Field in the Context Definition

Next, Manoj adds the custom field in the context definition. Follow along in your Developer Edition org.

  1. In the Context Definitions page, go to the Custom Definitions tab, and then select ProductDeepCloneContextCustom.
  2. Click Edit.
  3. Click Next and Next again
  4. In the Edit Attributes window, select the Product2 Inherited node.
    The Product2 Inherited node.
  5. Click Add Attributes. A new blank row is added to the list. Enter these details.
    • Name: AvailabilityDate
    • Type: INPUT OUTPUT
    • Data Type: DATE
    • Display Name: Availability Date
  6. Click Next.
  7. Click the Product2Inherited node.
  8. Scroll to the AvailabilityDate__c attribute, click the + Add Tags next to it, and enter AvailabilityDateas Tag Name.
    Adding a new tag name.
  9. Click Done, and then save your changes.

You have now added a custom field in the context definition and added a context tag to it.

Map Fields in the Context Definition

Next, Manoj maps the newly added custom field to the corresponding field in the object and then activates the context definition. Follow along.

  1. In the ProductDeepCloneContextCustom page, go to the Map Data tab.
  2. For ProductDeepCloneMapping, click Dropdown, and select Edit SObjectMapping.
  3. In the Edit Mapping window, select Mark as Default, and then click Map. If you are prompted to switch to the new UI for context mapping, click Proceed.
  4. Click Switch View, and then click Legacy Interface.
  5. Click Switch.
    The Context Mapping page shows how the attributes in context definition on the left are mapped to the entities on the object shown on the right.
  6. Expand Unmapped under the Product2 node on both sides of the context mapping page.
  7. To create mapping, select Availability Date on context definition and then select corresponding Availability Date on the object.
    The map custom attribute in context definition.
  8. Click Save.
  9. Switch to the ProductDeepCloneContextCustom context definition page and click Activate to activate the definition.

Your extended context definition now includes the custom field and its mapping. Now, when you deep clone a product, the cloned product contains all the fields defined in the context definition, including the custom field.

Define an Expression Set

By default, the products in the InfinitraBytes catalog don’t have an availability date defined. Manoj wants every cloned product to have one, so he creates an expression set that automatically sets the cloned product’s availability date to the current date. Follow along.

  1. From the App Launcher, find and select Expression Sets.
  2. Click New.
  3. In the New Expression Set window, add these details.
    • Name: ProductAvailabilityDate
    • Usage Type: Default
    • Context Definition: ProductDeepCloneContextCustom
  4. Save your changes. The ProductDeepCloneContextCustom expression set page opens.
  5. In the Expression Set Versions section, select ProductAvailabilityDate V1. The expression set definition opens on a new page.
  6. In the Add step elements section, click The Add element button, and then select Calculation.
  7. Add these details.
    • Formula: TODAY ()
    • Output Variable: AvailabilityDate__c
  8. Click Expression Set Properties , and add these details.
    • Start Date Time: Today. Set this time after the Start Date Time of the context definition used. You can set it to any future date as well. However, make sure that it’s active when you deep clone a product.
    • Rank: 1
  9. Save your changes and click Activate.

Awesome! You’ve now defined the expression set to update values of specific attributes in the cloned product.

Configure Deep Clone Settings

Next, Manoj updates the setup page to specify the context definition and expression set to use for deep cloning. Follow along.

  1. From Setup, in the Quick Find box, find and select Deep Clone Product Settings.
  2. Under the Select Context Definition section, select ProductDeepCloneContextCustom.
  3. Under the Select Expression Set section, click The remove button. If you don’t see this button, click the right corner of the dropdown.
    The Select Expression Set section in Product Discovery settings page.
  4. Select ProductAvailabilityDate.
    The Deep Clone Product Settings page.

You’re all set to deep clone products.

Deep Clone a Product

Time to deep clone a product.

  1. From the App Launcher, find and select Product Catalog Management.
  2. On the Product Catalog Management home page, click the Products tile.
  3. Click Recently Viewed and select All Products. All the products in your catalogs are listed.
  4. Select Laptop Pro Bundle.
  5. Go to the Structure tab to view the bundle structure. It contains two product groups: Laptop and Accessories. Under each product group, there are various products.
  6. ClickQuick action menu , and select Deep Clone.
    The Deep Clone option on the product details page.
  7. Enter the product name as Laptop Pro Bundle - Festival and click Deep Clone.
  8. The Deep clone summary window shows the list of objects and the corresponding records that were created during the deep clone. Click View Cloned Product.
  9. In the Details tab, observe that the Availability Date is set to the current date.
  10. Click the Structure tab. Observe that all of the product groups and the component products that existed in the source product are available here.

Well done! You’ve successfully deep cloned a product.

Next Steps

In this unit, you learned about setting up the context definition and expression set for deep cloning products. In the next unit, explore how to customize the product discovery page for an enhanced product browsing experience.

For now, click Check Challenge to earn 500 points.

Resources

Comparta sus comentarios de Trailhead en la Ayuda de Salesforce.

Nos encantaría saber más sobre su experiencia con Trailhead. Ahora puede acceder al nuevo formulario de comentarios en cualquier momento en el sitio de Ayuda de Salesforce.

Más información Continuar a Compartir comentarios