Posts

Magento 2 code debug line by line

$result = ''; foreach( debug_backtrace() as $_stack) { $result .= ' ' . (isset($_stack['file']) ? $_stack['file'] : '') . ' ' . (isset($_stack['line']) ? $_stack['line'] : '') . ' ' . (isset($_stack['function']) ? $_stack['function'] : '') . ' '; } echo ' ' . 'file' . ' File Line Function ' . $result . ' ';die;

get category custom attribute value using sql

This query will get robot_index attribute value with list of categories.you can join multiple attribute as per your requirement. SELECT `c1`.* from catalog_category_entity_varchar AS c1 JOIN catalog_category_entity AS c2 ON c1.row_id = c2.entity_id JOIN eav_attribute AS e ON c1.attribute_id = e.attribute_id WHERE `attribute_code` = 'robot_index' AND `entity_type_id` = '3' AND c2.path LIKE '%1/1830/2355/%'

Magento 2 product varchar table eav attribute data update using sql query

UPDATE catalog_product_entity_varchar AS c1 JOIN catalog_product_entity AS c2 ON c1.row_id = c2.entity_id JOIN eav_attribute AS e ON c1.attribute_id = e.attribute_id SET c1.value = 'NOINDEX,NOFOLLOW' WHERE `attribute_code` = 'robot_index' AND `entity_type_id` = '4' AND c1.row_id = '86211' AND c1.store_id -- Row id u can use dynamic it's for only one record update. = '0'

Magento 2 update custom category attribute value

UPDATE catalog_category_entity_varchar AS c1 JOIN catalog_category_entity AS c2 ON c1.row_id = c2.entity_id JOIN eav_attribute AS e ON c1.attribute_id = e.attribute_id SET c1.value = 'NOINDEX,NOFOLLOW' --Here put your value WHERE `attribute_code` = 'robot_index' AND `entity_type_id` = '3' AND c2.path LIKE '%1/1830/2355/%' -- put atribute code and it's entity type id and category which you want to update in condition mention or you can modify it's condtion based on requirement.

Magento 2 Composer killed error quick fix executing those command

========= killed error solution ======== free -m mkdir -p /var/_swap_ cd /var/_swap_ #Here, 1M * 2000 ~= 2GB of swap memory dd if=/dev/zero of=swapfile bs=1M count=2000 mkswap swapfile swapon swapfile chmod 600 swapfile echo "/var/_swap_/swapfile none swap sw 0 0" >> /etc/fstab #cat /proc/meminfo free -m

Magento 2 invalid Form key

There is also in Magento 2 a form key validator Magento \Framework\Data\Form\FormKey\Validator public function validate(\Magento\Framework\App\RequestInterface $request) { $formKey = $request->getParam('form_key', null); if (!$formKey || $formKey !== $this->_formKey->getFormKey()) { return false;//for solving please return true here } return true; }