Outside Links collection
Sometimes you find just the right resources that fulfill certain need and nothing much should be added to them, in those cases I will just collect them on this page and add short comment why is this so.
How to combine Git and Drush to have perfect workflow for site maintenance, information and examples are here
http://www.jenlampton.com/blog/keeping-your-drupal-site-date-git-and-drush
Setting upt perfect Git + Drush workflow, read here
http://www.acquia.com/blog/using-git-drush-win-workflow
An overview of Drupal's cache_clear_all uses
Drupal has a very simple, yet powerful (low level) caching system. It provides 3 functions that should please all you caching needs: cache_get, cache_set and cache_clear_all. The first two are pretty straight forward to use, but the third one might take some time to wrap your head around.
It accepts 3 argument: a cache ID, table cache and a wilcard boolean. Each combination of these 3 has a very different result. Here's an overview of all combinations.
cache_clear_all()
Passing no arguments to cache_clear_all is the same as saying the following
cache_clear_all(NULL, 'cache_block');
"Price is locked and cannot be edited" - how to unlock this or any other field
So to cut it short, just write this in your code, probably devel/php, change the filed name and you will have unlock a filed (probably commerce_price field).
$field = field_read_field($field_name);
$field['locked'] = 0; // 0: unlock; 1: lock.
field_update_field($field);
After you do what you need to do, you should put it back to lock.
Importing wordpress (ver 3 and 4) users to Drupal 7, how to solve password problem
So importing data from WP is not so hard, you can do it in different ways, mapping data as you need. But what to do about passwords. they are encrypted, WP uses "one-way encryption" and you will need hacker to know what is in them. There are 2 methods.
1. Copy paste
Logging mysql on localhost
In mysql 5.6+. Use this:
[mysqld]
general_log = on
general_log_file=/usr/log/general.log
in your my.cnf / my.ini file
http-response set-header X-Frame-Options DENY will break AJAX on edit forms
We had on server this thing set
http-response set-header X-Frame-Options DENY
Which in the end made all the ajax form on node edit/add, product edit/add stop working and throwing out errors on browser console.
Refused to display 'https://dev.site.com/system/ajax' in a frame because it set 'X-Frame-Options' to 'DENY'.
So this cant be used that way in drupal.
DB Uploading from local to remote
mysqldump -u user -p databasename > dump.sql
Then using SCP transfer the file to the remote server:
scp dump.sql [email protected]:
Then use the mysql client there to import the dump.sql with:
mysql -u user_name -p databasename < dump.sql
Ajax error on node add/edit, opened a new browser window instead of file upload or reference edit
One of those things. We have spent 4 hours, 2 persons combined hunting down this problem. Google GTM code, which we for specific reason enabled on node add forms, broke all ajax forms and made crayze problem of opening new browser window instead of editing the node reference field with inline entity form. The same thing happened also on image upload widget. Remove google GTM code from page, solved the issue.
Two ways to change patterns in pathauto
First is to use hook_pathauto_pattern_alter and add some code to it like
// Switch out any [node:created:*] tokens with [node:updated:*] on update.
if ($module == 'node' && ($context['op'] == 'update')) {
$pattern = preg_replace('/\[node:created(\:[^]]*)?\]/', '[node:updated$1]', $pattern);
}
}
where in context you will find all the date you need to match specific entity and language
Or you can use Variables and make a token out of it and it is i18n aware.
Getting product display info from product ID and building node object with only needed fields
$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node', '=')
->propertyCondition('type', 'product_display')
->fieldCondition('field_product_reference', 'product_id', '1092', '=')
->range(0, 1);
If node is present, we do the array building
if ($result = $query->execute()) {
$nodeview = $result['node'];
// At first we need to get field's id. If you already know field id, you can ommit this step