分享方式:


建立並管理產品系列、產品、搭售方案及產品屬性

 

發佈日期: 2017年1月

適用對象: Dynamics 365 (online)、Dynamics 365 (on-premises)、Dynamics CRM 2016、Dynamics CRM Online

藉由在階層式結構中組織產品,定義產品類別目錄,方法是在產品系列中建立產品和搭售方案、定義相關產品和新增屬性 (屬性) 至上層產品系列,這樣產品系列中的所有下層產品與搭售方案會自動繼承屬性。

根據預設,當您建立產品系列、產品或搭售方案記錄時,它們是在草稿狀態。 在建立產品、定義相關產品和設定上層產品系列記錄的屬性之後,就必須發行產品系列、產品或搭售方案記錄,使其可以在系統中供銷售專員銷售。其他資訊:發行產品系列、產品或搭售方案

備註

對於未與產品系列相關的產品,也就是說沒有被指派上層產品系列記錄的產品,您可以直接在使用中狀態下建立它們,透過設定 Organization.CreateProductsWithoutParentInActiveState 屬性為 1 (true)。 根據預設,如果是新安裝的 Microsoft Dynamics 365,此屬性設為 0 (false),如果您從舊版 Dynamics 365 升級,則設為 1 (true),確保您的應用程式與舊版 Dynamics 365 相容,其中的產品記錄是在使用中狀態下建立。

您也可以使用 Microsoft Dynamics 365 或 Microsoft Dynamics 365 for Outlook 系統設定區域的 [銷售] 索引標籤,指定產品是否在使用中狀態下建立。其他資訊:TechNet:管理產品類別目錄設定

本主題內容

定義產品、產品系列與搭售方案

定義產品屬性

搭售方案和套件

定義產品關聯,在產品銷售時提供增強式建議

複製產品系列、產品或搭售方案

定義產品、產品系列與搭售方案

使用 Product.ProductStructure 屬性來定義項目是產品系列、產品或搭售方案。 將此屬性的值設為:

  • 1 表示建立產品

  • 2 表示建立產品系列

  • 3 表示建立搭售方案

以下是定義產品系列、產品及搭售方案時要考慮的一些重點:

  • 產品系列記錄可能是包含階層式結構中的多個下層產品系列、產品以及搭售方案執行個體。 使用 Product.ParentProductId 屬性,對於下層產品系列、下層產品或下層搭售方案執行個體,可定義上層產品系列執行個體。 設定後,上層記錄就無法變更。

  • 產品或搭售方案無法設定為上層,這表示產品或搭售方案記錄不能有下層記錄。

  • 產品系列、產品或搭售方案執行個體只能為一個產品系列執行個體的一部分。

  • 產品系列沒有巢狀層級上的限制。

  • Product.ValidFromDateProduct.ValidToDate 屬性沒有任何相關聯的內建商務邏輯,不過有檢查可確保 Product.ValidToDate 日期應晚於或等於 Product.ValidFromDate 日期。 必要時,您可以根據這些屬性實作您自己的商務邏輯。 例如,使用 Product.ValidToDate 屬性的日期值,您可以執行排程工作,自動淘汰上一季的產品。

下列程式碼範例示範如何建立產品系列和下層產品記錄。

// Create a product family
Product newProductFamily = new Product
{
   Name = "Example Product Family",
   ProductNumber = "PF001",
   ProductStructure = new OptionSetValue(2)
};
_productFamilyId = _serviceProxy.Create(newProductFamily);
Console.WriteLine("\nCreated {0}", newProductFamily.Name);

// Create a product record under the product family
Product newProduct1 = new Product
{
   Name = "Example Product 1",
   ProductNumber = "P001",
   ProductStructure = new OptionSetValue(1),
   ParentProductId = new EntityReference(Product.EntityLogicalName, _productFamilyId),
   QuantityDecimal = 2,
   DefaultUoMScheduleId = new EntityReference(UoMSchedule.EntityLogicalName, _unitGroupId),
   DefaultUoMId = new EntityReference(UoM.EntityLogicalName, _unit.Id)
};
_product1Id = _serviceProxy.Create(newProduct1);
Console.WriteLine("Created {0} under the product family", newProduct1.Name);

定義產品屬性

產品屬性可幫助您定義產品的特性,如大小、色彩或元件。 產品屬性式使用 DynamicProperty 實體定義。 定義產品屬性時,只能將它與 Draft 狀態的產品系列記錄產生關聯,無法與產品或搭售方案記錄產生關聯。 與草稿產品系列記錄相關聯的產品屬性最大數量由下列組織設定所決定:Organization.MaximumDynamicPropertiesAllowed。 此數字只有在您發行附加屬性的產品系列的下層產品記錄或搭售方案時才會生效,當您將屬性附加至草稿產品系列的記錄時不會生效。

