eBay like database structure - php

I'm trying to get my head around eBay like structural database.
Given that each type of products has different columns I had to get products table then products descriptions table which is a meta table with key and value columns with product_id as foreign key for Products table
I've also got Specifications table which is hasAndBelongsToMany relationship with Subsubcategory table (which has belongsTo with Subcategory and then belongsTo Category relations)
So I've got joining table for Specifications Subsubcategory then also got Specification_Category which Specifications table belongsTo.
Now. I want my users to select a product with all those specifications of the product when they want to create a product selling page or have an option to create their custom product then enter those specific details into the Product Detail Meta Table based on pre-defined columns that are read from Specifications of that Subsubcategory.
To give you an example:
I'm now adding Specification using Scaffolding feature of Cakephp and I have a form with Name ie - 1TB, Specification Category - Hard Drive Capacity (belongsTo) and Subsubcategory - ie. Laptops, Desktops (hasAndBelongsTo)
Is this the correct way to structure something like this?

Related

Show Filters by Category

Does anyone have any previous experience or ideas on how to proceed in the product filtering section by category on the e-commerce site?
Because the filter field in the left menu will vary according to the product category. The memory filter should appear in the phone category, but the body (S,M,L) filter should appear in the t-shirt category. The project was built in Laravel. Options and option values models are available. Should the option_id be added to the category table and set accordingly or manually?
Thanks in advance.
You can use pivot table for this purpose. If each category has its own filters and you have a filter table (you name it option here), you must create a pivot table like category_option to store categoty_id and option_id. This will help you when building filter menu in category page. Next use another table to store product_id, option_id and value for that option to store values for each individual product.

relation schema for dealer locator mysql and php

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.

Mass import custom attributes Magento

I was wondering if anybody has ever tried to mass import custom attributes into a Magento Database before? My client has a Magento store that specialises in selling musical instruments, and wishes to add a Google Shopping Feed (using the extension of that name by Rocket Web) to sell the products on Google Shopping. The problem is that i need both an MPN (Manufacturer Product Number) and a Brand (so for instance Gibson) for the shopping feed to work, both of which are not automatically uploaded by the stores POS system.
The way that the POS system currently works is when a product is added, the title / SKU number / description / price etc are all uploaded to the Magento store, which means the client does not need to add the product twice. The problem is that as MPN and Brand aren't necessarily out of the box attributes, the POS system does not upload either of these to Magento, and therefore I now have 1,000 products without them and they are apparently crucial to the Google Shopping Feed extension.
I'm currently working on getting a table of each of the products SKU, MPN and Brands from the local database of the POS system (of which each of the products has all 3), but once i have it my question is this: is there a simple way for me to reference the products currently in the Magento database (most likely by SKU, as both databases contain the same SKU for each of the items) and apply two custom fields to each of the products: MPN and Brand? I've created custom 'MPN' and 'cat-brand' attributes (which i can use the Google Shopping Feed to map to the custom attributes) and looked inside the Magento database but i cant find them anywhere, but i found a table called 'catalog_product_flat_1', which i imagine is a flat DB used for indexing or something, but it looks perfect for achieving what i want, in that i could easily search for SKU and apply two custom attributes as columns for each product. Something tells me it isn't going to be that easy though.
Any thoughts would be a great help, thanks for your time.
Magento uses an EAV data model, which means your attributes are broken up into multiple tables. Take a look at any tables with 'entity', 'eav', 'attribute', or 'value' in their name if you want an idea of how it all works.
What you're probably looking for is catalog_product_entity_varchar or catalog_product_entity_text. In those tables, entity_id is your product ID number (different from SKU, but you can link a product_id to a SKU) and attribute_id corresponds to the eav_attribute table.
In short, what you want to do is look at your eav_attribute table, pull the entity_type_id, attribute_id fields for your MPN and cat-brand attributes you made, and then you can insert your data into catalog_product_entity_varchar. (or _text if your attributes use that instead)

How to include manufacturer description without using a product attribute in Magento Community Edition? PHP / XML / MySQL

