enabling 'Marketplace Product Kit' gives the following error

Notice: Undefined index: #node in mp_product_kit_form_alter() (line 14 of ............./sites/all/modules/ubercart_marketplace/mp_product_kit/mp_product_kit.module).

Comments

iRex’s picture

having the same issue. Does anyone have an answer?

thx

eduarrulho’s picture

US: having the same issue. Does anyone have an answer?
Brazil: Também tenho o mesmo problema, alguém sabe a solução?
Agradecido!

Salif’s picture

Same issue
Notice: Undefined index: #node in mp_product_kit_form_alter() (line 14 of /home/.../sites/all/modules/ubercart_marketplace/mp_product_kit/mp_product_kit.module).

sabrawy’s picture

same here + im clicking on rebuild permission but its not working

sabrawy’s picture

i have uninstalled "Marketplace Product Kit" till someone can fix it

Bigo’s picture

Hi,

this works for me.
I've set the control of variable $form['#node'] beacuse it exists surley in edit page of a product kit and not in other pages.
Then i've added "AND type IN ('product')" statement in query
And changed the reading of result in -> foreach ($result as $product) { which is drupal 7 compatible.

of course it could be done better but i've to finish work today ;)

hope it helps!

function mp_product_kit_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['#node'])) {
		$node = $form['#node'];
		if (is_object($node) && $form_id == $node->type . '_node_form' && $node->type == 'product_kit') {
		global $user;
		// TODO Please convert this statement to the D7 database API syntax.
		$result = db_query("SELECT nid, title FROM {node} WHERE uid = ".$user->uid." AND type IN ('product')");
		$products = array();
		foreach ($result as $product) {
		  $products[$product->nid] = $product->title;
		}
		if (!user_access('administer nodes')) {
		  $form['base']['products']['#options'] = $products;
		}
	  }
	}
}
liliplanet’s picture

perfect, it works, thank you!

phizes’s picture

Status: Active » Closed (duplicate)

The issue arises as the modules' hook_form_alter() runs on every form, regardless of whether it is or is not a node form, or a node of a different content type.

Closing as duplicate of #1812520: Patch which ports/should fix mp_product_kit for Drupal 7 which has a patch which addresses this issue as well as a few more.

kim51’s picture

> Bigo
It works, thank you!