Last active
August 29, 2015 14:01
-
-
Save yanniboi/acf877aa0e293e5e5fc2 to your computer and use it in GitHub Desktop.
Unpublish CD and DVD talks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Unpublish CD and DVD mediums fro talks. | |
| */ | |
| function sss_tweaks_update_7002(&$sandbox) { | |
| $query = "SELECT nid FROM {node} WHERE type='talks'"; | |
| // Set up vars. | |
| if (!isset($sandbox['total'])) { | |
| $result = db_query($query); | |
| $sandbox['total'] = $result->rowCount(); | |
| $sandbox['current'] = 0; | |
| } | |
| $range = 50; | |
| // Get the nodes to process during this pass. | |
| $result = db_query_range($query, $sandbox['current'], $range); | |
| while ($row = $result->fetchAssoc()) { | |
| // Load the node, edit its title, and save the node. | |
| $wrapper = entity_metadata_wrapper('node', $row['nid']); | |
| if (!empty($wrapper->field_product->value())) { | |
| foreach ($wrapper->field_product->value() as $product) { | |
| if ($product->title == 'CD' || $product->title == 'DVD') { | |
| $product->status = 0; | |
| commerce_product_save($product); | |
| } | |
| } | |
| } | |
| // @TODO Log progress. | |
| $sandbox['current']++; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment