Magento: Add admin user with MySQL statement in the database

4. April 2016 at 11:34

sql-statement-mysql

This script quickly adds a Magento Admin user directly into the database. It is possible to run this script from the command line or by copying and pasting into phpMyAdmin. Just make sure to edit the following fields with your personalized data and import. Most of these fields are trivial, I’m just listing them so you don’t miss anything.

Set the salt portion of your password. You’ll rarely need to change this. If you do, just use two lower case letters of your choice.
Set your password. At least 8 characters in length and at least one digit.
Firstname: Enter admin’s first name.
Lastname: Enter admin’s last name.
Enter email of admin user.
Enter username where ‘myuser’ is set. Notice ‘myuser’ shows up in two places.
Enter Firstname again. This is more symbolic to label the rule.

LOCK TABLES `admin_role` WRITE , `admin_user` WRITE;
SET @SALT = "rp";
SET @PASS = CONCAT(MD5(CONCAT( @SALT , "password") ), CONCAT(":", @SALT ));
SELECT @EXTRA := MAX(extra) FROM admin_user WHERE extra IS NOT NULL;
INSERT INTO `admin_user` (firstname,lastname,email,username,password,created,lognum,reload_acl_flag,is_active,extra,rp_token_created_at)
VALUES ('Firstname','Lastname','email@example.com','myuser',@PASS,NOW(),0,0,1,@EXTRA,NOW());
INSERT INTO `admin_role` (parent_id,tree_level,sort_order,role_type,user_id,role_name)
VALUES (1,2,0,'U',(SELECT user_id FROM admin_user WHERE username = 'myuser'),'Firstname');
UNLOCK TABLES;

Please share this article von facebook & google plus or where you want, thank you!

Magento: How to easily Debug Layout Xml Warning/Error?

16. März 2016 at 16:30

magento-xml-config-xml

If you get an error like „Warning: simplexml_load_string(): Entity: line 46: parser error : Comment not terminated in */lib/Varien/Simplexml/Config.php on line 510

in Magento you can do one of the following solution to solve this XML error.

This warning is related to some config.xml error, so a possible workaround to find out the exact file is to mod. the /lib/Varien/Simplexml/Config.php class.

You should modify Varien_Simplexml_Config::loadString() method:

public function loadString($string)
{
if (is_string($string)) {
// Enable internal errors
libxml_use_internal_errors(true);
$xml = simplexml_load_string($string, $this->_elementClass);
if (false === $xml) {
// Put breakpoint here
$errors = libxml_get_errors();
}
if ($xml instanceof Varien_Simplexml_Element) {
$this->_xml = $xml;
return true;
}
} else {
Mage::logException(new Exception('"$string" parameter for simplexml_load_string is not a string'));
}
return false;
}

In case the error is related to some Layout file ( Update.php line 444 warning )

You should modify Mage_Core_Model_Layout_Update::getFileLayoutUpdatesXml() method in a similar way:

public function getFileLayoutUpdatesXml($area, $package, $theme, $storeId = null)
{
if (null === $storeId) {
$storeId = Mage::app()->getStore()->getId();
}
/* @var $design Mage_Core_Model_Design_Package */
$design = Mage::getSingleton('core/design_package');
$layoutXml = null;
$elementClass = $this->getElementClass();
$updatesRoot = Mage::app()->getConfig()->getNode($area.'/layout/updates');
Mage::dispatchEvent('core_layout_update_updates_get_after', array('updates' => $updatesRoot));
$updateFiles = array();
foreach ($updatesRoot->children() as $updateNode) {
if ($updateNode->file) {
$module = $updateNode->getAttribute('module');
if ($module && Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $module, $storeId)) {
continue;
}
$updateFiles[] = (string)$updateNode->file;
}
}
// custom local layout updates file - load always last
$updateFiles[] = 'local.xml';
$layoutStr = '';
foreach ($updateFiles as $file) {
$filename = $design->getLayoutFilename($file, array(
'_area'    => $area,
'_package' => $package,
'_theme'   => $theme
));
if (!is_readable($filename)) {
continue;
}
$fileStr = file_get_contents($filename);
$fileStr = str_replace($this->_subst['from'], $this->_subst['to'], $fileStr);
libxml_use_internal_errors(true);
$fileXml = simplexml_load_string($fileStr, $elementClass);
if (false === $fileXml) {
// Put breakpoint here
$errors = libxml_get_errors();
$err = array($filename, $errors);
// error detail and file name will be printed
Zend_Debug::dump($err);
die();
}
if (!$fileXml instanceof SimpleXMLElement) {
continue;
}
$layoutStr .= $fileXml->innerXml();
}
$layoutXml = simplexml_load_string('<layouts>'.$layoutStr.'</layouts>', $elementClass);
return $layoutXml;
}

Now just reload the page a read the error info.

Please share this article von facebook & google plus or where you want, thank you!

Magento: delete an system attribute

13. September 2011 at 18:56

To delete a system attribute in Magento, you must first have to make it user defined.

– Go to phpmyadmin
– Go to your magento installation database
– Go to eav_attribute table
– Browse table with attribute_code ‘YOUR_ATTRIBUTE_CODE’ OR browse the table with the attribute_id of your    attribute (‘your attribute’ means the attribute which you want to remove as system attribute)
– Edit the table row of your attribute
– Find the field „is_user_defined“ and set the value to 1
– save the attribute

 

Now your attribute no longer remains System Attribute
Now you can delete it from Attribute manager