0
votes

Lets say I need to have some logic in this use case scenario. The user is on the WIX Online Store's Product page for a particular product and clicks on QTY to order more units of the product. The logic to add is to check against the inventory at that moment and send a Twilio SMS message to the Store owner as a warning(this use case is somewhat contrived).

The thing is I dont seem to see any examples on WIX online training that shows how the Corvid Database can be connected to existing WIX Online stores which have Products and Collections already defined (which I assume is kept in some database). How does the Corvid Database and the Online Store Products/Collections map and how is it done and how can Corvid js code access that ? By the way, the Corvid uses the term "Collections" which does not seem related to Product Collections which must be a source of confusion for many.

1
Wix Stores pre-created Products and Collections are read only Corvid Databases. You cannot change the permissions. So you can use Wix Data to query the Products database, but you cannot updated it. If you want to make changes to the Store's Products in the code, you'll need to use Wix Stores Backend.Meredith Hassett

1 Answers

0
votes

You can access your Wix-Stores products collection using the wix-data module.

import wixStoresBackend from 'wix-stores-backend'; // Not needed here but try in the editor
import wixData from 'wix-data';

const WIX_STORES_PRODUCT_TABLE = 'Stores/Products';

const getProducts = () => {
    return wixData.query(WIX_STORES_PRODUCT_TABLE)
        .find()
        .then((data) => {
            let wixInventory = data.items;
            return wixInventory
    }

If you start there you will see all the items in your Wix-Stores. You can further query the database/collection by narrowing down the query. There are some good starter examples in the Corvid documentation for query here.

Just as a note - Because the Wix-Stores collections are read only you can query them but you can't write to them. If you have a look at wixStoresBackend within the Corvid editor the code completion there shows that you can update some parameters of a product however, you will need to modify a product's item if you want to adjust things like quantity.