I am trying to print out information from a list. I thought I had this figured out but realized It was just printing out the same information over and over.
This is from a Joomla website and I am using the J2store extension, just to give you the information from where this is coming from.
So this is suppose to print out all the attributes from a single order. Each item in the order has any number of attributes that make it up. I am using it as an assembly site. So each assembly will have different attributes that make it up. (Hope that explains it good enough.)
[code][php]
<?php JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_j2store/models'); $model = JModelLegacy::getInstance( 'OrderItemAttributes', 'J2StoreModel' ); ?> <?php foreach (@$items as $item) : ?> <?php //these are just printed to show the 5 different items in the same order echo $item->order_id; echo ''; echo $item->orderitem_id; echo '
'; echo $item->orderitem_name; echo '
'; $model->setState( 'filter_orderitemid', $item->orderitem_id); $attributes = $model->getList(); foreach($attributes as $attribute) { if(!empty($attribute->orderitemattribute_value)) { echo $attribute->orderitemattribute_name.' : '.$attribute->orderitemattribute_value; echo '
'; } } echo '
'; ?> <?php endforeach; ?>
[/php][/code]
This ends up printing out this:
1402100770
49
16" Box to Stud Bracket with Open Back Box + Modular Duplex
BRACKET : B-Line BB7-16
BOX : Crouse Hinds TP40DPF
Mud Ring (Choose an Option) : 3/4’’ Rise Single Gang
MC Cable (Choose an Option) : 12/2 (black,white,green) x 25’ L
Device (Choose an Option) : Hubbell 20A SnapConnect Duplex with Connector
Device Color (Choose an Option) : White
MC Connector (x2) : Crouse Hinds 38MCQ
12/2 Anti-Short (x2) : 12/2 Anti Short
11" Cable Tie (x2) : 11’’ Cable Tie
4 Port Wago (x3) : Ideal Model 88
Device Protector Plate : B-Line BPR1
1402100770
52
3/4" Conduit Masonry Stub
BRACKET : B-Line BB7-16
BOX : Crouse Hinds TP40DPF
Mud Ring (Choose an Option) : 3/4’’ Rise Single Gang
MC Cable (Choose an Option) : 12/2 (black,white,green) x 25’ L
Device (Choose an Option) : Hubbell 20A SnapConnect Duplex with Connector
Device Color (Choose an Option) : White
MC Connector (x2) : Crouse Hinds 38MCQ
12/2 Anti-Short (x2) : 12/2 Anti Short
11" Cable Tie (x2) : 11’’ Cable Tie
4 Port Wago (x3) : Ideal Model 88
Device Protector Plate : B-Line BPR1
1402100770
53
3/4" Conduit Masonry Stub
BRACKET : B-Line BB7-16
BOX : Crouse Hinds TP40DPF
Mud Ring (Choose an Option) : 3/4’’ Rise Single Gang
MC Cable (Choose an Option) : 12/2 (black,white,green) x 25’ L
Device (Choose an Option) : Hubbell 20A SnapConnect Duplex with Connector
Device Color (Choose an Option) : White
MC Connector (x2) : Crouse Hinds 38MCQ
12/2 Anti-Short (x2) : 12/2 Anti Short
11" Cable Tie (x2) : 11’’ Cable Tie
4 Port Wago (x3) : Ideal Model 88
Device Protector Plate : B-Line BPR1
1402100770
51
MC Cable Whip Assembly
BRACKET : B-Line BB7-16
BOX : Crouse Hinds TP40DPF
Mud Ring (Choose an Option) : 3/4’’ Rise Single Gang
MC Cable (Choose an Option) : 12/2 (black,white,green) x 25’ L
Device (Choose an Option) : Hubbell 20A SnapConnect Duplex with Connector
Device Color (Choose an Option) : White
MC Connector (x2) : Crouse Hinds 38MCQ
12/2 Anti-Short (x2) : 12/2 Anti Short
11" Cable Tie (x2) : 11’’ Cable Tie
4 Port Wago (x3) : Ideal Model 88
Device Protector Plate : B-Line BPR1
1402100770
50
Span Bracket with 4 SQ. Deep 1/2’’-3/4’’ KO’s + Modular 2 Single
BRACKET : B-Line BB7-16
BOX : Crouse Hinds TP40DPF
Mud Ring (Choose an Option) : 3/4’’ Rise Single Gang
MC Cable (Choose an Option) : 12/2 (black,white,green) x 25’ L
Device (Choose an Option) : Hubbell 20A SnapConnect Duplex with Connector
Device Color (Choose an Option) : White
MC Connector (x2) : Crouse Hinds 38MCQ
12/2 Anti-Short (x2) : 12/2 Anti Short
11" Cable Tie (x2) : 11’’ Cable Tie
4 Port Wago (x3) : Ideal Model 88
Device Protector Plate : B-Line BPR1
The number ‘1402100770’ is the order number. Which in that order there were 5 items purchased. The numbers for the orderitem_id are the correct numbers for the order number. The name is also the correct for the items that were in the order.
The problem is when the attributes print out. It prints the same attributes for all 5 items purchased.
It seems to be printing the first items attributes for all the items in the order.
I can’t figure out why the orderitem_id and orderitem_name all prints out correctly but when it prints of the attributes it just prints the same attributes for all the items in the order.