In a normalized database schema, the manufacturers would have their own attributes like, for example, name, description, address, phone number.
The manufacturer description is something that is useful for the product pages. Many ecommerce sites show a manufacturer description on every product page.
As far as I know, in Magento you would have to create a product attribute, "Manufacturer description" or something like that. If, for example, ABC Corporation has 1,000 products, you would have to update all 1,000 every time you changed your description for ABC Corporation.
Is that the only reasonably easy way to do it?
Or is there a more database normal way of doing it, where a single, atomic update would result in all the manufacturer's items showing an updated value on the front end?
Create a module with the following contents:
setup script that creates a manufacturer table like desired
model and resource model classes for manufacturer
grid to manage the manufacturers (this is quite complicated, you should follow a tutorial like this or copy the basics from another module)
manufacturer block and template to render HTML for manufacturer info. You will use it as frontend model for the manufacturer_id attribute (see below)
setup script that adds a product attribute manufacturer_id
source model for the manufacturer id, so you can select the manufacturer from a dropdown instead of typing in the id
To display manufacturer description on product page without using product attribute you need to create new table "manufacturer_info" and this table contains information of manufacturer id as well as description.
Table is something like this
manufacturer_id | description
To add description, you need to create new module which will display all the shop brand s and description in grid. When you edit manufacture one form will appear and in that form add description and save it to database.
After saving description, You can display it on product page based on manufacture_id.
To get current manufacture use following code
$_product = $this->getProduct();
$manufacturerName = $_product->getAttributeText('manufacturer');
$manufacturerId = $_product->getManufacturer();
Use manufacturer_id for getting description from newly created table
I hope this helps.

Database structure for product variants

I am upgrading a website to enable product variants - currently the website only provides standalone products but there is now a requirement to provide variants of a particular product, e.g. size or colour. The aim is to enable the site admin to easily insert/edit product variants.
The current structure is as follows:
table product
=============
id
name
description
category_id
price
stock_level
The fields 'price' and 'stock_level' will now need to be relevant to each product variant.
A product can have multiple combinations of variants, e.g:
Product ID 5 - Size: Small, Colour: Black
Product ID 5 - Size: Small, Colour: Brown
On the front end there are two dropdowns to select the variants (Size and Colour). Upon selecting the required variants, the values are posted to a PHP script which runs an SQL query to check if that particular variant combination is available.
I am struggling to come up with a solution for this. I have currently created the following functionality, which I think is the starting point:
Ability to create/edit variant TYPES e.g. Size or Colour:
table variant_type
==================
id
name
Ability to assign values to variant types, e.g. Small, Large, Black, Brown:
table variant_type_value
========================
id
name
variant_type_id
I am struggling to come up with the design for the table(s) that will store the product variant combinations (including their price and stock level).
Bear in mind, on the backend, there will be a form to "Add a new Variant" - on this form the admin will need to select 'Size', 'Colour', 'Price' and 'Stock Level' when adding/editing a variant.
I think the easiest way would be to have a Product table; that would have all the details of the variants in it, by including the foreign keys for the Product table, as well as the Size and Colour tables:
table variant
=============
variantID
productID
sizeID
colourID
stock
price
table product
=============
id
name
description
category_id
table size
==========
sizeID
sizeName
table colour
============
colourID
colourName
So you can get the details for the variants by joining all four tables together. Information that relates to the product in general goes in the product table, and you can add extra types of variant by creating new tables and linking them in the variant table.
Editted to add:
This way, you'll need to add extra tables if you want to add a new type of variant. You could also get around it by merging all the variant possibilities into one variant table:
+--+------+------+
|ID|Type |Option|
+--+------+------+
|1 |Colour|Brown |
|2 |Size |Small |
+--+------+------+
You'd then have multiple foreign keys from variantInfo in the main product table.
I don't tend to like that - I don't like have multiple types of information stored in the same table. I just think it's confusing, and you need to make the programming logic more complicated. If you want to have extra variant types, I'd recommend just setting them all up now - it's a little extra work, and some of them won't be used, but I think it's a lot easier to maintain.

Categories