Jump to content

Recommended Posts

Hello all, 

 

I need some help here! I want to find a way to do this:

in an e-shop (not a real one just for a homework!) I want when a non registered user add items in his basket to have a php code that will understand the kind of user. For example

if the user add a pink tennis ball the code will understand that the user might be a woman and that might like sports. If user add a car fluid code will understand that the user has a car.

If user add in his basket a baby cream code will understand that user has a baby. So all the data the code will collect will be displayed somewhere in the page. For example: user is man, have car, have baby, between 30-50 years old. And somewhere in page will be a ads based to these results. For example user will see an advertising for baby food, or for a car product.

 

I need to make that for a homework, but I don't really know from where to start, can someone help me? Any help would be fine because I don't know from where to start! This thing called user profiling.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/300125-user-profiling-homework-need-some-help/
Share on other sites

Sure. Just keep in mind that buying pink tennis balls could mean the user has a dog, car fluid could mean they have a lawnmower, and baby cream could mean they use moisturizing cream. Profiling is nice but only if you get it perfectly right, otherwise you start thinking a 70 year old man is a young single mother.

 

My take after, like, 5 minutes of thought:

 

Store in the database a list of different profiles: woman, sports, dog owner, etc. Each one is tied to a particular PHP class*, implying that testing or invoking the profile will run the code. Then store another list of items with profiles: pink tennis balls -> woman, pink tennis balls -> sports, pink tennis balls -> dog owner, etc.

 

Each class follows a particular interface.

interface IProfiledItem {

	public function __construct(Item $item);

	public function evaluate(ShoppingCart $cart);

}
Adding an item fires up the code and has the class decide whether it's an appropriate profile according to the cart. Eventually you've gathered up a bunch of (potential) profiles.

 

* The code approach is faster but takes more effort to maintain over time. Long term, I'd probably try to put much more information in the database so more work can be generalized (eg, "profile A + profile B = profile C" or "item D suggests profile E at 50% and profile F at 20%").

OT: It's less work and more precise to simply link your products to possible advertising directly. Instead of using pseudo-meta information that has several conceptual flaws. Like requinix pointed out that baby cream could be linked to either a mother between the age of 16 and 35 and an old man of 60+. This couldn't be more far apart.

 

I understand this is homework and you won't have any say in the matter but nonetheless. Requinix already gave you the solution though I wouldn't generalize. So instead of simply stating Woman as a profile. I would add 'Mother (16 - 35)', 'Elderly man (60+)' etc..

 

Then for each new product that gets added like diapers for example will only contain 'Mother (16 - 35)' and do a array_intersect. So that 'Elderly man (60+)' gets excluded. As where Cane for example would exclude Mother.

 

I wouldn't simply drop the excluded tags but keep them in a separate array as a second source of meta information (hard versus soft tags).

 

For baby cream and diapers:

Hard tags: Mother (16 - 35), Baby (0 - 4)

Soft tags: Elderly man (60+)

Edited by ignace

You want to design something for a "homework" project that other people make careers out of. Is this project one of your own choice or was it really a hard assignment?

 

 

I know its hard...but professor gave it to me. So I have to create it somehow. 

Thank you all for your replies.

 

My thought was this: I create an e-shop in joomla with the virtuamart. I thought to add tags for each product and make the tags not visible in the page. So to make something like if has tag woman then add woman if has tag man then add man and if woman tags > than man tags then user might be woman etc etc. 

 

Requinix do you think its better to have in sql lists with the profiles? Or to add a "tags" table in the products? 

 

oh God it gets harder and harder to do this!

You need to sit down and visualize this problem. After all that's how all computer algorithms are developed. A problem is described, the data and processes are analyzed and the result is the solution. Then the programming begins.

 

In your case you have products that you want to take you to categories and from categories to other 'products', ie, the advertisements. So? You have to connect the dots here. Correct? Your products in the first case have to have some attributes to help you connect them to categories. Remember - some products may be so generic that you cannot make a positive connection so what are YOU going to do there? For most though you can probably make multiple category associations so what will you do in that case? This is the hard part. Do you assign multiple possible categories to a product and then lump them all together into some kind of query that seeks the most common category for the person based on multiple product selections? Decisions, decisions. That is the dilemma of any systems analyst.

 

Once you have the category selected the link to the actual ads you want to show becomes much clearer of course. Going from the distinct category to multiple ads will be easy since they can rotate or be presented in groups, whatever you want to do. The hard part is the above part when you are trying to go from multiple choices down to one or more categories.

 

