I recently worked on a reasonably large shopify project where the potential categories (collections) counted approximately 190. We built the menu based on those collections, but the problem was that until we had products imported for those collections we didnt want to show the menu item.

Using the supply menu I edited the site-nav.liquid file in the snippets directory and added a line under each of the for loops that build the menu items and added a test to see if a. the time was based on a collection and if the number of products in that collection where over 0. This was done using an <%unless %> tag – look at the bolded lines below.

Yep.. I’ve joined the dark side.. from .net to python.. What is more I’m moving away from Ecommerce Sites that i have built from scratch to the more universal Shopify Platform (at least for evaluation reasons)

On first blush this may be better as an ecommerce site than i expected. It has some shocking limitations like only supporting a VERY limited number of payment gateways and having little to no concept of an ACH transaction (ones that take money directly from a persons bank account.. WAY cheeper than running credit card transactions..

One of my tasks was to see if we could write code to generate a menu based on our products taxonomy. Out of the box our company sells around 130 different categorys and if we didn’t script this creation it would be really easy to have unreachable products after the import. The fact that Shopify doesn’t really even understand categories isn’t that much of a problem.. What it does have is “collections”, “collections” come in 2 flavors, dynamic and static.

Because we want automatic incorporation of products as they are uploaded into Shopify the correct choice is dynamic.

So.. how did we manage to script the creation.. Most of the documentation is in PHP.. but our current flavor of language is python and as much as it is probably possible to just convert the code over, shopify was nice enough to create a PYTHON based api that allows you to work with both the ADMIN api and STOREFRONT api. The ADMIN api actually providing all the ability required to work with products or collections

You also need to generate API keys for shopify. To do this login to your store and create a new “app key”

Log into your store and in theme actions click “Edit Code”

On the next screen select “Apps” in the left hand menu.

On the Apps Screen select (at the bottom of the page) “Manage Private Apps”

If you don’t already have one click the button labeled “Create a new private app” (top right)

On the next screen review all the permissions available and what they pertain to (select the ones you need)

You will need the followitn values after going to your app (copy them somewhere)
API key
Password
Shared secret
and example u8rl (as a sanity check)

From the python side you need to install the Shopify Python API (docs:http://shopify.github.io/shopify_python_api/)

open a bash prompt

use pip to install the api pip install –upgrade ShopifyAPI

In this example I’m just going to create a simple python file that can be executed from a command prompt of some type. (bash or dos)

x = shopify.SmartCollection().find()print('-------------------------------------------------------------')
# print x
for y in x:
# if y.attributes["title"] == "rob test":
# print y.__dict__# prints all the properties of the collection
# print y.attributes['title']
print y.__dict__
# the properties are all stored in a dictionary.. you can loop through

# them if needed.
print('-------------------------------------------------------------')

I found a great blog that talked about manifest files.. but this one is WAY easier.

Right click the exe file you are trying to run that is giving you weird scaling issues.

Select “Compatibility”
Look for a setting “Override high DPI scaling behavior. Scaling Performed by.. And if the box is checked. uncheck it or if it is unchecked, check it. In photoshop where menus etc were tiny, I needed to check it. WIth another app where the fonts where HUGE I had to uncheck it.

the code below is basically a for loop that continues until a counter reaches a value..

@echo off
:: turn off echo
set /a var=1
:: initialize a numeric variable and set it to 1
:LOOP
:: a label to define the start of the loop
if %var% gtr 254 goto :END
:: the if test the variable and if it is > 254 (gtr) it sends the code to the label END
echo %var%
::return current value to screen
set /a var+=1
::increment counter
goto LOOP
::go back to the top of the loop and increment the number again.
:END

I recently decided to finally upgrade my tried and true copy of IE10.. knowing full well i was about to lose some of my favorite Developer Tools – not an easy decision.. but i got sick of videos not playing due to compatibility issues.

Result.. I lost my dev tools and still couldn’t play videos.. I did find a few online solutions that suggested adding the following to the end of the youtube url to make it work..&nohtml5=1
The problem was that you had to append that to EVERY video in Youtube and *#& help you if you want to watch an embedded video.

Today i found the real solution. To view video in the first place you needed to add the “Desktop Experience” to server 2008. The problem is that that version of “Desktop Experience” didn’t support the latest video formats or codecs.. So you need to upgrade/update the Desktop experience..

All it does is attach to the keydown of any element it is attached to and look to see if the key being pressed is numeric via a regular expression. Nothing fancy. no periods, no commas, no currency formatting.

Useful for making sure credit card numbers or bank account numbers are being entered correctly in a web page.