Calling Developers!
We are reenergizing our code contribution process! Learn More

Bug in generating keys for Redis.

Options
filip.gojkovic955
filip.gojkovic955 Spryker Solution Partner Posts: 19 ✨ - Novice

Hi I'm working on implmentation of FactFinder in spryker system.

I found out that sku that gets returned from FactFinder is used to generate redis key. With that redis key we are querying redis to get the data.

Method in ProductAbstractStorageReader class(vendor/spryker/product-storage/src/Spryker/Client/ProductStorage/Storage/ProductAbstractStorageReader.php) called "findProductAbstractStorageDataByMapping".

That method is called in my case fro 10 places:

As picture suggest those are all bridges from some glue API. Method has first parameter "MAPPING TYPE".

If I go to see what value does $mappingType have it is always "sku"


The method "findProductAbstractStorageDataByMapping" generates $reference

$reference = $mappingType . ':' . $identifier;

Identifier is SKU of product. Let's take some sku. For example i have sku "M100000068" for one abstract product.

$reference = "sku" . ":" . "M100000068";
So result is "sku:M100000068"

Key generation in redis has some rules and are defined in xml file.

Key is build like:
resource, store, locale, key_suffix_column
Example: product_abstract:de:de_de:515


Since glue apis and FactFinder are concatenating reference as "sku" . ":" . "[sku_number]" that reference would never match any of the keys in redis since keys in redis have different logic of generation.

When i call FactFinder or any GLUE apis that were mentioned in bridges in picture above.
They will generate key like:
"product_abstract:de:de_de:sku:sku:M100000068"

And all keys in redis will look like.
product_abstract:de:de_de:515

All of that being said. I can not see a way for this to work. Is this a known bug? Or am I missing something?

Comments

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,016 ⚖️ - Guardians (admin)
    Options

    Heyhey @filip.gojkovic955 ,

    for me it sounds reasonable what you write there - yet I have not validated it by myself.

    The best would be if you file a bug-report through the official support portal so the team can take it to further investigations :)

    All the best,

    Florian

  • harry
    harry Developer Posts: 9 🧑🏻‍🚀 - Cadet
    Options

    I got same things

    I tried use \Spryker\Client\ProductStorage\ProductStorageClient::findProductAbstractStorageDataByMapping

    example:

    $this->getFactory()
    ->getProductStorageClient()
    ->findProductAbstractStorageDataByMapping('sku', $itemTransfer→getSku(), 'en_US')
    

    expected:

    the response show me the product abstract data

    actually:

    the response is null

    ##############

    I found the redis storage saved the data look like this

    But actually the key generated was be set is: product_abstract:de:en_us:sku:115_21811723

    So I think the response will be null if we try to get data with the function findProductAbstractStorageDataByMapping

  • harry
    harry Developer Posts: 9 🧑🏻‍🚀 - Cadet
    Options

    @Alberto Reyer can you help for verify this issues ?