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

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Can someone please tell me where is the price data for abstract products saved in the database?

Options
U048WDEP3R7
U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet

Can someone please tell me where is the price data for abstract products saved in the database?

Comments

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    @U048WDEP3R7 It should be in the same table where the concretes' are stored too: in spy_price_product_store

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    Unless you're looking for the storage tables, because those are separated by abstracts and concretes (spy_price_product_abstract_storage and spy_price_product_concrete_storage). But the base price data should be in the aforementioned one, together for both abstracts and concretes.

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @U04FXCTCWPP I am on B2B store. Are they same on B2B as well?

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    edited January 2023
    Options

    @U048WDEP3R7 Should be, as I'm on a B2B store too and I see said tables in my store.

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @U04FXCTCWPP Basically I am working on a custom product import. To add prices for abstract product, I am updating spy_price_product and spy_price_product_store . But I still can not see the prices in backoffice in the "Price & Tax" section when editing an Abstract product. Can you please tell me if there is something else I need to do?

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    @U048WDEP3R7 And do your abstract products really do have prices of their own in the import data source? Because as I know, abstract products don't necessarily need to have a price, only concretes. Maybe your abstract products don't have any price data to begin with?

    Also, I assume you checked that your import really did update the price data in the DB? If yes, then you might also try to debug the code when opening the "Price & Tax" tab in the backoffice (or the product detail page in the shop) and see what data it gets from where and how - and this way you'll be sure to find the source of the problem.

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @U04FXCTCWPP Actually, I am manually added the abstract price data. Something like this:

    $this->setDataSetWriterPersistenceState(false);
    
            // todo try to initiate the following import sequences with chain of command pattern
    
            // adding/updating abstract product
            $spyAbstractProductId = $this->createOrUpdateProductAbstract($dataSet);
    
            // adding price
            // todo move it to a separate function
    
            $spyPriceProduct = new SpyPriceProduct();
            $spyPriceProduct->setFkPriceType(1);
            $spyPriceProduct->setFkProductAbstract($spyAbstractProductId);
            $spyPriceProduct->save();
    
            $spyPriceProductId = $spyPriceProduct->getIdPriceProduct();
    
            $spyPriceProductStore = new SpyPriceProductStore();
            $spyPriceProductStore->setFkCurrency(93);
            $spyPriceProductStore->setFkPriceProduct($spyPriceProductId);
            $spyPriceProductStore->setFkStore(1);
            $spyPriceProductStore->setGrossPrice(9002);
            $spyPriceProductStore->save();
    
            // adding/updating localized product abstract
    
            $this->createOrUpdateProductAbstractLocalizedAttributes($dataSet, $spyAbstractProductId);
    

    Just trying to figure out how can I show up the prices in the backoffice like this. So it seems like there is another schema that also needs to be updated.

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    @U048WDEP3R7 And did you check that these values were indeed added to your DB?

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @U04FXCTCWPP Yes I checked. They are being added.

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @U04FXCTCWPP Here are the relevant screenshots

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    That's probably not the problem, but you really should add a net price data too.

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    Other than that, looks good to me so far. As I said above, you really should check with a debugger to see what is happening when the backoffice (or the store) tries to get the price for the product. Then you could see immediately what the problem is.

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    Sometimes it happens that errors get "swallowed" by try/catches deep in the code and you don't even notice them unless you step it through with the debugger.

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @U04FXCTCWPP thanks. I will try to debug it now 🙂

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    yw 🙂

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    @U048WDEP3R7 I checked a bit further and I think you're missing a connection in the spy_price_product_default table

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @U04FXCTCWPP Unfortunately, I did that as well but still doesnt work

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    Hmm... do you also have the DEFAULT and the ORIGINAL entries in the spy_price_type table?

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    also, what you have in your spy_price_product_default table is wrong

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    because the fk you have there is not the same as the id in your price_product_store table

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    There, you have 7711, and here you have 959

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    @U048WDEP3R7 I think this latter mismatch will be your problem. Try updating that 959 fk value to 7711 in your spy_price_product_default table.

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 🧑🏻‍🚀 - Cadet
    Options

    @U04FXCTCWPP WOW that was the issue. I missed it. Thank you very much for pointing that out.

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet
    Options

    yw 🙂