Laravel - Please advise on table name - laravel

I am in trouble with the name of the pivot table.
products ... Product master table
shop ... Shop master table.
shop_sales ... A table that links products and dates. It leads to another table. The column is date and shop_id.
I want to add a table to shop_sales to manage products and the number sold.
shop_sale_products vs product_shop_sale
Does laravel recommend product_shop_sale?
thanks.

Related

Many-to-many from relational design to dimensional design

This is my database design:
I make a data warehouse a with 2 fact table design as you show :
I want to add Order dimension but the problem is that there is bridge table between product table and order table by the way order table contain 830 rows and Order details table contain 2155 rows.
How can I create order dimension?

Join database table based on Json colum having multiple key

I am trying to create an ecommerce application using laravel, So when someone orders something, I store data in orders table, in which a column "products" exists.
I store json object in this column.
this is products json:
[{"pid":65,"min_price":"349.0000"},{"pid":71,"min_price":"349.0000"}]
Now, I want to show these order details to the user profile. So, i need to fetch rows from an another table (products), with the primary key same as "pid" in given json object.
please, suggest me how to resolve it.
You can't do this without retrieving it first and looping over it or something.
What you might want to consider is the following:
Remove the column products from the orders table and create a order_product table. This is called a pivot table.
You can create this table by running the command php artisan create:migration CreateOrderProductTable
Now in this table you define 2 foreign keys. order_id and product_id.
If you have done this, you have to create the relations in the Product model and the Order model.
You can now use this relation to query all products that an order has like this: Order::find(1)->products()->get()

value of custom product attribute is not storing in database table

I am new in Magento and I am using 1.7.2. I added one product attribute called product type name. It is a drop down field and values are populated from a different custom table called product_type_name. I have done successfully so far. Now I want to store the value of product type name into DB Table while adding a product. For that I have added a column product_attrb_type_name(attribute code) in catalog_product_flat_1 table.
Now while trying to add the product, it is showing the following error
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''
Also while trying to edit a product, the values are not set in the product entry form.
How to fix this issue? Could you please help me?
Thanks in advance.
Magento uses EAV table structure, so once you add a attribute they are stored in eav_attribute table with specific entity type (4 for product).
Now when you load a product object, say
$product = Mage::getModel('catalog/product')->load({{entity_id}}) , where entity_id is your product id,
you can use get and set function on this object to set the values of the particular product instance, i.e.
$product->setProductTypeName('someValue'); in your case a a dropdown ,so
$product->setProductTypeName(attributeId);
$product->save();
and get by
$product->getProductTypeName();
You do not have to insert in catalog_product_flat tables, that is Magento way to normalize data into flat tables.
Hope it helps!

Tables involved in storing order information for a certain product in magento

What are the Tables involved in storing the information of an order.
For example: Customer - product purchased - etc.
I found the product purchases status etc.(invoice and sales tables) but having hard time in linking it to the customer. Could not find who bought what ? Any suggestions
Thanks
The table sales_flat_order has a field customer_id referring to a row in the customer_entity table. But remember that some orders are guest orders, and they are not associated to a customer account. In those cases customer_id is null.
The products (line items) for an order are stored in sales_flat_order_item. There's an order_id linking it to the order and a product_id linking it to the product.

How to delete / clear all product reviews in magento?

How to delete / clear all product reviews in magento?
Go to Catalog -> Reviews and Ratings -> Customer Reviews -> All Reviews
There are checkboxes and you can take the "Delete" action in the upper right.
truncate table `rating_option_vote`;
truncate table `rating_option_vote_aggregated`;
truncate table `review`;
truncate table `review_detail`;
truncate table `review_entity_summary`;
truncate table `review_store`;
You do not have to delete all of the tables, just the main one (review) and the aggregated (review_entity_summary), they use foreign keys and are set to cascade on delete of parent.
You can just run the following:
DELETE FROM review;
DELETE FROM review_entity_summary;
DELETE FROM rating_option_vote;
DELETE FROM rating_option_vote_aggregated;
That should help remove any old reviews.

Resources