Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

AJAX Attribute Manager support


Guest

Recommended Posts

When adding a new product the price box for the attribute is empty. But if I save it, go back in and edit it, the 0.00000 shows. I if I go ahead and put a + for the prefix and add a dollar amount in the price box beside it, than on the web site the attribute show up 3 times.

 

If I copy a product the 0.00000 shows in the price box. So I have been working around this problem by making a dummy product that's not active and just coping it.

 

I would like to fix error. I truly love this contributions.

 

Starla

Link to comment
Share on other sites

Replace this with
  $this->arrSessionVar[] = $getArray;

and everything should work fine. [] adds a new element to arrSessionVar (that's what we want), while [$id] replaces element arrSessionVar[''] ('' because $id wasn't set to any value before, so it's null, but since null isn't a valid array key, PHP's automatic type conversion comes into play). [$id] was neither in the bugfix nor in the original version, so I guess you somehow messed that up on your own. Well, shit happens all the time. :)

 

Btw. $id in update() isn't an actual id but just an array index. The actual ids are generated later by the database itself when attributeManagerUpdateAtomic.inc.php inserts the attributes.

 

You are my hero! Fantastic!

 

One slight thing still is that if I set AM_ATOMIC_PRODUCT_UPDATES to true it does not get the attributes. Maybe I screwed something else up!? If so which files / functions should be replaced?

 

Also I have separate price per customer installed and I wanted to add a button to the attribute lising rows next to delete attribute from option to popup the window to set this. I will probably do it in a crude popup way rather than ajax initially but could you point me to where the line listing the attribute properties and the delete button is created so I can put this in the right place? I will post my code when I have it working.

 

Martin

Link to comment
Share on other sites

I'm getting the following error when attempting to add an additional attribute to an existing option. I'm not have a problem creating new Options, Values, or adding the 1st attribute to a product. The error only occurs when adding a second attribute on an already assigned Option. Any ideas?

 

Here's the error:

 

1366 - Incorrect decimal value: '' for column 'options_values_price' at row 1

 

insert into products_attributes (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('5', '1', '1', '', '')

 

[TEP STOP]

 

I'm running this with the following:

IIS; PHP5.2.1; MySQL v5.0

Edited by eakatank
Link to comment
Share on other sites

Hi,

 

I tested with AM_ATOMIC_PRODUCT_UPDATE for a new product and an existing one with no attributes and it worked fine. The problem was when I tried a product that already had attributes as the existing ones were not listed.

 

I had a play with getAllProductOptionsAndValues() and got it to list some stuff but I could not translate between the instant version and the atomic version.

 

Here is the function:

 

	function getAllProductOptionsAndValues($reset = false) {
	if(0 === count($this->arrAllProductOptionsAndValues) || true === $reset) {
		$this->arrAllProductOptionsAndValues = array();
		$allOptionsAndValues = $this->getAllOptionsAndValues();

//		  echo '<br><br>Array ARRSESSVAR:: <br><br>';
//		print_r($this->arrSessionVar);

		$optionsId = null;
		foreach($this->arrSessionVar as $id => $res) {
			if($res['option_id'] != $optionsId) {
				$optionsId = $res['option_id'];
				$this->arrAllProductOptionsAndValues[$optionsId]['name'] = $allOptionsAndValues[$optionsId]['name'];
			}
			$this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['option_value_id']]['name'] = $allOptionsAndValues[$optionsId]['values'][$res['option_value_id']];
			$this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['option_value_id']]['price'] = $res['option_value_price'];
			$this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['option_value_id']]['prefix'] = $res['prefix'];
			if (AM_USE_SORT_ORDER) {
				$this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['option_value_id']]['sortOrder'] = $res['sortOrder'];
			}
		}
	}
	return $this->arrAllProductOptionsAndValues;
}

 

The thing I noticed straight away was that there is no DB query to get existing products unlike in the Instant version. Is this done elsewhere or should the query be here.

 

The Instant function is:

 

function getAllProductOptionsAndValues($reset = false) {
	if(0 === count($this->arrAllProductOptionsAndValues)|| true === $reset) {
		$this->arrAllProductOptionsAndValues = array();

		$allOptionsAndValues = $this->getAllOptionsAndValues();

		$queryString = "select * from ".TABLE_PRODUCTS_ATTRIBUTES." where products_id = '$this->intPID' order by ";			
		$queryString .= !AM_USE_SORT_ORDER ?  "options_id" : AM_FIELD_OPTION_VALUE_SORT_ORDER;
		$query = amDB::query($queryString);

		$optionsId = null;
		while($res = amDB::fetchArray($query)) {
			if($res['options_id'] != $optionsId) {
				$optionsId = $res['options_id'];
				$this->arrAllProductOptionsAndValues[$optionsId]['name'] = $allOptionsAndValues[$optionsId]['name'];
			}
			$this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['name'] = $allOptionsAndValues[$optionsId]['values'][$res['options_values_id']];
			$this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['price'] = $res['options_values_price'];
			$this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['prefix'] = $res['price_prefix'];
			if (AM_USE_SORT_ORDER) {
				$this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['sortOrder'] = $res[AM_FIELD_OPTION_VALUE_SORT_ORDER];
			}
		}
	}
	return $this->arrAllProductOptionsAndValues;
}

 

The other discrepency I noticed was $res['options_id'] vs $res['option_id'] ?!?!

 

I wondered whether to fix this some code to run on start up like an include_once or with a variable flag to populate the session variable. Maybe the Instant code could be placed inside the Atomic function to run only on initiation.

 

I'm guessing slightly and I got stuck on the different spellings of e.g. option(s)_id.

 

Any one with any ideas because I think if this is cracked then I will be bug free !!! :D

 

Martin

Link to comment
Share on other sites

Hi,

 

I am trying to put a button in attribute manager to popup the box from separate price per customer to allow separate attribute prices to be set for different customers. in attributeManager.php I added:

 

<?php /* MS_added popup separate price per group */ echo '<input type="image" border="0" onclick="window.open(\'' . tep_href_link(FILENAME_ATTRIBUTES_GROUPS, 'attribute_id=' . $?????????????, 'NONSSL') . '\',\'' . NAME_WINDOW_ATTRIBUTES_GROUPS_POPUP . '\',\'menubar=yes,resizable=yes,scrollbars=yes,status=no,location=no,width=500,hei
ght=350\');return false" src="attributeManager/images/users.png" >';?>

 

I can post a link to the image if anyone wants it.

 

Where $??????????? is the variable representing the "products_attributes_id" field from table "products_attributes".

 

What holds this info in attribute manager?

 

Also, will this remain the same as updates are done though attribute manger or will this id change with each update?

 

Martin

Link to comment
Share on other sites

Hello

 

I am using the ajax attribute manager and i have some questions cause something is going a bit wierd and you might can help me solve it.

 

There a few things who are going a bit wierd though i love to use it!

 

- I can't ad or remove attributes from the module (when i want to do that the box will turn white and nothing is working)

- I can't change the normal attributes section anymore (cant switch to the pages into the attributes manager as well, it will stay at page one even though i want to switch to page 31 by example.

- when i want to add an extra prize to some items i can't it will show off double in the product in the webshop. (and no extra costs are show off in the product) *see for an online example http://www.miss-salsa.nl/shop/product_info...products_id=226 *

 

I hope someone can help me fix this issues, cause i love to use it!

 

Thanks in advance

 

Vanessa

www.miss-salsa.nl

Edited by Delsea
Link to comment
Share on other sites

@msinternet:

Sorry, wasn't here for some time because my comp went up in smoke. Literally. Well, not too bad - it ran 24/7 for more than 6 years, killing 3 CPU fans in the process. The first two times I was able to notice that something was wrong and replace the fans just in time. The third time, I somehow missed the warning signals...

 

About the variable names: They're a mess, but there is a plan:

Names in plural (eg. "options_id") are for fields in database queries.

Names in singular (eg. "option_id") are for fields in local arrays.

Names in CamelCase (eg. $optionsId) are for variables.

 

Atomic mode does not work for existing products (editing). As you've figured out, it's missing an initialisation where the product's existing attributes are read. Updating the database in attributeManagerUpdateAtomic.inc.php also doesn't work as expected.

 

The following fix is not tested

 

First, the initialisation:

 

