You are here

Nick Vahalik's blog

Importing a price in Drupal 8 for Drupal Commerce 2.x

Just a quick note that if you're importing a Commerce price:

  • you must set the currency_code.
  • what was commerce_price in DC 1.x / Drupal 7 is now just price.
  • the number can be a decimal now.

    'price/number': SomeFieldName 'price/currency_code': plugin: default_value default_value: 'USD'

Note that you can also set up a constant in the migration definition and use the constant value:

You can chain callbacks in a Drupal 8 migration

If you're wanting to do some advanced processing (e.g. lowercasing a word and then capitalizing the first letter) you can chain the two callbacks to get the desired effect:

Quickly importing new config entities from the command line using Drush

Drush's cset command is a bit picky, but with a few command line options, we can get it to import a yaml file into our site's config:

drush -y --format=yaml cset config.entity.string '' - < config_file.yml

This will put the entirety of config_file.yml into the configuration entity config.entity.string.

Field Tools as a replacement for Features

One of my new favorite modules recently has been Field Tools. What I love about it is that it presents you with the ability to export all of the fields on a particular bundle (or even just a single field).

Then, you can just use field_create_field or field_create_instance in a little loop.

Take for example (in a module's .install file):

Modifying distribution Makefiles within your own project Makefile on Platform.sh

As I've written about in the past, Platform.sh's Makefile build system is pretty sweet. One of the things that confuse me the most, however, is how to make a change to a distribution (such as adding a patch) without making things even more complicated.

Hat tip to Tavi Toporjinschi for writing the original example this is based off of.

Acquia Dev Desktop and the Drupal 7 test runner

Recently, I tried to run some tests locally and the test runner kept silently failing. Ultimately, it was just giving up during bootstrap. The problem was eventually traced to Acquia's frustrating modification of the settings.php file; it only loads when $_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] is defined.

So in order to make it run, you'll need to:

All code (and coding) is moral

So I was reading through some blogs this weekend and came across an article about VW on the Clean Code blog. It's a short post and I suppose if you wanted a summary blurb, it would be this:

I think that argument is even more asinine than Michael Horn's. They knew. And if they didn't know, they should have known. They had a responsibility to know.

Recreate Drupal's users table from url_alias table

So I needed to recreate a truncated users table to stop the Drupal admin from barfing all over the admin... the url_alias table has the UID and the user names in it... so why not?

Using Acquia DevDesktop with a site that has domain access and multiple languages

Acquia DevDesktop can be pretty slick at times for development, but if you're trying to work with a site that has domain access AND internationalization, you may be scratching your head a bit.

First off, you must correct the entries for the default site (or whichever site you're testing) in the domain and languages tables.

But then...

You'll need this patch since Drupal 7.x Core doesn't handle port numbers properly.

Then your site will work!

Pages