Example: Simple product (with pre-selection)
GraphCommerce enables various ways to manage the display of data from configurable products in Magento. This flexibility allows you to choose dynamic updates for the following data:
Add the following to your graphcommerce.config.js
file:
Determines whether a simple product should appear as a Configurable Product with pre-selected options or as the default Simple Product.
When the products(filters: { url_key: { eq: 'simple-product' } }) { ... }
query is ran, Magento also returns besides the requested Simple product also the
Configurable product the simple belongs to.
If that is the case we render the Configurable Product page instead of the Simple Product page, but the options for the Simple Product are pre-selected.
const config = {
configurableVariantForSimple: true,
}
module.exports = config
Add the following to your graphcommerce.config.js
file:
url
: When a variant is selected the URL of the product will be changed in
the address bar. Note that this only occurs when the actual variant can be
accessed through the URL.
content
: Use the name, description, short description and meta data from the
configured variant
gallery
: This option enables the automatic update of product gallery images
on the product page when a variant is selected, provided that the gallery
images for the selected variant differ from the currently displayed images.
const config = {
configurableVariantValues: {
url: true,
gallery: true,
content: true,
},
}
By default Magento will return the simple and configurable for a simple variant, no configuration required.
To make the automatic swithcing of URL's possible, make sure the simple product
has a URL by making sure it's visibility is set something different than
Not Visible Individually
: Catalog
, Catalog, Search
or Search
.
Catalog -> Products -> [product] -> Visibility: [Catalog / Catalog, Search / Search]