summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Lindsay2012-08-04 12:36:16 (GMT)
committerAnthony Lindsay2012-08-04 12:36:16 (GMT)
commit7361150d97f8436fcbd49f37162ff4f642a333f4 (patch)
tree55ff6663c89cfc2546c901fc78ea80622d1337fc
parent26bfb65c5823e8bb885694d91ef5c3abc9e0a4ec (diff)
Initialised products array when settings empty and removed bad bock region.
-rw-r--r--commerce_popular_products.module22
1 files changed, 15 insertions, 7 deletions
diff --git a/commerce_popular_products.module b/commerce_popular_products.module
index 4df68ce..cb4fefb 100644
--- a/commerce_popular_products.module
+++ b/commerce_popular_products.module
@@ -136,7 +136,6 @@ function commerce_popular_products_block_info() {
// A block To display a popular product.
$blocks['popular-product-block'] = array(
'info' => t('Commerce Popular Products display block'),
- 'region' => array('Content'),
'weight' => '-50',
);
return $blocks;
@@ -193,6 +192,19 @@ function commerce_popular_products_settings_form($form, &$form_state) {
$number = variable_get('commerce_popular_products_number', $default = '1');
$products = variable_get('commerce_popular_products_products');
$title = variable_get('commerce_popular_products_title', 'Popular Products This Month');
+ $product_types = commerce_popular_products_get_product_types();
+ $options = array();
+
+ foreach ($product_types as $type) {
+ $options[$type] = $type;
+ }
+ if (!isset($products)) {
+ $product_array = array();
+ foreach ($product_types as $type) {
+ $product_array[$type] = 0;
+ }
+ $products = $product_array;
+ }
$form['block_title'] = array(
'#type' => 'textfield',
'#title' => t('Block title.'),
@@ -205,11 +217,7 @@ function commerce_popular_products_settings_form($form, &$form_state) {
'#description' => t('Product nodes to include in the popularity check.'),
'#default_value' => $products,
);
- $product_types = commerce_popular_products_get_product_types();
- $options = array();
- foreach ($product_types as $type) {
- $options[$type] = $type;
- }
+
$form['product_types']['#options'] = $options;
$form['time_period'] = array(
'#type' => 'radios',
@@ -236,7 +244,7 @@ function commerce_popular_products_settings_form($form, &$form_state) {
),
'#default_value' => $number,
);
- $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));;
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
return $form;
}