I am building an webapplication for retailers to register purchased products in PHP/MySQL.
What I like to do now is to populate a dropdown menu in a form with the products the specific retailer sells.
The retailer is assigned a value for each product that they are selling, and then the values are summed up and putten into the database in the colum Group.
The group memberships can be determined by coverting the number in the Group column to binary and then check the specific position for a specific group in the string returned.
Example: 5 is 101 in binary, this value is assigned to the Group column in the database. By checking if the first position is a 1 I'll determine if the retailer is selling Product 1. Noting that the second character is a 0 I thereby know they ar'nt selling Product 2.
And since the last position is a 1 I also know they sell Product 3.
So for the retailer to register they've sold a Product 1, I want to populate a dropdownbox with only the prducts that retailer is selling.
I do understand I have to get the groupvalue (the binary value is set when loggin in using the $_SESSION['group']) loop it through to check wich products the retailer sells and in the same time populate the dropdownbox. I'm guessing a while loop inside the -tag, but how? The names (Product 1 and so on) are in a separate table with their values. Example:| 1 | "Product 1" | (the | are representing columns start/end).
Any idea on how to do this? Or is it someway better to do this? A string in the table with the names wont work since the fields are limited to a number of chars and with many products that will be a problem.
Nevermind, remade the groupsystem into using separate tables instead.
Now working like a charm with a table frou groups, a table for users and a table to link them together.
Related
the functionality is to take all price from cscart_prices table instead cscart_product_prices and also price with specific user as per user_id column (Current user).
example: Product_price = current_logged-in_user_id + product_price (from cscart_prices)
Note : Dont want to make user group for every user because so many user group will require to make.
All user have different price for different products.
IF 100 Product and 150 user then 100*150=1500 entries available in cscart_prices table.
I have tried different hooks available but not getting exact value and not able to identify that which hook will work in this addon to change price before they appear on store front.
There are many different answers to satisfy different online store needs.
A lot of the example I see don’t take into consideration **inventory and images ** and treat styles and sizes as attribute like tags and try to be flexible. This seems wrong to me. My Product that hasMany styles/color that hasMany Sizes.
Here is how i want to layout it out
Product
id | name | price
1 | shirt | 10.00
^ Styles < Images
id product_id name id styles_id filename
1 1 red 1 1 image.jpg
2 1 blue
^ Size
id sku styles_id name inventory
1 n1 1 m 50
2 n2 1 l 50
I don’t see many examples of this but this is what makes sense most to me. Am i totally wrong and bad to do it this way? With styles having its own table I can use a FK with images to load different looks of each style
I know one flaw is that what if I have a product that has only one style and one size. Like a winter coat. Then I to use extra tables. Visually with PHP I will just make it all one form. Will I run into an issue when i start working on cart and orders?
Note: I am using CakePHP
Response to the parent child method
Yes I have seen that before, Wouldn't you have repeated fields or empty fields, for example your table would look like this
id role color size inventory price name
1 parent - - - - artShirt
2 child red m 20 50.00 -
3 child red l 20 50.00 -
4 child blue s 20 50.00 -
5 child blue m 20 50.00 -
how would you link img to products that are red?
id product_id image
1 2 redImg.jpg
1 3 redImg.jpg
the concept i really like is called Parent Product - Child Products.
The Parent Product is given a sku for reference, but its not a buyable product. It represents the product, like the ArtSir Shirt. It contains a product description for ArtSir Shirt, qualities, keywords, etc.
the Child Products are the actual buyable products. the shirts. there is one record per child product with the sku, color, size, price, weight, inventory, etc. they are related to the Parent product by the parent product sku. for most merchants inventory is critical so having a db record per sku is really the only practical way to do this. (not to mention if you need distinct UPC or EAN codes)
the parent products and the child products can all be in - one simple happy db table. like a family :-) You call the parent product with its sku, then get the child products with the parent product sku.
and then when you get the child products, you have the option to filter out the ones with no inventory and not show them.
Showing product pictures on a product page for specific colors -- so this has nothing to do with the products being buyable or not. this is the presentation. the simplest (hack) is to put that information in the Parent product record. fields for Color 1, photo link, Color 2, photo link, etc
Otherwise you could have a separate db table to do this. Just try and confine its tasks to the presentation.
Always pass a product id to the cart - then the cart looks up the product price in the product table. If you pass the product price openly, then it can be easily hacked. When you look up the price you can also confirm inventory.
Suggest that there be one step before billing - where you check price and inventory again to confirm everything is correct before charging the customer.
==============
edit in response to question. you asked:
"Wouldn't you have repeated fields or empty fields, for example your table would look like this"
yes you will have empty fields. in 1985 or 1995 that was important. its not important any longer unless you are running your web site on a machine from that era.
bottom line you have to be able look up a sku and get the price and inventory. you could put arrays or data structures into a field.
but then you are having to pack and unpack them every single time you make a db call.
how would you link img to products that are red?
you can hack it by creating fields for the parent product to hold the image links, a color reference, a name, etc. color01, photolink01,color02, photolink02, etc. its a hack but it will work.
remember you are pulling all the page display information from the parent product. so this is just more display data.
you also have the option of having a photo field in the child product record. which you might need for product feeds. so then you could take the color - photo results from the child products, and use that to create the display.
otherwise make a db table for the display. and that table could also help with uploading the product photos and assigning them to the correct product.
I have a project where there is a dealer locator which is supposed to locate the dealers in the area.
The dealers supply multiple brands of different items(example: cement bricks etc.).
These items have subcategories and may also have a variable length sub categories.
Under the sub categories are the brands. Brands are lowest level of that product , meaning there is no end product, all these put together is the product
These dealers have a location which is used to map them on google maps.
The locator must have filters where one can select the category and then a sub category and if exists a sub sub category . Also one can select the brand and quantity of the product.
I have tried different ways to create the database , but have failed.
I am having difficulty in accessing products which have to be displayed after selecting each filter option.
My questions:
Should I create a table for every product , if so what will be the
attribute?
How to handle the variable length sub categories ?
How can I access each product based on category or sub category or brand.
Sample schema:
table:categories(Parent_ID | Category_ID | Category_Name);
table:product (Dealer_ID| Brand_ID|Quantity); - table for each product
table:brands(brand_ID|Category_ID|Brand_Name);
table:Dealer(dealer_ID|lat|long|name ...etc.);
When the page loads all dealers are shown in the map based on location.
On selecting each option the page reloads and displays the dealers based on the selection.
With my current schema I am unable to access them based on selection.
I would create a single products table, and create an entry for each unique product (not one for each categorical permutation). So Cement Brick, Shovel, Hammer, etc.
For the categories, I would create a category map table that would have the following fields:
product_id(int), parent_category_id(int), child_category_id(int)
Both of those fields would map to a category table that would look something like: id(int), name(text), status_id(int), created_at(timestamp), updated_at(timestamp), deleted_at(timestamp)
This implementation would allow you to have as many sub-categories as you wish, and would allow for easy lookups since you'd just need to see if the child_category_id matched one in the requested filter.
As for the brand question, it really depends on how detailed you need to be concerning brand. If you don't need anything other than .. say a name, you could use First Normal Form and put the brand on the product entry itself (as a column on your products table). If you need some more details, and / or need to associate a single brand with multiple products.. you could use a basic xref.
I am designing a website for wedding cards with Magento.
Each wedding card which a user buys may come with few additional sub products like a Reply Card, an Additional Insert, etc.
For Example:
There is a wedding card named “A”. Now there is a minimum quantity check that we have put over this product. This product comes with 2 complementary inserts per product.
In addition to these 2 complementary inserts a user can buy additional inserts. The user should select the number of additional inserts from a drop down menu. According to whatever number is selected, additional inserts should be generated.
Now suppose he selected 2, so there would be 2 additional inserts. Each additional insert would have a minimum quantity linked to it. And there would be a fixed cost per additional insert.
I am stuck at this position. How can this be achieved in Magento?
This feature can be handled by the "configurable item type".
Make configurable item, select EAV attribute which connect that type selection.
This is way how you present an empty default product visible (with name image price) and after this you can make variables by another simple product with other prices store ammounts etc...
The same way is bundled item (there is no price, and is counted by sum of prices or selected sub-items by customer), magento shows "price starts by ...."
I'm working on an order system for my online shop. I have 2 tables:
products, storing info about products
orders, storing general id's & infos of customer orders.
Now I want to have a way to store complex customer orders in the database. I need something that will let me know how much of each size (S, M or L) of each product is in an order.
The tricky part is that I want to be able to add/edit/delete products (of course without affecting orders from the past), so the method should be flexible
How should I go about this?
a separate table for every order, with products as rows?
one table for all orders, with products as columns?
some other option?
Thanks!
Depends on your goals for your cart. For instance, do you want to allow guest purchases? i.e. where a user does not need to login in order to make a purchase?
The attached image is a design I have been working on and it goes like this:
A visitor selects products from the site and adds these to a session cart (just a place to temporarily store the products, their quantities and their prices etc.)
Once the customer is ready to check out, we create the order, the order person and the person_address (where the product must be delivered to) and add the items to the order_item table. All this information is added by the customer in the checkout page.
The final step is then to offer the payment methods: paypal, credit card, etc.
What I like about this design is that users have no obligation to register with us. Order_person acts as a kind of interface between users and orders. If do register, we simply link order_person to the user table...
I have included a sample front end of the checkout page too.
At the very least you need:
Products (one row per product)
ProductID
Size
Orders (one row per order)
OrderID
OrderDetails (one row per product per order)
ProductID
OrderID
Size
Note that each 'size' is its own ProductID. You'll probably want to have yet another ID that groups products that are the same 'base' product, but in different sizes.
So if Order #1 has three products, and Order #2 has four, then OrderDetails will have seven rows:
OrderID ProductID Quantity
1 234 2
1 345 9
1 456 30
2 432 1
2 234 65
2 654 8
2 987 4