Last active
September 25, 2016 05:51
-
-
Save reinaldomendes/f743ba8e90a1a8a1307a to your computer and use it in GitHub Desktop.
Magento: Tricks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Define variaveis | |
username: admin | |
password: YOUR_PASSWORD_HERE | |
*/ | |
set @username='admin'; | |
set @password='YOUR_PASSWORD_HERE'; | |
set @salt='S4Lt'; | |
update `admin_user` set password = concat(md5(concat(@salt,@password )),':',@salt) | |
where username=@username; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Define vars | |
username: admin | |
password: YOUR_PASSWORD_HERE | |
*/ | |
set @username='admin'; | |
set @password='YOUR_PASSWORD_HERE'; | |
set @salt='S4Lt'; | |
/*init transaction*/ | |
start transaction; | |
/* insert new user */ | |
INSERT IGNORE INTO `admin_user` set firstname='admin',lastname='admin',email='admin@jn2.com.br',username=@username, | |
password= concat(md5(concat(@salt,@password )),':',@salt), | |
is_active=1,extra='N;',reload_acl_flag=0; | |
/*Var @lastId receive last user id*/ | |
select @lastId := last_insert_id(); | |
/*Create new role to user*/ | |
insert into `admin_role` set parent_id=1,tree_level=2, role_type='U',user_id=@lastId,role_name="admin"; | |
/*Complete transaction*/ | |
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$_paymentMethods = Mage::getSingleton('payment/config')->getActiveMethods(); | |
$_aryPaymentMethod = array(); | |
foreach ($_paymentMethods as $m) { | |
$_aryPaymentMethod[$m->getCode()] = $m; | |
} | |
/** $this = Mage_Checkout_Block_Onepage_Payment_Methods * */ | |
$methods = Mage::getSingleton('payment/config')->getActiveMethods(); | |
$quote = Mage::getSingleton('checkout/session')->getQuote(); | |
$payment = $quote->getPayment(); | |
$originalPayment = $payment->getMethod(); | |
if ($quote->isVirtual()) { | |
$address = $quote->getBillingAddress(); | |
} else { | |
$address = $quote->getShippingAddress(); | |
} | |
$salesRules = Mage::getResourceModel('salesrule/rule_collection')->setValidationFilter( | |
Mage::app()->getStore()->getWebsiteId(), $quote->getCustomerGroupId() | |
)->load(); | |
$quoteItem = Mage::getModel('sales/quote_item') | |
->setProduct($_product) | |
->setQuote($quote); | |
$quoteItem->setAllItems(array($_product)); | |
$quoteItem->getProduct()->setProductId($_product->getId()); | |
?> | |
<?php | |
foreach ($salesRules as $rule) : | |
$payments = array(); | |
foreach ($methods as $_method) { | |
$_code = $_method->getCode(); | |
$applicableRule = false; | |
$payment->setMethod($_code); | |
$address->unsPaymentMethod(); | |
if ($rule->validate($payment)) { | |
$payments[] = $_aryPaymentMethod[$_code]->getTitle(); | |
$applicableRule = $rule; | |
} | |
} | |
?> | |
<?php if ($applicableRule): ?> | |
<?php | |
$validator = Mage::getModel('salesRule/validator')->init(Mage::app()->getStore()->getWebsiteId(), $quote->getCustomerGroupId(), null); | |
$validator->process($quoteItem); | |
$_price = $_product->getFinalPrice() - $quoteItem->getDiscountAmount(); | |
$_price = $_price - ($_price * $quoteItem->getDiscountPercent() / 100); | |
?> | |
<div class="pagamento-avista price-box"> | |
<strong> | |
<?php echo $applicableRule->getName();?> | |
</strong> | |
<span class="price"> | |
<?php echo $_coreHelper->formatPrice($_price, true);?> | |
</span><br/> | |
(<small> | |
<?php echo join(", ", $payments);?> | |
</small>) | |
</div> | |
<?php endif; ?> | |
<?php endforeach; ?> | |
<?php | |
/** Reset * */ | |
$payment->setMethod($originalPayment); | |
$address->setPaymentMethod($originalPayment); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET FOREIGN_KEY_CHECKS=0; | |
TRUNCATE `sales_flat_creditmemo`; | |
TRUNCATE `sales_flat_creditmemo_comment`; | |
TRUNCATE `sales_flat_creditmemo_grid`; | |
TRUNCATE `sales_flat_creditmemo_item`; | |
TRUNCATE `sales_flat_invoice`; | |
TRUNCATE `sales_flat_invoice_comment`; | |
TRUNCATE `sales_flat_invoice_grid`; | |
TRUNCATE `sales_flat_invoice_item`; | |
TRUNCATE `sales_flat_order`; | |
TRUNCATE `sales_flat_order_address`; | |
TRUNCATE `sales_flat_order_grid`; | |
TRUNCATE `sales_flat_order_item`; | |
TRUNCATE `sales_flat_order_payment`; | |
TRUNCATE `sales_flat_order_status_history`; | |
TRUNCATE `sales_flat_quote`; | |
TRUNCATE `sales_flat_quote_address`; | |
TRUNCATE `sales_flat_quote_address_item`; | |
TRUNCATE `sales_flat_quote_item`; | |
TRUNCATE `sales_flat_quote_item_option`; | |
TRUNCATE `sales_flat_quote_payment`; | |
TRUNCATE `sales_flat_quote_shipping_rate`; | |
TRUNCATE `sales_flat_shipment`; | |
TRUNCATE `sales_flat_shipment_comment`; | |
TRUNCATE `sales_flat_shipment_grid`; | |
TRUNCATE `sales_flat_shipment_item`; | |
TRUNCATE `sales_flat_shipment_track`; | |
TRUNCATE `sales_invoiced_aggregated`; | |
TRUNCATE `sales_invoiced_aggregated_order`; | |
TRUNCATE `sales_order_aggregated_created`; | |
TRUNCATE `sendfriend_log`; | |
TRUNCATE `tag`; | |
TRUNCATE `tag_relation`; | |
TRUNCATE `tag_summary`; | |
TRUNCATE `wishlist`; | |
TRUNCATE `log_quote`; | |
TRUNCATE `report_event`; | |
ALTER TABLE `sales_flat_creditmemo` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1; | |
ALTER TABLE `sales_order_aggregated_created` AUTO_INCREMENT=1; | |
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1; | |
ALTER TABLE `tag` AUTO_INCREMENT=1; | |
ALTER TABLE `tag_relation` AUTO_INCREMENT=1; | |
ALTER TABLE `tag_summary` AUTO_INCREMENT=1; | |
ALTER TABLE `wishlist` AUTO_INCREMENT=1; | |
ALTER TABLE `log_quote` AUTO_INCREMENT=1; | |
ALTER TABLE `report_event` AUTO_INCREMENT=1; | |
SET FOREIGN_KEY_CHECKS=1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#modgit update source | |
if [ -z "$1" ] ; then | |
echo "Please inform one module name" | |
modgit list | head -n -1 | gawk -F ' ' '{print $1}'; | |
read -p "Enter a module name: " module | |
else | |
module=$1; | |
fi; | |
#copy all mapped files project to source | |
for i in $( modgit files $module | grep --invert-match "Deployed files of"); do | |
cp "$i" ".modgit/$module/source/$i" | |
done; | |
#commit changes | |
cd ".modgit/${module}/source/"; | |
git add --all | |
git commit | |
echo "" | |
echo "please execute update remote repositories" | |
echo "cd .modgit/$module/source/" | |
echo "git pull origin master" | |
echo "git push origin master" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
users=$(ls /mnt/files/ | grep -v base | grep -v 'lost+found' ); | |
env=production | |
for user in $users ; | |
do | |
sed -i "s/<\!\[CDATA\[admin\]\]>/<\![CDATA\[controle\]\]>/g" /mnt/files/$user/magento/$env/shared/app/etc/local.xml | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment