IProductCatalog3::AddVirtualCatalogRule Method [C++]

Use this method to add an inclusion or exclusion rule for a specific product, category, variant, or catalog to the current virtual catalog. This method applies only to virtual catalogs.

Definition

[C++]

HRESULT IProductCatalog3::AddVirtualCatalogRule(BSTRstrCatalogName,
  VARIANTvrProductIDOrCategoryName,
  VARIANTvrVariantID,
  VARIANT_BOOLfCategory,
  VARIANT_BOOLfExclusion);

[Visual Basic]

Sub AddVirtualCatalogRule(strCatalogName As String,
  vrProductIDOrCategoryName As Variant,
  Optional vrVariantID As Variant,
  Optional fCategory As Boolean,
  Optional fExclusion As Boolean
[in, optional] VARIANT vrVariantID, )

Parameters

  • strCatalogName[C++]
    [in] A BSTR that contains the catalog name.
  • strCatalogName[Visual Basic]
    A String that contains the catalog name.
  • vrProductIDOrCategoryName[C++]
    [in] A VARIANT that contains the product ID or category name to which the rule applies.
  • vrProductIDOrCategoryName[Visual Basic]
    A Variant that contains the product ID or category name to which the rule applies.
  • vrVariantID[C++]
    [in, optional] A VARIANT that contains the variant ID to which the rule applies.
  • vrVariantID[Visual Basic]
    A Variant that contains the variant ID to which the rule applies.
  • fCategory[C++]
    [in, optional, defaultvalue (0)] A VARIANT_BOOL that specifies whether the parameter vrProductIDOrCategoryName is a product or a category. A value of True (-1) indicates a category. A value of False (0) indicates a product.
  • fCategory[Visual Basic]
    A Boolean that specifies whether the parameter vrProductIDOrCategoryName is a product or a category. A value of True (-1) indicates a category. A value of False (0) indicates a product. The default value is False (0).
  • fExclusion[C++]
    [in, optional, defaultvalue (0)] A VARIANT_BOOL that specifies whether this is an inclusion or exclusion rule. A value of True (-1) indicates an exclusion rule. A value of False (0) indicates an inclusion rule.
  • fExclusion[Visual Basic]
    A Boolean that specifies whether this is an inclusion or exclusion rule. A value of True indicates an exclusion rule. A value of False indicates an inclusion rule. The default value is False.

Return Values

[C++] This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic] None.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and either standard or custom COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to either standard or custom COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

The following table shows the custom COM errors that this method can return.

Constant Value Description
E_CAT_VC_NOT_A_VIRTUAL_CATALOG

[C++] 0x889800FA

[Visual Basic] &H889800FA

Invalid catalog type. This API can only be called on a virtual catalog.
E_CAT_INVALID_CATALOGNAME

[C++] 0x88980063

[Visual Basic] &H88980063

The catalog Name you specified is invalid. Catalog names cannot be blank
E_CAT_INVALID_CATALOG_NAME_LENGTH

[C++] 0x88980042

[Visual Basic] &H88980042

The catalog name you specified exceeds the maximum limit of 85 characters.
E_CAT_CHARACTER_NOT_ALLOWED

[C++] 0x8898003D

[Visual Basic] &H8898003D

The catalog name you specified has one of the nine reserved characters " [ ] , ' ( )#. which should not be used.
E_CAT_VC_INVALID_PROD_ID_OR_CATEGORY_NAME

[C++] 0x889800FB

[Visual Basic] &H889800FB

The value you specified for the ProductID or CategoryName exceeds the maximum allowed length of 348 characters.
E_CAT_VC_INVALID_VARIANT_ID

[C++] 0x889800FC

[Visual Basic] &H889800FC

The value you specified for the VariantID exceeds the maximum allowed length of 348 characters.
E_CAT_VC_INVALID_ITEM

[C++] 0x889800FD

[Visual Basic] &H889800FD

The specified product/category/variant could not be found in the base catalog.
E_CAT_VC_TOO_MANY_BASECATALOGS

[C++] 0x88980106

[Visual Basic] &H88980106

The limit (84) on the maximum number of base catalogs that can be included in a virtual catalog has been exceeded.

[C++] Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

If the fCategory parameter is True and the vrProductIDOrCategoryName parameter is an empty string, then the entire catalog will be included.

Exclusion rules always override inclusion rules. If you exclude a category you cannot include any category or product contained within that category. Conversely, you can exclude any category or product contained within a category you have included.

If a value is provided for the vrVariantID parameter, then the rule will apply only to that variant of the product. If any variant of a product is included, then the product will be implicitly included. It is not possible to have variant without a parent product.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

[Visual Basic]

Example

' You have a "Shoe" catalog.
' It contains "Mens","Womens", and "Kids" categories.
' Each category contains categories for dress, casual, and sports.
'   For example "Mens sports"

' The following rules result in including men's and women's categories 
' with their dress and casual subcategories.
' This could also be done using inclusion rules only.

myVCatalog.AddVirtualCatalogRule("Shoe", "Mens",, True, False)
myVCatalog.AddVirtualCatalogRule("Shoe", "Womens",, True, False)
myVCatalog.AddVirtualCatalogRule("Shoe", "Mens sports",, True, True)
myVCatalog.AddVirtualCatalogRule("Shoe", "Womens sports",, True, True)

'The following rules result in including the full "Mens" and "Womens" categories by including the catalog and excluding the "Kids" category.

myVCatalog.AddVirtualCatalogRule("Shoe", "",, True, False)
myVCatalog.AddVirtualCatalogRule("Shoe", "Kids",, True, True)

' If you then tried to include the Kids dress category as in:
'   AddVirtualCatalogRule("Shoe", "Kids dress",, True, False)
'   the method would return an error.

See Also

[C++]ProductCatalog Object

[Visual Basic]ProductCatalog Object

Copyright © 2005 Microsoft Corporation.
All rights reserved.