Importance note for magento 2

These are common notes for magento 2 during working with this ecommerce platform.

1. Static of admin load base on locale of user login

[pub/static/adminhtml/backend/locale_of_user_login]


2. Sql for query products

-- Product entity type ID
SET @etype = (SELECT
                    entity_type_id
                FROM
                    eav_entity_type
                WHERE
                    entity_type_code = 'catalog_product');
-- Product name attribute ID
SET @name  = (SELECT
            attribute_id
        FROM
            eav_attribute
        WHERE
            attribute_code = 'name'
                AND entity_type_id = @etype);
-- Product image attribute ID
SET @status  = (SELECT
            attribute_id
        FROM
            eav_attribute
        WHERE
            attribute_code = 'status'
                AND entity_type_id = @etype);
-- Product price attribute ID
SET @price  = (SELECT
            attribute_id
        FROM
            eav_attribute
        WHERE
            attribute_code = 'price'
                AND entity_type_id = @etype);
-- Admin store ID
SET @store = 0;

-- Query
SELECT
    e.entity_id AS 'id',
    e.sku,
    v1.value AS 'name',
    i1.value AS 'status',
    si.qty AS 'stock qty',
    d1.value AS 'price'
FROM
    catalog_product_entity e
        LEFT JOIN
    cataloginventory_stock_item si ON e.entity_id = si.product_id
        LEFT JOIN
    catalog_product_entity_varchar v1 ON e.entity_id = v1.entity_id
        AND v1.store_id = @store
        AND v1.attribute_id = @name
        LEFT JOIN
    catalog_product_entity_int i1 ON e.entity_id = i1.entity_id
        AND i1.store_id = @store
        AND i1.attribute_id = @status
        LEFT JOIN
    catalog_product_entity_decimal d1 ON e.entity_id = d1.entity_id
        AND d1.store_id = @store
        AND d1.attribute_id = @price
WHERE
    i1.value = 1;

3. The way save to table "quote_item" when add product to cart

- On detail page ( Simple product [ This simple product can be belong to a configuration product ] ) will save a record on "quote_item" with price

- On detail page ( Configuration product ) when add to cart a variation will save to "quote_item" 2 record: One is configuration product that this product belong with price of this variation, One is this simple product without price. So if we add 2 variation belong to only a configuration product then magento still save 4 records to this table

4.CSS preprocessing

http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/css-topics/css-preprocess.html

You might also need to clear the var/cache and var/view_preprocessed directories.

Example:

sudo rm -rf var/view_preprocessed/* pub/static/frontend/Pb/
php bin/magento setup:static-content:deploy --theme Pb/Cecilia en_AU






Comments