Add to attributeManagerAtomic.class.php (add it to the class):

  function getProductAttributes($get) {
$queryString = "select * from ".TABLE_PRODUCTS_ATTRIBUTES." where products_id = '".(int)$get['products_id']."' order by ";
$queryString .= !AM_USE_SORT_ORDER ?  "options_id" : AM_FIELD_OPTION_VALUE_SORT_ORDER;
$query = amDB::query($queryString);
while($res = amDB::fetchArray($query)) {
   $this->arrSessionVar[] = array( 'option_id' => $res['options_id'],
								   'option_value_id' => $res['options_values_id'],
								   'price' => $res['options_values_price'],
								   'prefix' => $res['price_prefix'],
								   'sortOrder' => $res[AM_FIELD_OPTION_VALUE_SORT_ORDER]);
}
 }

 

In attributeManagerGeneralFunctions.inc.php, replace function &amGetAttributeManagerInstance with:

function &amGetAttributeManagerInstance($get) {

 if (!is_numeric($get['products_id']) || AM_ATOMIC_PRODUCT_UPDATES) {

// first time visiting the page - delete the session var and start again
if(!tep_not_null($get[AM_ACTION_GET_VARIABLE])) {
  amSessionUnregister(AM_SESSION_VAR_NAME); 
} 
amSessionRegister(AM_SESSION_VAR_NAME, array());  
$attributeManager =& new attributeManagerAtomic(amGetSesssionVariable(AM_SESSION_VAR_NAME));
if (is_numeric($get['products_id'])) {
  $attributeManager->getProductAttributes($get);
}  
 } else {
$attributeManager =& new attributeManagerInstant($_GET['products_id']);
 }   

 return $attributeManager;
}

 

Finally, the update:

 

In attributeManagerUpdateAtomic.inc.php, replace

if(is_array(${AM_SESSION_VAR_NAME}) && is_numeric($products_id)){

with

 if(is_array(${AM_SESSION_VAR_NAME}) && is_numeric($products_id)){

amDB::query("delete from ". TABLE_PRODUCTS_ATTRIBUTES ." where products_id = '" . $products_id . "'");

The last one is pretty brute force - we just delete all the product's attributes from the database and then insert them again from the session var (as if it was a new product). A better way would be to re-read the original attributes (like in getProductAttributes()) and to check which attributes have actually been changed, added or removed.

 

Btw., there is a general problem with the atomic mode: It only works as long as editing/adding a product is done with a single call of the page which has the attribute manager. It doesn't work as soon as you want to call it again without updating the database in between. As an example, in my catalog products need to have unique model numbers. This means that it's possible to come back to the product page with an error message (model missing or model already exists) and without updating the database. And then you're screwed because the attribute manager forgets all changes made. Another problem comes when the user opens another tab/window for the same product (or another new product). Try this out: open the new product page, enter some attributes, then hit the green arrow next to Firefox's location bar with the middle mouse button (to open another new product page in a new tab) and see what happens...

Link to comment
Share on other sites

@msinternet:

Sorry, wasn't here for some time because my comp went up in smoke. Literally. Well, not too bad - it ran 24/7 for more than 6 years, killing 3 CPU fans in the process. The first two times I was able to notice that something was wrong and replace the fans just in time. The third time, I somehow missed the warning signals...

 

About the variable names: They're a mess, but there is a plan:

Names in plural (eg. "options_id") are for fields in database queries.

Names in singular (eg. "option_id") are for fields in local arrays.

Names in CamelCase (eg. $optionsId) are for variables.

 

Atomic mode does not work for existing products (editing). As you've figured out, it's missing an initialisation where the product's existing attributes are read. Updating the database in attributeManagerUpdateAtomic.inc.php also doesn't work as expected.

 

The following fix is not tested

 

First, the initialisation:

 

Add to attributeManagerAtomic.class.php (add it to the class):

  function getProductAttributes($get) {
$queryString = "select * from ".TABLE_PRODUCTS_ATTRIBUTES." where products_id = '".(int)$get['products_id']."' order by ";
$queryString .= !AM_USE_SORT_ORDER ?  "options_id" : AM_FIELD_OPTION_VALUE_SORT_ORDER;
$query = amDB::query($queryString);
while($res = amDB::fetchArray($query)) {
   $this->arrSessionVar[] = array( 'option_id' => $res['options_id'],
								   'option_value_id' => $res['options_values_id'],
								   'price' => $res['options_values_price'],
								   'prefix' => $res['price_prefix'],
								   'sortOrder' => $res[AM_FIELD_OPTION_VALUE_SORT_ORDER]);
}
 }

 

In attributeManagerGeneralFunctions.inc.php, replace function &amGetAttributeManagerInstance with:

function &amGetAttributeManagerInstance($get) {

 if (!is_numeric($get['products_id']) || AM_ATOMIC_PRODUCT_UPDATES) {

// first time visiting the page - delete the session var and start again
if(!tep_not_null($get[AM_ACTION_GET_VARIABLE])) {
  amSessionUnregister(AM_SESSION_VAR_NAME); 
} 
amSessionRegister(AM_SESSION_VAR_NAME, array());  
$attributeManager =& new attributeManagerAtomic(amGetSesssionVariable(AM_SESSION_VAR_NAME));
if (is_numeric($get['products_id'])) {
  $attributeManager->getProductAttributes($get);
}  
 } else {
$attributeManager =& new attributeManagerInstant($_GET['products_id']);
 }   

 return $attributeManager;
}

 

Finally, the update:

 

In attributeManagerUpdateAtomic.inc.php, replace

if(is_array(${AM_SESSION_VAR_NAME}) && is_numeric($products_id)){

with

 if(is_array(${AM_SESSION_VAR_NAME}) && is_numeric($products_id)){

amDB::query("delete from ". TABLE_PRODUCTS_ATTRIBUTES ." where products_id = '" . $products_id . "'");

The last one is pretty brute force - we just delete all the product's attributes from the database and then insert them again from the session var (as if it was a new product). A better way would be to re-read the original attributes (like in getProductAttributes()) and to check which attributes have actually been changed, added or removed.

 

Btw., there is a general problem with the atomic mode: It only works as long as editing/adding a product is done with a single call of the page which has the attribute manager. It doesn't work as soon as you want to call it again without updating the database in between. As an example, in my catalog products need to have unique model numbers. This means that it's possible to come back to the product page with an error message (model missing or model already exists) and without updating the database. And then you're screwed because the attribute manager forgets all changes made. Another problem comes when the user opens another tab/window for the same product (or another new product). Try this out: open the new product page, enter some attributes, then hit the green arrow next to Firefox's location bar with the middle mouse button (to open another new product page in a new tab) and see what happens...

 

well thank you for try, i tested this and my atributes still wont insert in database., anybody have some ideea ?

Link to comment
Share on other sites

I'm still getting the error described above.

 

1366 - Incorrect decimal value: '' for column 'options_values_price' at row 1

 

insert into products_attributes (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('5', '1', '1', '', '')

 

[TEP STOP]

 

I have removed and recreated the products_attributes table to ensure it's configured with the default settings....no luck. Do i need to alter the table to allow null values for options_values_price? Any help would be appreciated.

Link to comment
Share on other sites

I have my categories.php reorganized into div (for at tabbed look) therefore I have <?php require_once( 'attributeManager/includes/attributeManagerPlaceHolder.inc.php' )?> inside a div. All works fine except that the popup prompts (and the "blackout" that appears behind them) is down and to the right about 50px. I've tried making changes to the .css file to move the blackout or the popups, but no luck.

Does anyone know where/how I can move where this popup appears?

Thanks for any help, Im loving this Contrib

===================EDIT==================================

Here's what I tried and it almost works(could be about 10 more px to the right but much better)

in attributesManager.js I commented out lines 291, 292

 	
newBit.style.left = attributeManagerX;
newBit.style.top = attributeManagerY;

and changed starting at 308

	// work out the center postion for the box
leftPos = (((attributeManagerW - popupContents.scrollWidth) / 2) + attributeManagerX);
topPos = (((attributeManagerH - popupContents.scrollHeight) / 2) + attributeManagerY);

to

	// work out the center postion for the box

	leftPos = ((attributeManagerW - popupContents.scrollWidth) / 2);
topPos = ((attributeManagerH - popupContents.scrollHeight) / 2);

If anyone can comment on a better way to go about this please let me know

Edited by johnson4
Link to comment
Share on other sites

hi, i manged to make save this but i have this now

Fatal error: Call to undefined function: productattributes() in /home/prosp5/public_html/shopcart/admin/attributeManager/includes/attributeManagerGeneralFunctions.inc.php on line 39

 

 

how to fix i never see that function in this contrib.

please help.

Link to comment
Share on other sites

Well I managed to find a solution to my errors on my own. I ran across this thread and it seemed to resolve my problem. Apparently MySQL 5 enforces standards more strictly than MySQL 4. I suggest making the necessary adjustments if you have query errors while running MySQL 5.

Link to comment
Share on other sites

When adding a new product the price box for the attribute is empty. But if I save it, go back in and edit it, the 0.00000 shows. I if I go ahead and put a + for the prefix and add a dollar amount in the price box beside it, than on the web site the attribute show up 3 times.

 

If I copy a product the 0.00000 shows in the price box. So I have been working around this problem by making a dummy product that's not active and just coping it.

 

I would like to fix error. I truly love this contributions.

 

Starla

 

I Have the same problem

 

Infini

Link to comment
Share on other sites

I'm using v2.6 and get this error message.

"Session not registered - You cant access this page directly"

 

So I comment out line 47, and it works great.

// check that the file is allowed to be accessed

//stopDirectAccess::checkAuthorisation(AM_SESSION_VALID_INCLUDE);

 

Is this necessary to run it on PHP5/MySQL5 with register_globals off?

 

Thanks,

EricK

Link to comment
Share on other sites

  • 2 weeks later...

I am having the following problem with this contribution. I have installed everything correctly to my knowledge but when I try to test it out I get this error in my catalog page:

 

Warning: require_once(attributeManager/includes/attributeManagerHeader.inc.php) [function.require-once]: failed to open stream: No such file or directory in /home/zajanat/public_html/admin/categories.php on line 341

 

Fatal error: require_once() [function.require]: Failed opening required 'attributeManager/includes/attributeManagerHeader.inc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/zajanat/public_html/admin/categories.php on line 341

 

Not quite sure how to fix this, any help is greatly appreciated!

Always grateful for any help received!!

Link to comment
Share on other sites

The problem relates to the file not being available at:

 

catalog/admin/attributeManager/includes/attributeManagerHeader.inc.php

 

Make sure that this file exists on your webserver, and that it has the correct permissions (They should be correct if you havent changed any of these yourself).

 

Alex

Link to comment
Share on other sites

I'm having problems with this contribution -- I thought it could do something, but now I'm afraid maybe it can't.

 

I need a product's attribute to have a price that's based on whether or not another attribute is selected. Is that possible??

 

Example:

 

Product = Widget, which comes in Small, Medium and Large

Each size has three options: Light, Normal and Heavy

 

Small widget $10, Medium widget $15, Large widget $20

 

Small light is the $10 price, Small normal is $12, Small heavy is $14

Medium light is $15, Medium normal is $17, Medium heavy is $19

Large light is $20, Large normal is $22, Large heavy is $24

 

Can AJAX Attribute Manager do this? (I though it could, which is why I installed it!) If not, can someone please point me to an AJAX mod that does??

 

THANK-YOU!!!

 

OZ

Link to comment
Share on other sites

Dang, I have installed this and I haveno idea where it is in my admin panel. Can anyone help?

 

seriously, I have no idea where this is supposed to show up. cant find it anywhere. I uploaded the folder structure to a fresh install, added the nessesary code in the catalog.php in admin and see nothing different in the control panel. Mabye I am just not seeing it. Anyone?

Link to comment
Share on other sites

Using a fresh install of osCommerce 2.2 RC1, this is the only mod I've added. when trying to load an attributes template I'd just made, I get this error:

 

Fatal error: Call to undefined function sprint_f() in /home/a6576099/public_html/admin/attributeManager/includes/attributeManagerPrompts.inc.php on line 164

Link to comment
Share on other sites

Using a fresh install of osCommerce 2.2 RC1, this is the only mod I've added. when trying to load an attributes template I'd just made, I get this error:

 

Fatal error: Call to undefined function sprint_f() in /home/a6576099/public_html/admin/attributeManager/includes/attributeManagerPrompts.inc.php on line 164

 

 

Ok, I have got my junk figured out but I am now getting this same error. I am alos using a fresh 2.2 install.

 

atal error: Call to undefined function sprint_f() in D:\hosting\member\wuggie\catalog - Copy\admin\attributeManager\includes\attributeManagerPrompts.inc.php on line 132

Edited by loghova
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...