How to find all the collections that your product belongs to on Shopify

Shopify’s REST API is a powerful tool for managing your store. It gives your apps direct access to product catalogues, customer records, and orders for just about any analysis you can imagine. However, the path to the data you need is not always obvious. For instance, it’s easy to find a product inside of a collection, but what if you need a list of collections that your product belongs to?

This is really useful data if you have a lot of product collections, whether they are created by hand or generated automatically. The answer to this question is not found in the Products endpoint of the rest api. There are two endpoints dedicated to collections, Collection, and CustomCollection. The first one retrieves automatic collections, the kind that include products that have special tags or other criteria. CustomCollection covers collections where the products have been added by hand or by a custom app.

You can find custom collections that contain your product by providing the product id.

GET /admin/api/2021-04/custom_collections.json?product_id=632910392

If you are using the Shopify Rest API gem, this line of code will do.

current_collections = ShopifyAPI::CustomCollection.find(:all, :params => {:product_id => shopify_product.id})

This also works for the collect API as well.

GET /admin/api/2021-04/collects.json?product_id=632910392

And here’s the ruby code for that operation.

current_collections = ShopifyAPI::Collection.find(:all, :params => {:product_id => shopify_product.id})

Now that you have the JSON data back from the API, you can pretty much do what you like with it. You can put the collections in separate lists, you can combine them, or you can cross-reference it and remove the product from collections it shouldn’t belong to.

I hope that allows somebody to take little bit more control of their Product Data. If you want to get more tips like these, feel free to subscribe to my newsletter!

What I do in 2021

As part of my 30×500 coursework, I’m supposed to be building clout with my audience by posting educational content. Since already kind of have an audience (Hello, you!) I thought it would be kind of jarring to just start posting random e-commerce advice. Kind of like when people go from posting about their kids to posting about weight-loss supplements? So I’m just going to give a bit of context and talk about what I do for work these days.

Programmer is one word for what I do, but that covers a lot of different jobs I’ve done. I’ve worked on crime mapping programs, soil databases, school enrolment systems, and online car advertisement systems. Each project involved learning new techniques and facing new challenges.

Nowadays, I run a website called Fire-parts.com. It’s the largest online retailer for gas fireplace parts in the US and Canada. I started off working on it as a contract for a previous job, but now I work on it full time.

It’s powered by an e-commerce web software package called Shopify. If you shopped online outside of Amazon, chances are you’ve used it yourself. There are open source software packages like Magento and Woocommerce that you can install yourself on your own rented server, but they require a lot of little tweaks to get working properly. Shopify handles a lot of those features all by itself.

It also has the added benefit of not having as many heavy handed merchant standards as platforms like eBay and Amazon. Although Shopify allows you to connect to those platforms, Amazon in particular has been known to severely punish merchants who ship items late or run out of stock unexpectedly. Getting back online involves a lengthy process of writing letters detailing your process and how “this will never happen again, Mr. Bezos sir”. With Shopify, such matters are settled between you and your customers.

Does it have its limitations? Sure it does, but you can work your way around most of those by using their app platform. There are apps for marketing, product searches, user experience, and a whole lot more. You can even build custom apps yourself to really set your store apart from your competitors.

Fire-parts has one such custom app, and it’s the one that I spend most of my day working on. It’s a searchable database containing manuals for over 10,000 fireplace models. Whereever possible, it scrapes the manuals for part numbers, which we cross reference with our product database. When you find the manual you’re looking for, it will not only display the manual itself, but any instructional videos we have, related documents, and a parts list. Thousands of fireplace professionals all over North America use this system to find the parts that they need. My job is to add new features to this database so it has more models, more parts, a better interface, and a better search engine than any other competing database.

So that is what I do now. I have some special expertise, but I’m always looking to improve. That’s why I enroll in courses like 30×500. Another great way to improve your knowledge is to take what you know, put it in a new context, and help some people with their problems. People have lots of questions about Shopify, so I’ll try to answer a few on this blog and see how it goes. Of course, if you have any questions yourself, Let me know and I’ll try to answer them here too. And as always, you can join my mailing list and you’ll get the answers straight into your inbox.

How I’m doing Social Media right now

Like most people, I have a complicated relationship with social media. On the one hand, posting is free labor for multi-billion, growth-at-all-cost megacorporations that have left us drowning in misinformation. On the other, to put it bluntly, it is where the people are. So if you’re trying to build a reputation for a business or anything else, your only other option is a classified ad in the newspaper.

So I’m still taking the marketing course. That means I have to use my social media more often. What does that look like?

It looks like more posting on Twitter. The platform allows me to use automation services like buffer.com, and I can use their analytics to figure out what kind of content spreads. I get more engagement out of Facebook, but it’s more for keeping in touch with people I already know. Same with instagram. Those platforms also don’t allow automated posting, so I’ll be using them less often.

It also means a bit of Spring cleaning. I’ve been on Facebook and Twitter for more than 10 years, and I don’t need anything I said 10 years ago to embarrass me now. I also want to make separate online identities, basically having a public identity for stuff I create, and private accounts for stuff I consume. Not everybody needs to know I subscribe to wikipedia titles that sound like Teenage Mutant Ninja Turtles. I also want to stop following accounts that don’t follow me back. I’m trying cut down on the para-social relationships, you know?

