Inheritance not supported on Event Listener?

I’m attempting to implement Assortment Subtenants to separate products for a multi-store environment. It works great if I index the products from the command line, but if I save the product from the admin interface, it ignores inheritance and just returns blank. That seems to be the case when attempting to access inherited attributes from an Event Listener. The products are also Variants, if that matters. Let me know if you need me to include any further details.

$backup = DataObject\AbstractObject::getGetInheritedValues();
DataObject\AbstractObject::setGetInheritedValues($inheritValues);

$result = $function();

DataObject\AbstractObject::setGetInheritedValues($backup);

Or use https://github.com/coreshop/CoreShop/blob/master/src/CoreShop/Component/Pimcore/DataObject/InheritanceHelper.php

Perfect! That got me pointed in the right direction. It appears as though Pimcore does something very similar when calling “prepareDataForIndex” in AbstractBatchProcessing (https://github.com/pimcore/pimcore/blob/master/bundles/EcommerceFrameworkBundle/IndexService/Worker/AbstractBatchProcessingWorker.php#L185). Since I need to have inheritance set before they set it in that function, I ended up just creating a function in my own worker that does the same thing:

public function prepareDataForIndex(IndexableInterface $object)
{
    $b = AbstractObject::doGetInheritedValues();
    AbstractObject::setGetInheritedValues(true);
    $data = parent::prepareDataForIndex($object);
    AbstractObject::setGetInheritedValues($b);
    
    return $data;
}

I noticed in theirs, they call “doGetInheritedValues”, which appears to have a few extra checks and things vs. calling getGetInheritedValues directly. It may not matter, but figured I’d match theirs.