How you implement this (so far we haven't thought about coding yet) is the last part. Tables/array/ifelse string/ etc. are the last things to work out. You have to visualize your problem and the pitfalls and make the decisions that will complete YOUR design. Then work out the implementation.

 

See why careers are made from this? Perhaps you could write up a 500 word synopsis of your thoughts on the problem and the possible solutions and/or pitfalls and present that to your professor to show how well you have analyzed the problem He might just be testing you on your thinking and not your programming.

Edited by ginerjm
  • Like 1

Thank you for your reply. The worst part of this case is that the professor can't really help me because he can't really do it his own... I mean he only say general things but when I ask something deeper hes just don't know what to say... and the final presentation of this homework will be in 2 other professors. 

 

Is the idea with the tags wrong you believe? 

What I thought as a plan is this:

I have 15 categories. Each category has 3-5 sub categories. Each subcategory has 15 products. 

I can use these subcategories for the user's profiling but I thought to add tags to any of each product so the profiling would be based of these tags.

After that I need to have somewhere in my page a small div that will show the process of the profiling of the user. So I must save somewhere the decisions of my code.

After that I will add in sql in users profile the new things that I want to be saved when the user will register in the site so the site would know after it what ads will show every time the user will log in.

 

Now I tried to add tags in products but I use the virtuamart and I can't find where is the php for the form of adding products for add the code for adding tags. But I will find it soon or later :P

But after that I thought to use if else for watching the tags of the products. But how can do that for the items that are in user's basket?

I'm with Jim here, you are coming at this with the wrong perspective.  You need to step back, sit down and look at the overall requirement.  You are coming at this by focusing on a specific part of the problem and spiraling out to try and capture the rest of the requirements as you go.  This is only going to get you tied up in knots and will eventually - on anything more than the most simple requests - result in you having to re-write a huge part of your code because it just doesn't have the scope to handle everything that your project requires.  Take the problem as a whole, find the start and the end, identify the specific requirements in between and then use that to crystallise the overall process. once you have that, break each part down and identify the stages required as well as the process flow between each part and remember to document everything in a way that you can follow. When you have that, and not before, then you start to code.  Some people have a gift, they can naturally visualise problems in this way and just jump in with a high degree of success, the rest of us have to spend anything up to three to four times as time on the project design stage as we do actually coding.

 

Dont try to run before you can walk.

 

We can't answer any more specific questions without seeing the full and proper project brief.  What you described in the original post has the potential to either be quite an intricate piece of software, or a fairly straightforward mock simplification.  Either way I can't find a way to use categories as defining characteristics and still keep them meaningful for a shopping cart.

 

Something else that you could consider would be looking at the currently available e-store software solutions and see if any of them do what you are trying to.  If there is all you need to do is quote it and give a brief essay on why "reinventing the wheel" is a waste of a developers time.

An if else s/b the last option. Too much maintenance.

 

If you have cats and sub cats and assigned products to each, why the tags? Seems like duplication of effort.

 

Again - work this thru in a thinking manner. Forget all about programming. Pretend it is not a computer problem but simply a business problem. Get a good design based on clear detailed thinking.

 

What do you mean you have by this line:

 

... and the final presentation of this homework will be in 2 other professors.

 

You have one professor giving you an assignment and no help and 2 others grading you? B.S!

 

Last question: What is the title of this course you are taking? What is the main subject matter you are trying to learn from it? Design & Analysis? Coding? Database technology?

Edited by ginerjm

If the problem persists to elude you. You can take the agile approach and use iterative development to get to the solution. What this means is that you start with very simple code that could work. For example a simple array with a mapping between products and tags/categories:

 

<?php

$tags = array(
  'woman' => 'Woman (16 - 35)',
  'infant' => 'Infant (0 - 1)',
  'child' => 'Child (1 - 4)',
  ..
);

return array(
  11 => array( // assume 11 = product baby cream
    $tags['woman'],
    $tags['infant'],
  ),
  ..
);
Then in your code:

 

<?php

class ShoppingCartEvaluatorImpl implements ShoppingCartEvaluator {
  public function __construct(array $mappings) {
    $this->mappings = $mappings;
  }
  public function evaluateShoppingCart(ShoppingCart $cart) {
    // ..
  }
}

// in your shopping cart

$evaluator = new ShoppingCartEvaluatorImpl(require '/path/to/product-mappings.php');
$evaluator->evaluateShoppingCart($cart);
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.