Hi Guys, I am running on 1.5.6 new store and I am trying to add two new product fields. I am trying to add product_h1 and product_desc2 which will be for adding a header on the products and for adding a second description on the page. I have done the following:
1. Added the text defnitions for the admin for both of these in admin/includes/languages/english/product.php
2. updated admin/includes/functions/general.php to create new functions zen_get_products_h1 zen_get_products_desc2
3. updated admin/includes/modules/product/collect_info.php for the following:
Added below 'products_description' => '',
Code:
'products_h1' => '',
'products_desc2' => '',
Added after pd.products_description,
Code:
pd.products_h1, pd.products_desc2,
Added after $products_description = isset($_POST['products_description']) ? $_POST['products_description'] : '';
Code:
$products_h1 = isset($_POST['products_h1']) ? $_POST['products_h1'] : '';
$products_desc2 = isset($_POST['products_desc2']) ? $_POST['products_desc2'] : '';
Added the following inputs for the h1 and desc2
Code:
<div class="form-group">
<?php echo zen_draw_label(TEXT_PRODUCTS_H1, 'products_h1', 'class="col-sm-3 control-label"'); ?>
<div class="col-sm-9 col-md-6">
<?php
for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
?>
<div class="input-group">
<span class="input-group-addon">
<?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>
</span>
<?php echo zen_draw_input_field('products_h1[' . $languages[$i]['id'] . ']', htmlspecialchars(isset($products_h1[$languages[$i]['id']]) ? stripslashes($products_h1[$languages[$i]['id']]) : zen_get_products_h1($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS_DESCRIPTION, 'products_h1') . ' class="form-control"'); ?>
</div>
<br>
<?php
}
?>
</div>
</div>
<div class="form-group">
<?php echo zen_draw_label(TEXT_PRODUCTS_DESC2, 'products_desc2', 'class="col-sm-3 control-label"'); ?>
<div class="col-sm-9 col-md-6">
<?php
for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
?>
<div class="input-group">
<span class="input-group-addon">
<?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>
</span>
<?php echo zen_draw_textarea_field('products_desc2[' . $languages[$i]['id'] . ']', 'soft', '100%', '30', htmlspecialchars((isset($products_desc2[$languages[$i]['id']])) ? stripslashes($products_desc2[$languages[$i]['id']]) : zen_get_products_desc2($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE), 'class="editorHook form-control"'); ?>
</div>
<br>
<?php
}
?>
</div>
</div>
4. Updated admin/includes/modules/update_product.php
added after (isset($_POST['products_model']) ? $_POST['products_model'] : '')
Code:
. (isset($_POST['products_h1']) ? $_POST['products_h1'] : '') . (isset($_POST['products_desc2']) ? $_POST['products_desc2'] : '')
added after 'products_description' => zen_db_prepare_input($_POST['products_description'][$language_id]),
Code:
#'products_h1' => zen_db_prepare_input($_POST['products_h1'][$language_id]),
'products_desc2' => zen_db_prepare_input($_POST['products_desc2'][$language_id]),
5. Updated admin/includes/modules/product/preview_info.php
added after $products_description = $_POST['products_description'];
Code:
$products_h1 = $_POST['products_h1'];
$products_desc2 = $_POST['products_desc2'];
added after pd.products_description,
Code:
pd.products_h1, pd.products_desc2,
added after $pInfo->products_description = zen_get_products_description($pInfo->products_id, $languages[$i]['id']);
Code:
$pInfo->products_h1 = zen_get_products_h1($pInfo->products_id, $languages[$i]['id']);
$pInfo->products_desc2 = zen_get_products_desc2($pInfo->products_id, $languages[$i]['id']);
added after $pInfo->products_description = zen_db_prepare_input($products_description[$languages[$i]['id']]);
Code:
$pInfo->products_h1 = zen_db_prepare_input($products_h1[$languages[$i]['id']]);
$pInfo->products_desc2 = zen_db_prepare_input($products_desc2[$languages[$i]['id']]);
6. added two new columns in the product_description table names products_h1 and products_desc2
I feel like I could be missing something, Everything displays correctly on the admin side, the inputs show correctly. If I manually enter the products_h1 and products_desc2 in phpmyadmin they will show on the admin when I try alter the product, however as soon as I try update the product these will be rewritten with blanks. Can anyone see anything?
Bookmarks