/   /   /  OroCommerce For developers: Content nodes and product Variants

Note:

For more extensions and themes visit our store

OroCommerce For developers: Content nodes and product Variants


OroCommece has an advanced web catalog to manage all frontend display related to catalog menu , products , landing page , So from admin Left Menu Products→ Master Catalog you have the ability to add all your category with many roots , and create restriction based to customer or customer group or localization , you can managing SEO , global product options by category …..

But the categories management is small part of catalog management often the B2B Shop need mutlti catalog display related to current customer or  need other links based on dynamic variant for example: adding to principal menu a root link with sub links which can show a dynamic products segment of specific brand or new arrival products with some condition for example just product created in some time Or... in the same time you want restrict  Links and Products display just for some of your customers,  So this very small opportunity gave by Marketing→ Web Catalogs , you can make all this complex job manually by admin user without coding.

What about Override Product Variant Configuration* : you should check if you don’t add product manually , if you have added by segment or by expression .  
And from note we have : If has selected, all simple product variants included into this product collection will be displayed on the page regardless of "Display Simple Variations" setting in the system configuration. Please note that this applies only to the products included via "Advanced Filter", as both "Manually Added" and "Excluded" products do not depend on this configuration option.

If you don’t check it and you use an external 3d party lib for example to reindex the integer.manually_added_to_variant well get added to criteria , but if you didn’t add manually products so for example integer.manually_added_to_variant_1 didn’t get reindexed so you have an empty result .
All fields added to website reindexing:

  1.  
  2. Oro\Bundle\ProductBundle\Entity\Product:
  3.     alias: oro_product_WEBSITE_ID
  4.     fields:
  5.         -
  6.             name: product_id
  7.             type: integer
  8.         -
  9.             name: sku_uppercase
  10.             type: text
  11.         -
  12.             name: status
  13.             type: text
  14.         -
  15.             name: type
  16.             type: text
  17.         -
  18.             name: inventory_status
  19.             type: text
  20.         -
  21.             name: is_variant
  22.             type: integer
  23.         -
  24.             name:  all_text
  25.             type:  text
  26.             store: false
  27.             default_search_field: true
  28.         -
  29.             name:  all_text_LOCALIZATION_ID
  30.             type:  text
  31.             store: false
  32.         -
  33.             name: assigned_to_ASSIGN_TYPE_ASSIGN_ID
  34.             type: integer
  35.         -
  36.             name: image_product_large
  37.             type: text
  38.         -
  39.             name: image_product_medium
  40.             type: text
  41.         -
  42.             name: product_units
  43.             type: text
  44.         -
  45.             name: primary_unit
  46.             type: text
  47.         -
  48.             name: attribute_family_id
  49.             type: integer
  50.         -
  51.             name: manually_added_to_ASSIGN_TYPE_ASSIGN_ID
  52.             type: integer
  53.  

 
manually_added_to_ASSIGN_TYPE_ASSIGN_ID for example is : integer.manually_added_to_variant_1

assigned_to_ASSIGN_TYPE_ASSIGN_ID: integer.assigned_to_variant_1

The manually_added_to_ASSIGN_TYPE_ASSIGN_ID well get reidexed inside class vendor/oro/commerce/src/Oro/Bundle/ProductBundle/EventListener/ManuallyAddedProductCollectionIndexerListener.php just if some products has been added manually to some variant

assigned_to_ASSIGN_TYPE_ASSIGN_ID: well get indexed if the variant has used which means all the time

the query related to last display based on variant get built in commerce/src/Oro/Bundle/ProductBundle/DataGrid/EventListener/SearchContentVariantFilteringEventListener.php :

by event  onBuildAfter of datagird  frontend-product-search-grid

  1.  
  2.     oro_product.datagrid.event_listener.search_content_variant_filtering:
  3.         class: Oro\Bundle\ProductBundle\DataGrid\EventListener\SearchContentVariantFilteringEventListener
  4.         arguments:
  5.             - '@oro_product.handler.request_content_variant'
  6.         calls:
  7.             - [setConfigManager,  ['@oro_config.manager']]
  8.         tags:
  9.             - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.pre.frontend-product-search-grid, method: onPreBuild }
  10. - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.frontend-product-search-grid, method: onBuildAfter }


the part of code is:
  1.  
  2. $datasource
  3.             ->getSearchQuery()
  4.             ->addWhere(Criteria::expr()->eq(sprintf('integer.assigned_to_variant_%s', $contentVariantId), 1));</p>
  5.  
  6. <p>        $overrideVariantConfiguration = $event->getDatagrid()
  7.             ->getConfig()
  8.             ->offsetGetByPath(self::OVERRIDE_VARIANT_CONFIGURATION_CONFIG_PATH);
  9.         if ($overrideVariantConfiguration) {
  10.             $datasource
  11.                 ->getSearchQuery()
  12.                 ->addWhere(Criteria::expr()->gte('integer.is_variant', 0));
  13.         } elseif ($this->isVariationsHideCompletely()) {
  14.             $datasource
  15.                 ->getSearchQuery()
  16.                 ->addWhere(Criteria::expr()->orX(
  17.                     Criteria::expr()->eq(sprintf('integer.manually_added_to_variant_%s', $contentVariantId), 1),
  18.                     Criteria::expr()->eq('integer.is_variant', 0)
  19.                 ));
  20.         }
  21.  

Test to Override Product Variant Configuration*:

  1.  
  2.         $overrideVariantConfiguration = $event->getDatagrid()
  3.             ->getConfig()
  4.             ->offsetGetByPath(self::OVERRIDE_VARIANT_CONFIGURATION_CONFIG_PATH);
  5.  

Done!

Comments

IBNAB is a company made of a group of professionals whose work is providing secure open source solutions. Our company strives for reaching magnificent results with each experience and provides professional open source solutions that cover every part of the business process.