提示

您也可以使用 Dynamics 365 或 Dynamics 365 for Outlook 系統設定區域的 [銷售] 索引標籤,設定產品屬性數目上限。其他資訊:TechNet:管理產品類別目錄設定

建立產品屬性時,您會指定其名稱、與其相關聯的 Draft 狀態的產品系列記錄、屬性的屬性 (如隱藏、必要或唯讀),以及屬性的資料類型。 產品屬性可以是下列資料類型之一:

資料類型

0

選項組

1

Decimal

2

浮點數

3

單行文字

4

整數

您無法在建立之後變更產品屬性的資料類型。 當您建立產品屬性時,會以 Draft 狀態建立。

下列範例程式碼示範如何建立產品屬性:

DynamicProperty newProperty = new DynamicProperty
{
    Name = "Example Property",
    RegardingObjectId = new EntityReference(Product.EntityLogicalName,
                                            _productFamilyId),
    IsReadOnly = true,
    IsRequired = true,
    IsHidden = false,
    DataType = new OptionSetValue(3), //Single line of text
    DefaultValueString = "Default Value"
};
_productPropertyId = _serviceProxy.Create(newProperty);

如需完整的範例,請參閱範例:建立和發行產品

備註

當您建立 Option Set 資料類型的產品屬性時,您必須建立 DynamicPropertyOptionSetItem 實體記錄來定義產品屬性的個別選項。 每個實體記錄都會儲存有關個別選項的資訊,其中 DynamicPropertyOptionSetItem.DynamicPropertyOptionNameDynamicPropertyOptionSetItem.DynamicPropertyOptionValue 屬性分別定義選項名稱和值,而且您可以將個別選項記錄與上層產品屬性執行個體產生關聯,使用 DynamicPropertyOptionSetItem.DynamicPropertyId 屬性。

如需使用網頁用戶端建立及管理產品屬性的詳細資訊,請參閱說明及訓練:使用屬性描述產品

備註

您定義產品屬性的方式決定在執行階段,也就是將相關產品新增至商機、報價、訂單或發票時,銷售專員如何使用產品屬性。可更新產品屬性的值可以在執行階段變更,而唯讀產品屬性的值無法。 如果產品屬性設定為必要,必須在執行階段指定屬性的值。 否則,屬性會顯示為未解析。隱藏的屬性不會在執行階段顯示給銷售專員。

此外,產品屬性不影響產品的定價。 這表示 Dynamics 365 定價引擎不支援根據產品屬性值的變更來變更產品的價格。

變更產品屬性

務必了解產品屬性的各種狀態,才能了解如何及何時能變更。 產品屬性的狀態可以是 [草稿]、[使用中] 或 [已淘汰]。 產品建立時會處於 [草稿] 狀態,然後在與其相關的產品系列記錄發行時變更為 [使用中] 狀態。 當關聯的產品系列記錄淘汰時,產品屬性的狀態也會變更為 Retired

產品屬性可在兩種層級變更:在產品屬性相關聯的產品系列層級,其次在子產品系列、產品或搭售方案層級,產品屬性會從中繼承。

變更相關聯的產品系列的產品屬性

若是 Draft 產品系列記錄,您可以變更與其關聯的產品屬性。 一旦發行產品系列記錄 (變更為 Active 狀態),您就無法變更產品屬性,直到您修改產品系列記錄。 在修改產品系列記錄之後 (變更為 Under Revision 狀態),然後覆寫屬性的已發行 (使用中) 版本以進行變更。 如需產品生命週期的相關資訊,請參閱發行、修訂、還原、淘汰及啟用產品 (產品週期)

變更子產品系列、產品或搭售方案的繼承的產品屬性

對於 Draft 狀態的產品屬性,子產品系列、產品及搭售方案記錄可以覆寫繼承的屬性,以定義屬性自己的版本。 例如,覆寫繼承的屬性會變更其名稱,或將屬性從隱藏變更為可見、必要變更為選用,或唯讀變更為可更新。 您無法覆寫或變更繼承的屬性的資料類型。

若要覆寫產品屬性,建立產品屬性的執行個體並將 BaseDynamicPropertyId 屬性設定為要覆寫的屬性的 GUID。 此外,您也可以將新屬性執行個體與要在其中覆寫的子產品系列、產品或搭售方案記錄產生關聯。

下列範例程式碼示範如何覆寫現有的產品屬性記錄,假設使用 GUID _productPropertyId,並將覆寫的屬性與產品記錄產生關聯,假設使用 GUID _product1Id。 在此之後,您可以更新新屬性的屬性,以指定自己的值來完成覆寫。

// Override a product property
DynamicProperty newOverrideProperty = new DynamicProperty();
newOverrideProperty.BaseDynamicPropertyId = new EntityReference(DynamicProperty.EntityLogicalName,
                           _productPropertyId);
newOverrideProperty.RegardingObjectId = new EntityReference(Product.EntityLogicalName, _product1Id);
_productOverridenPropertyId = _serviceProxy.Create(newOverrideProperty);

// Retrieve the attributes of the cloned property you want to update                    
ColumnSet columns = new ColumnSet();
columns.AddColumns("name", "isreadonly", "isrequired");
DynamicProperty retrievedOverridenProperty = (DynamicProperty)_serviceProxy.Retrieve(
                                               DynamicProperty.EntityLogicalName, _productOverridenPropertyId,
                                               columns);

// Update the attributes
retrievedOverridenProperty.Name = "Overridden Example Property";
retrievedOverridenProperty.IsReadOnly = true;
retrievedOverridenProperty.IsRequired = false;
_serviceProxy.Update(retrievedOverridenProperty);

如需完整的範例,請參閱範例:建立和發行產品

若是 Active 狀態的產品屬性,您可以覆寫子產品系列、產品或搭售方案記錄的繼承屬性,假設下列兩個子句屬實:

  • 子產品系列、產品或搭售方案記錄為 [修訂中] 狀態。

  • 繼承的使用中產品屬性已覆寫。

若要覆寫產品屬性,建立產品屬性的執行個體並將 BaseDynamicPropertyId 屬性設定為已覆寫屬性的 GUID。 此外,您也可以將新屬性執行個體與 Under Revision 狀態的子產品系列、產品或搭售方案記錄產生關聯。

下列範例程式碼示範如何覆寫使用中狀態的已覆寫產品屬性記錄,假設使用 GUID _productOverridenPropertyId,並將新屬性與 Under Revision 狀態的產品記錄產生關聯,假設使用 GUID _product1Id。 在此之後,您可以更新新屬性的屬性,以指定自己的值並完成覆寫。

// Overwrite a product property
DynamicProperty newOverwriteProperty = new DynamicProperty();
newOverwriteProperty.BaseDynamicPropertyId = new EntityReference(DynamicProperty.EntityLogicalName,
                           _productOverridenPropertyId);
newOverwriteProperty.RegardingObjectId = new EntityReference(Product.EntityLogicalName,
    _product1Id);
_productOverwrittenPropertyId = _serviceProxy.Create(newOverwriteProperty);

// Retrieve the attributes of the cloned property you want to update
ColumnSet myCols = new ColumnSet();
myCols.AddColumns("name", "isreadonly", "isrequired");
DynamicProperty retrievedOverwrittenProperty = (DynamicProperty)_serviceProxy.Retrieve(
                                                   DynamicProperty.EntityLogicalName, _productOverwrittenPropertyId,
                                                   myCols);

// Update the attributes of the cloned property to complete the overwrite 
retrievedOverwrittenProperty.Name = "Overwritten Example Property";
retrievedOverwrittenProperty.IsReadOnly = true;
retrievedOverridenProperty.IsRequired = false;
_serviceProxy.Update(retrievedOverwrittenProperty);

如需完整的範例,請參閱範例:建立和發行產品

搭售方案和套件

搭售方案是Dynamics 365 中引入的功能,用來取代舊的套件功能。 與套件類似的是,搭售方案是做為單一單位銷售的一組產品集合。 產品搭售方案對群組產品非常有用,因此客戶可以從完整產品線獲得更大的益處,或提供搭售產品的折扣,讓您將產品群組並做為單一單位銷售。

只有產品可加入搭售方案;您無法將產品系列、搭售方案或套件記錄新增至搭售方案。 使用 ProductAssociation 實體,您可以建立產品關聯記錄,將產品新增至搭售方案或套件。ProductAssociation.ProductId 記錄指定要新增產品至的搭售方案或套件,而 ProductAssociation.AssociatedProduct 指定要新增的產品。 加入搭售方案的產品最大數量由下列組織設定所決定:Organization.MaxProductsinBundle

您也可以使用 Dynamics 365 或 Dynamics 365 for Outlook 系統設定區域的 [銷售] 索引標籤,指定加入搭售方案的產品最大數量。其他資訊:TechNet:管理產品類別目錄設定

下列程式碼範例示範如何將產品加入至搭售方案。

// Add a product to a bundle
ProductAssociation newAssociation1 = new ProductAssociation
{
   AssociatedProduct = new EntityReference(Product.EntityLogicalName, _product1Id),
   ProductId = new EntityReference(Product.EntityLogicalName, _bundleId),
   Quantity = new decimal(15),
   ProductIsRequired = new OptionSetValue(0),
   UoMId = new EntityReference(UoM.EntityLogicalName, unit.Id)
};
_product1AssociationId = _serviceProxy.Create(newAssociation1);                    

