Page 1 of 1
Trying to Pull in the Value of a Certain Field
Posted: Tue Jul 29, 2008 11:58 am
by Danielc1234
I am trying to set up a condition and pull in the value of an attribute (part of a field for a specific item) named ‘manufacturer’
Since I do not know php this is becoming very frustrating, but I’m sure this is a no brainer for someone who does.
The ‘if’ condition is working fine and I have it pulling in the options ID from the database with no problem. I want to replace the getID to pull in the manufacturer of the product that is being viewed.
Here is the code:
<?php if ($_option->getTitle() == "Select Color") {echo $_option->getId();} ?>
I would appreciate any help at all.
Thanks
Daniel
Re: Trying to Pull in the Value of a Certain Field
Posted: Tue Jul 29, 2008 12:03 pm
by mabwi
What are you doing with the data when you get it back from the Database?
Is the getId() function of the _option object supposed to return the Id? What you've posted seems fine, if the code we don't see is correct. What exactly is the problem, and where's the problem code? A better explanation of how the data is stored after it's retrieved from the Database will help.
Re: Trying to Pull in the Value of a Certain Field
Posted: Tue Jul 29, 2008 12:15 pm
by Danielc1234
Sorry my explaination is weak. I'm not really familar with php.
This part of the code {echo $_option->getId();} is pulling from the database a category number. So its getting this number from category data that is set up in the database. I am only using this as an example here. What it really needs to do is to be able to view or pull the manufacturer of this particular product that the customer is viewing.
Within the database, when setting up products/items, their is a field or attribute named 'manufacturer' which stores just that, the name of the manufacturer that makes the product that the customer is looking at.
My goal here is to pull in the manufacturer so that I can create a URL using that code to open a color swatch window, but directly relates to that particular manufacturer.
I know its confusing because re-reading this doesnt make much sense to me either. Hopefully you will understand enough to ask another question! lol.
Thanks
Re: Trying to Pull in the Value of a Certain Field
Posted: Tue Jul 29, 2008 1:00 pm
by mabwi
OK... $_option is an object. getId is a method of that object that returns the ID number. This much I understand.
You now want to get a different piece of data from the Database. Am I correct that the class $_option comes from is not one you created? Does it store the manufacturer data in there? If not, can you just add a method that queries the database the same as the getId method, but pulls the manufacturer instead of an Id?
If you can give more information on the structure of the program, that would be great, and save me from randomly guessing at what you might or might not know/have in place already/be able to add.