There are times when it’s convenient to load up an ad hoc collection of Shopp products. For example, today I was working on a site where I have relationships setup between Shopp products, and another post type called “Story Cards”. I set this relationship up using Posts 2 Posts, which is one of the most powerful plugins around. It’s truly amazing, and built by a true engineer.
On this particular site, I needed to show products that relate to a particular story card. Using the Posts 2 Posts API, it was really easy to get an array of product ID(s) from the Posts 2 Posts, but I really needed to take it a step further and render those products using the standard Shopp collection template.
So, I used this bit of code:
I’ve added a couple of comments to show the important parts. Basically, you have to set a slug or the Shopp Theme API gets a bit confused as it isn’t used to ad hoc collections. But, once you overcome this, the rest just works.
So there you have it. That’s the easiest way I know to load an ad hoc collection of Shopp products and render it using the Shopp Theme API.