value of custom product attribute is not storing in database table - magento

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!

Related

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()

Laravel - Please advise on table name

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.

oracle forms not showing all fields

I have 2 tables: product which has primary key product_id and Review which has product_id which references the product_id of product table;
I created form master-detail for them but when executing I get at the bottom of page:
FRM-40505: ORACLE error: unable to perform query
and when pressing ctrl+shift+e I get:
SELECT ROWID, REVIEW_ID, LIKE, DISLIKE, FIRST_NAME, LAST_NAME, PRODUCT_ID
FROM U1.REVIEW WHERE (PRODUCT_ID=:1)
ORA-00936: missing expression
how to solve this? what is wrong? thank you in advance
Seems you have a field named like in your block with base table named review has Database Item set to Yes in the property palette, and for this reason Oracle treats that field as if a column of the table, but there's no such column, and not possible to have a column named like within a db table, since it's a reserved keyword.

oracle ADF related query

there is one search page in ORACLE ADF with header & line section ... in header section i search for the customer id (i can also search with any column name like customer name , organization id etc) then in line section it will show me all the customer related to that customer id now in line section i make that customer id a hyperlink and as user click on that link (customer id) it will show a popup contain all the details related to that customer (around 700 column)..column names are like column 1,column 2,column3 ....column 700 like that and the name of this column 1 ,column 2 up-to column 700 is stored in some other table so how can i change that column1 ,column2 ...column 700 with their actual name (which is stored in some different table ).
One thing you might trey is to Query the other table using this:How can I get column names from a table in Oracle? to get the column names and then use the VO api to change the hint for the column: ADF how to convert column name to attribute anme
You use two VOs in the page.
VO1 fetches column names, the other VO2 fetches column values.
Create a Form based on VO2, then go to each column and update the label attribute for that column to point to the right value from VO1.

Some products disappeared from magento backend and frontend

Some of the products in Magento have suddenly disappeared from backend and frontend. When I try to re-create these products I get this error:
The value of attribute "SKU" must be unique
So the products must still exist somewhere in the DB.
I already tried the following without luck:
Truncate all catalog_product_flat tables
ReIndex all indexes
Refresh all Caches
Checked the "status" attribute of the product in Mysql (it was set to 1)
Any ideas how I can get these products back in the frontend/backend?
Try checking the following tables:
catalog_product_entity
catalog_product_entity_datetime
catalog_product_entity_decimal
catalog_product_entity_gallery
catalog_product_entity_group_price
catalog_product_entity_int
catalog_product_entity_media_gallery
catalog_product_entity_media_gallery_value
catalog_product_entity_text
catalog_product_entity_tier_price
catalog_product_entity_varchar
You can find the sku in the catalog_product_entity table.

Resources