18.11.2015 Views

Beginning Drupal 8

Todd Tomlinson - Beginning Drupal 8 (The Expert's Voice in Drupal) - 2015

Todd Tomlinson - Beginning Drupal 8 (The Expert's Voice in Drupal) - 2015

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 22 ■ Building a Commerce Site<br />

To continue building the example commerce site, create an example hat and an example coffee cup<br />

following the same process as for the <strong>Drupal</strong> Flys T-shirt, with the only exception being that hats only come<br />

in colors, not sizes, and coffee cups are available in only one color and one size. I’ll use the hats product<br />

variation to create a hat and use the generic “Product display” to create a cup.<br />

If I now click the category links at the top of the page, clicking Cups displays the one cup that I created,<br />

clicking Shirts displays the <strong>Drupal</strong> Flys shirt, and clicking Hats displays the hat that I created.<br />

Displaying Products<br />

There are many things you can do to display products on your storefront. You can place links to individual<br />

products on menus or as embedded links in content; you can use the taxonomy listing approach as<br />

demonstrated on the example site by clicking the categories near the top of the page; or you can create views<br />

to display products based on the criteria and filtering mechanisms you employ in your view. As an example,<br />

I’ll create a product listing view for all products on my site, sorted and grouped by category. To follow along,<br />

hover over the “Site settings” link on the admin menu and then click the Views link in the drop-down menu.<br />

Click the “Add new view” button on the Views page, and on the “Add new view” page (see Figure 22-14), do<br />

the following:<br />

1. Give the view a name; in this case I’ll call it Product.<br />

2. Select Commerce Product from the Show select list to indicate what to show in<br />

the view.<br />

3. Leave All as the type of product to display, as we want to show all product types.<br />

4. Leave the view as Unsorted.<br />

5. Click the “Continue & edit” button.<br />

Figure 22-14. Creating a Product view<br />

255

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!