What is the correct attribute_set_id for customer entity and customer_address entity? - magento

I notice a discrepancy in Magento attribute_set_id for customer_address and customer entities. In customer_address_entity and customer_entity tables, the attribute_set_id is 0. However, in eav_attribute_set table, there is no such a thing where attribute_set_id is 0.
Supposedly, the attribute_set_id for customer entity is 1 and the attribute_set_id for customer_address entity 2. Is that correct?
attribute_set_id == 1 \\customer entity
attribute_set_id == 2 \\customer_address entity

The attribute_set_id column in the customer_entity and customer_address_entity are useless since the customers and the adresses only use one single attribute set.
When retrieving attributes for one of these entities the default_attribute_set_id from the eav_entity_type is used (and only that).

Related

How to add column in table based on left join using dax

Add column in Table items based on left join on item_category table. I want to add column itemcategory_category in the items table based on the left join
=ADDCOLUMNS (
items, LOOKUPVALUE (
'item_category'[ITEMCATEGORY_CATEGORY],
'items'[KEY_PRODUCTCATEGORY], item_category[KEY_PRODUCTCATEGORY]
)
)
Items Table
KEY_PRODUCTCATEGORY
1
item_category table
KEY_PRODUCTCATEGORY ITEMCATEGORY_CATEGORY
1 A
If you have one to one relationship
Table = ADDCOLUMNS(items,"new",RELATED(item_category[ITEMCATEGORY_CATEGORY]))
If you have no relationship
Table 2 = ADDCOLUMNS(items,"new",CALCULATE(MAXX(filter(item_category,item_category[KEY_PRODUCTCATEGORY]=MAX(items[KEY_PRODUCTCATEGORY])),item_category[ITEMCATEGORY_CATEGORY])))
If you are only keen on LOOKUPVALUE with or without relationship. LOOKUPVALUE is not dependent upon any relationship but it has performance issues.
Table 3 = ADDCOLUMNS(items,"new",LOOKUPVALUE(item_category[ITEMCATEGORY_CATEGORY],item_category[KEY_PRODUCTCATEGORY],items[KEY_PRODUCTCATEGORY]))
I tested out with following and it works fine.

Magento - how are categories joined to stores, and to each other

we are using Magento with multiple stores. Each store has categories starting with a root category. I understand that the store is a core_store entity, and category is a catalog_category_entity record, and that they are joined somehow in the EAV attributes table. But I have a few questions on this:
Category C is a subcategory of B is a subcategory of A, i.e. A > B > C - how are the relationships between A and B, and B and C stored?
How is the store joined in? Is there a join table, or is there a column allowing for the category to be listed in a table multiple times, each with a different value for the store field?
You can easily look at the tables and figure this out yourself.
In catalog_category_entity, the subcategories are linked to parent by the parent_id column. This column is also in the flat tables.
If you look in catalog_category_entity_varchar for the category name attribute for example, there's a store_id column. 0 is the default value, 1 is for store view 1, etc. All this means is that on the front end, if say Store View 1 is showing, then the value for the category name is the row in the table with store_id 1. For example, if your category name is "Hello" in Store View 1 English, then it might be "Hola" in Store View 2 Spanish, and so on.

checking values from two tables?

I had two tables
table1 contains a list of customer and their info and there is a customer id for each one
table2 contains a list of request from all with and customer id for each request as foreign key
and i want to check the customer who has request and who is not
plz how should that be done logical is it possible to eqaul between two queries ?
thanks
You have two tables, the first with one row per customer, the other with zero to many rows per customer. So you need two techniques: one to reduce the second table to one row per customer and the other to join that result set to the first table. These techniques are an aggregating sub-query and an outer join respectively.
select c.customer_id
, nvl(r.req_count, 0) as no_of_reqs
from customer c
left outer join ( select customer_id
, count(*) as req_count
from customer_req
group by customer_id ) r
on c.customer_id = r.customer_id

Reset orders,invoices and shipping to 000001

How can i reset orders,invoices and shipping to 000001 in magento Comunnity 1.7.0.2 ?
What is the simplest and safest method ?
There is a table in the database which stored increment id of order.
It is called “eav_entity_store” table.
You can check which entity type id belongs to which entity by looking at eav_entity_type table.
You can run following query to update last increment id for the order.
update eav_entity_store
inner join eav_entity_type on eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
set eav_entity_store.increment_last_id=000001
where eav_entity_type.entity_type_code='order';

Count the number of rows in many to many relationships in Hibernate

I have three of many tables in Oracle (10g) database as listed below. I'm using Hibernate Tools 3.2.1.GA with Spring version 3.0.2.
Product - parent table
Colour - parent table
ProductColour - join table - references colourId and prodId of Colour and Product tables respectively
Where the ProductColour is a join table between Product and Colour. As the table names imply, there is a many-to-many relationship between Product and ProductColour. I think, the relationship in the database can easily be imagined and is clear with only this much information. Therefore, I'm not going to explore this relationship at length.
One entity (row) in Product is associated with any number entities in Colour and one entity (row) in Colour can also be associated with any number of entities in Product.
Let's say as for an example, I need to count the number of rows available in the Product table (regarding Hibernate), it can be done something like the following.
Object rowCount = session.createCriteria(Product.class)
.setProjection(Projections.rowCount()).uniqueResult();
What if I need to count the number of rows available in the ProductColour table? Since, it is a many-to-many relationship, it is mapped in the Product and the Colour entity classes (POJOs) with there respective java.util.Set and no direct POJO class for the ProductColour table is available. So the preceding row-counting statement doesn't seem to work in this scenario.
Is there a precise way to count the number of rows of such a join entity in Hibernate?
I think you should be able to do a JPQL or HQL along the lines.
SELECT count(p.colors) FROM Product AS p WHERE p.name = :name ... other search criteria etc
or
SELECT count(c.products) FROM Color AS c WHERE c.name = :name .... other search criteria
From Comment below, this should work:
Long colours=(Long) session.createQuery("select count(*) as cnt from Colour colour where colour.colourId in(select colours.colourId from Product product inner join product.colours colours where product.prodId=:prodId)").setParameter("prodId", prodId).uniqueResult();

Resources