// Add another product to the bundle                    
ProductAssociation newAssociation2 = new ProductAssociation
{
   AssociatedProduct = new EntityReference(Product.EntityLogicalName, _product2Id),
   ProductId = new EntityReference(Product.EntityLogicalName, _bundleId),
   Quantity = new decimal(20),
   ProductIsRequired = new OptionSetValue(1),
   UoMId = new EntityReference(UoM.EntityLogicalName, unit.Id),                        
};
_product2AssociationId = _serviceProxy.Create(newAssociation2);

if ((_product1AssociationId != null) && (_product1AssociationId != null))
Console.WriteLine("\nAdded both the products to the bundle");

如需完整的範例,請參閱範例:將產品新增至搭售方案

套件與搭售方案的差異

套件和搭售方案都能讓您將產品群組成單一單位,但是,這二者之間有一些差異。

套件

搭售方案

在套件中所有產品都是必要的。

搭售方案中某些產品是選擇性的。

套件支援巢狀;您可以新增套件至另一個套件。

您無法將搭售方案加到另一個搭售方案。 您只能將產品加到搭售方案。

將套件新增至商機、報價、訂單或發票時,只能看到套件層級之詳細資料;您無法看到套件中的個別產品。

將搭售方案新增至商機、報價、訂單或發票時,您可以看到搭售方案件層級之詳細資料,以搭售方案件中的個別產品。

備註

套件在 Dynamics 365 中已被取代;請改用搭售方案。

定義產品關聯,在產品銷售時提供增強式建議

您可以定義產品的相關產品,在商機或訂單管理時,向銷售專員顯示為建議產品。 產品的產品建議讓您的銷售專員建議相關的產品與搭售方案/套件給客戶,並提高產品銷售。 您可以定義下列產品關聯:配件交叉銷售替代產品向上銷售。 例如,Surface Pro 可新增為 Surface RT 的向上銷售產品,如此一來,當您的銷售專員將 Surface RT 新增至商機、報價、訂單或發票時,將建議 Surface Pro 成為向上銷售選項。

使用 ProductSubstitute.SalesRelationshipType 屬性定義產品關聯。 將此屬性的值設為:

  • 0 表示向上銷售

  • 1 表示交叉銷售

  • 2 表示配件

  • 3 表示替代產品

定義產品關聯時,定義關聯方向以避免資料重複是很重要的。 產品關聯支援的方向為:

產品關聯

方向

配件

單向

交叉銷售

單向或雙向

替代產品

單向或雙向

向上銷售

單向

使用 ProductSubstitute.Direction 屬性為產品關聯指定方向。 將此屬性的值設為:

  • 0 表示單向

  • 1 表示雙向

下列程式碼範例示範如何定義產品關聯。

// Set product relationship
// Set product1 and product2 as substitute of each other (bi-directional)
ProductSubstitute newProductRelation = new ProductSubstitute
{
   SalesRelationshipType = new OptionSetValue(3),
   Direction = new OptionSetValue(1),
   ProductId = new EntityReference(Product.EntityLogicalName, _product1Id),
   SubstitutedProductId = new EntityReference(Product.EntityLogicalName, _product2Id)
};
_productRelationId = _serviceProxy.Create(newProductRelation);

複製產品系列、產品或搭售方案

使用 CloneProductRequest 訊息來複製產品系列、產品或搭售方案記錄,然後在相同上層節點下建立記錄的複本。 您必須提供要複製之記錄的識別碼。 複製產品記錄,也會複製產品的屬性。 複製記錄建立時含有日期與時間戳記,附加至 Product.NameProduct.ProductNumber 屬性中的原始值;日期時間戳記表示記錄複製的時間。 下列程式碼範例示範如何複製產品。

CloneProductRequest cloneReq = new CloneProductRequest
{
   Source = new EntityReference(Product.EntityLogicalName, _productId)
};

CloneProductResponse cloned = (CloneProductResponse)_serviceProxy.Execute(cloneReq);                                     
_productCloneId = cloned.ClonedProduct.Id;

// Retrieve the cloned product record
Product retrievedProduct = (Product)_serviceProxy.Retrieve(Product.EntityLogicalName, _productCloneId, new ColumnSet(true));
Console.WriteLine("\nCreated clone product: {0}", retrievedProduct.Name);

後續步驟

發行產品記錄,供銷售專員銷售產品。其他資訊:發行產品系列、產品或搭售方案

另請參閱

發行、修訂、還原、淘汰及啟用產品 (產品週期)
範例:建立和發行產品
範例:複製產品記錄
範例:將產品新增至搭售方案
產品類別目錄實體

Microsoft Dynamics 365

© 2017 Microsoft. 著作權所有,並保留一切權利。 著作權