Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / product_music/collect_info.php $pInfo

product_music/collect_info.php $pInfo

Locked

Views: 2,651

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
8 Apr 2007, 11:53 AM
#1
david_bo avatar

david_bo

New Zenner

Join Date:
Oct 2006
Posts:
23
Plugin Contributions:
0

product_music/collect_info.php $pInfo

I am working on a new product type. I use product_music as a template for that.

In "admin/includes/modules/product_music/collect_info.php" I see

<tr> <td class="main"><?php echo TEXT_PRODUCTS_MUSIC_GENRE; ?></td> <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_pull_down_menu('music_genre_id', $music_genre_array, $pInfo->music_genre_id); ?></td> </tr>

How and where has the $pInfo got the "music_genre_id" key?

8 Apr 2007, 2:38 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: product_music/collect_info.php $pInfo

$pInfo is built from the database fields extracted at the top of the file.

8 Apr 2007, 4:12 PM
#3
david_bo avatar

david_bo

New Zenner

Join Date:
Oct 2006
Posts:
23
Plugin Contributions:
0

Re: product_music/collect_info.php $pInfo

I think it happens here:

if (isset($_GET['pID']) && empty($_POST)) {
$product = $db->Execute("select pd.products_name, pd.products_description, pd.products_url,
p.products_id, p.products_quantity, p.products_model,
p.products_image, p.products_price, p.products_virtual, p.products_weight,
p.products_date_added, p.products_last_modified,
date_format(p.products_date_available, '%Y-%m-%d') as
products_date_available, p.products_status, p.products_tax_class_id,
pe.artists_id, pe.record_company_id,pe.music_genre_id,
p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
p.product_is_free, p.product_is_call, p.products_quantity_mixed,
p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max,
p.products_sort_order,
p.products_discount_type, p.products_discount_type_from,
p.products_price_sorter, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd,
" . TABLE_PRODUCT_MUSIC_EXTRA . " pe
where p.products_id = '" . (int)$_GET['pID'] . "'
and p.products_id = pd.products_id and p.products_id = pe.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
$pInfo->objectInfo($product->fields);

} elseif (zen_not_null($_POST)) {
$pInfo->objectInfo($_POST);
$products_name = $_POST['products_name'];
$products_description = $_POST['products_description'];
$products_url = $_POST['products_url'];
}

But when is $_POST not empty? and in case $_POST isn't empty with what and where has it been populated?

9 Apr 2007, 4:16 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: product_music/collect_info.php $pInfo

if (isset($_GET['pID']) && empty($_POST)) {
$product = $db->Execute("select blah blah...");
$pInfo->objectInfo($product->fields);

} elseif (zen_not_null($_POST)) {
$pInfo->objectInfo($_POST);

}

... translates to: if pID is set on the URL and POST is empty (ie: the page was entered by clicking on "Edit" and is therefore pre-populated from previous data-entry), then pull the data from the database based on PID. Otherwise, pull the data from POST (because we're viewing it as part of a data-entry exercise and need to display what was entered. This includes returning to the data-entry screen after clicking "go back" from the "preview" screen or if a validation error occurs when submitting the information.

11 Apr 2007, 3:53 PM
#5
swortis avatar

swortis

New Zenner

Join Date:
Mar 2007
Location:
Cambridge, MA
Posts:
59
Plugin Contributions:
0

Re: product_music/collect_info.php $pInfo

Related question (I hope):

Can the dropdown menu for music_genre (or others) be changed to a text field, so that any entry will remain associated with the specific product?

(And if so, how would you recommend doing this? I've tried a variety of things all to no avail..)

12 Apr 2007, 9:16 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: product_music/collect_info.php $pInfo

swortis:

Related question (I hope):

Can the dropdown menu for music_genre (or others) be changed to a text field, so that any entry will remain associated with the specific product?

(And if so, how would you recommend doing this? I've tried a variety of things all to no avail..)

No ... you need to set up your Genres, etc using the input areas found on the Admin->Extras menu. The lists of items built here then become available for selection in the music product pages.

12 Apr 2007, 1:36 PM
#7
swortis avatar

swortis

New Zenner

Join Date:
Mar 2007
Location:
Cambridge, MA
Posts:
59
Plugin Contributions:
0

Re: product_music/collect_info.php $pInfo

Seems like there should be a way to change the way the form takes in information - using a text field rather than the drop down array... as it does with product name for instance.

I'm currently in the process of adding additional "choices" to product_music/collect_info.php (such as Producer, Engineer, Mastering info etc.) I've been able to successfully set up the additional db tables, and add the additional fields to the Extras menu so as to create dropdown menus. However, a text field makes far more sense as this sort of information is rarely repeated..

12 Apr 2007, 1:47 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: product_music/collect_info.php $pInfo

You can certainly write custom code to capture free-form input and have it manually add new records to the relevant relational tables if the entered item doesn't already exist. You will want to guard against typographical errors by doing some sort of data-validation.

12 Apr 2007, 5:51 PM
#9
swortis avatar

swortis

New Zenner

Join Date:
Mar 2007
Location:
Cambridge, MA
Posts:
59
Plugin Contributions:
0

Re: product_music/collect_info.php $pInfo

So I take it there would be a problem if that input info already did exist? Or am I misunderstanding?

The price of the product is input this way (text field; often repeating information)