$.ajax({ url: Yii.createUrl('/site/save-session-notification'), type: 'POST', data: { notification_read_status: checkbox_val, notification_type_id:'2' }, success: function (data) { console.log("response here"); }, error: function (error) { console.log(error); } }); public function actionSaveSessionNotification() { print_r($_POST); die("===="); }
Additional hidden field with radio button set default value in yii2
additional hidden field with radio button set default value in yii2
you will see yii automatically adds hidden field with each radio button and checkbox , you can set its default value by following code
1 | <?= $form ->field( $model , 'session_frequency_id' )->radio([ 'uncheck' => 1, 'label' => 'Daily' , 'value' => 1, 'class' => 'icheck toggle-able sessionhost-session_frequency_id' ] ) ?> |
in above code uncheck => 1 will set hidden field value .
How to print raw sql query in Magento 1
$collection->load(true);
$collection->printLogQuery(true,true); die;
magento 1 create admin user programmatically
<?php
$mageFilename
=
'app/Mage.php'
;
if
(!
file_exists
(
$mageFilename
)) {
echo
$mageFilename
.
" was not found"
;
exit
;
}
require_once
$mageFilename
;
Mage::app();
try
{
//create new user by providing details below
$user
= Mage::getModel(
'admin/user'
)
->setData(
array
(
'username'
=>
'admin1'
,
'firstname'
=>
'John'
,
'lastname'
=>
'Doe'
,
'email'
=>
'john@example.com'
,
'password'
=>
'welcome123'
,
'is_active'
=> 1
))->save();
}
catch
(Exception
$e
) {
echo
$e
->getMessage();
exit
;
}
try
{
//create new role
$role
= Mage::getModel(
"admin/roles"
)
->setName(
'Student'
)
->setRoleType(
'G'
)
->save();
//give "all" privileges to role
Mage::getModel(
"admin/rules"
)
->setRoleId(
$role
->getId())
->setResources(
array
(
"all"
))
->saveRel();
}
catch
(Mage_Core_Exception
$e
) {
echo
$e
->getMessage();
exit
;
}
catch
(Exception
$e
) {
echo
'Error while saving role.'
;
exit
;
}
try
{
//assign user to role
$user
->setRoleIds(
array
(
$role
->getId()))
->setRoleUserId(
$user
->getUserId())
->saveRelations();
}
catch
(Exception
$e
) {
echo
$e
->getMessage();
exit
;
}
echo
'Admin User sucessfully created!'
;
@unlink(
__FILE__
);
?>
How to disable compilation in Magento 1
php shell/compiler.php -- disable
php -f shell/compiler.php compile
shell/compiler.php -- disable
shell/compiler.php state
Executing cron tasks manually in Magento
For example, we have this cron task on a config.xml file of a specific module:
1 | <catgento_sap_sync_nonimages><schedule><cron_expr>*/15 * * * *</cron_expr></schedule><run><model>sap/cron_sync_nonimages::run</model></run></catgento_sap_sync_nonimages> |
we can create a new script that loads and executes that cron task like this (create a script.php file and put something like this inside):
1234567 | <?php //Load Magento API require_once 'app/Mage.php' ;Mage::app(); //First we load the model $model = Mage::getModel( 'sap/cron_sync_nonimage' ); //Then execute the task $model ->run(); |
The last step would be running this script manually (php script.php).
magento 1 clear cache command line
I have resolved the issue by myself with the following solution:
Login to your server and run the below command from your Magento root directory:
php -r 'require "app/Mage.php"; Mage::app()->getCacheInstance()->flush();'
Above command flush your Magento 1 cache. I suggest when changing Magento project folder then run the above command
How to completely remove Donations Ultimate extension
DELETE FROM `eav_attribute` WHERE `attribute_code` = 'donation_available'; DELETE FROM `eav_attribute` WHERE `attribute_code` = 'donation_default';
Go to last commit in GIT
Go to last commit in GIT
Below command will move your code to previous commit
git reset --hard HEAD@{1}
Get magento version with command line
Get magento version with command line
With the help of the below command, you can check the Magento 1 version in command line.
1php -r
"require 'app/Mage.php'; echo Mage::getVersion();"