Facebook and Twitter both offer options to download and archive your data. On Twitter, you can use tweetdelete.com to delete all of your tweets before a certain date. Deleting Facebook and instagram posts is trickier because they are more nervous about any automated activity on their site. Plus, they want to make removing your data as slow and ponderous as humanly possible.

When it comes to separating your online identities, you’re going to have accounts you’ll want to keep, accounts you’ll want to get rid of, and accounts you’ll want to follow on another account. To make this process easier, there’s a tool called Phantom Buster that will scrape all that data from your Instagram and Twitter and put it in a handy csv spreadsheet. Phantom Buster is capable of much more complex monitoring tasks, but if you just need to scrape a couple of personal accounts, their 14 day free trial is all you need.

It’s hard to believe after all this time we are still figuring out how this internet thing is supposed to work. What to post, where to post, and how to post is still an open question for most of us. I still think we adhere to the pareto principle here. 80% of the content is likely produced by only 20% of the users. So if you are taking the time to post essays, take photos, or anything else on the internet that’s not consuming, you are already part of an exclusive club. I hope I’ve shown you some tools that can help you manage your online identity in a way that makes you feel comfortable. At its best, social media can help people build communities that just aren’t possible in the real world. I hope to be speaking with more of you out there really soon.

Again, if you want to see me write more without the social media companies getting in the way, you can always subscribe to my mailing list. I’ve figured out the mailchimp templates this time, I promise!

I’m in 30×500!

In a world of sweeping societal change, deadly pandemics, and the creeping spectre of climate change, what can a man do to better himself, his loved ones, and civilization itself?

Well, this man took a marketing course on the internet. Sure, there are worse things I could be doing. I could’ve been renovating and flipping houses, for instance. I admit it’s an underwhelming outcome, but when there’s so much uncertainty, you have to invest in the one resource that’s actually in control: yourself.

I picked a course called 30×500. It’s run by Amy Hoy and Alex Hillman, two very prominent people in my industry. They call it 30×500 because if you create a book, a podcast, or software that 500 people will pay $30 a month for, it works out to $15,000 a month, which is not a bad living.

I’m not sure I’ll make that much. In fact I’ll be ecstatic if I make the tuition back. What I’m really excited about is all the structure that I’ll be giving to all these side projects I’ve had over the years. I’m like most creative people. I come up with ideas constantly, but I don’t have a framework to execute it or get the kind of money to keep working on my ideas. The “30×500 approach” involves choosing and studying audiences so I can come up with the kind of ideas that will provide value. So, I can keep looking for shiny new things to work on, but this way I can find ways to justify them.

You can find out more about this course at stackingthebricks.com. Of course, I’m not just telling you about this because you’re all smart people and I like you. This is course work! I need to tell my audience (that’s you) about all of these new projects that I’m doing if I ever expect them to launch. That’s why I’ve now got a mailing list. I will need you to head to www.james-strocel.com and enter your e-mail into the sidebar. That way my blog posts will head to your mail box no matter what the algorithms on your social media have to say about it. Thanks in advance!

Processing…
Success! You're on the list.

The Day After, Once Again.

We’re not getting any time to process this. The American government is still in place, but the damage is done, the insult complete. The assault on the Capitol building in Washington D.C. didn’t even get the dignity of having barbarians at the gate. It was carried out by people cosplaying as barbarians. Now it’s coming out that many of the rioters used their statuses as police officers and military veterans to get past the barricades.

It’s so difficult to figure out what I’m looking at here. Yes, there was a riot in the US Capitol. Yes, the rioters were disgruntled Trump supporters. They deserved to fail and get all the consequences this current system of government will afford them. Still, I feel like I’m playing this children’s story of what society is in my head, over and over again. It’s failing to explain all of this.

Is this a worker’s revolt? It doesn’t seem like it, the rioters were based out of the Hilton and flew in on their own dime. The body armor they wore doesn’t come cheap either. Is this the system trying to re-establish itself? If so, why did it fail so spectacularly? Where is this all leading?

There are lots of historical precedents for this. Hitler’s Beer Hall Putsch of 1923, Mussolini’s march on Rome, even the Wilmington Massacre of 1898, which was a turning point in establishing segregation in the American South. The coups in Wilmington and Rome succeeded, and the Beer Hall Putsch led to the prison sentence where Hitler wrote “Mein Kampf”.

The facts are still coming in, but I think one thing is clear: Our ignorance is catching up to us. I didn’t know about the Wilmington Massacre until this week, and I’ve only recently started reading books about white supremacy like “Policing Black Lives” by Robin Maynard or “So you want to talk about Race” by Ijeoma Oluo. If we acknowledged how our societies are built on taking land, labor, and rights away from people we deemed “uncivilized”, we would have had a stronger sense of why Donald Trump’s rioters were wrong and how Black Lives Matter is trying to make our society safer. If we had a better grasp on society as it is, rather than what we wished it was, none of this would have happened.

I want to make a special shout out to everyone who said something like this would happen and were written off as anxious. I for one thought this would end in a comedy chase scene across the Mar-a-lago golf course, but the reality is more unsettling. It’s as if irony is not only dead, but has been re-animated in some kind of uncanny facsimile. It takes more than just anxiety to make these predictions. It also takes imagination and curiosity, qualities we’ll need a lot more of to get us through this.