Mage::app()->getLocale()->date(strtotime($Model->getCreatedAt()), null, null, false)->toString('dd/MM/yyyy')
About Magento, Linux, Jquery, PHP ... and other!
Mage::app()->getLocale()->date(strtotime($Model->getCreatedAt()), null, null, false)->toString('dd/MM/yyyy')
<?php require_once 'app/Mage.php'; umask( 0 ); Mage :: app( "default" ); Mage::log("Started Rebuilding Search Index At: " . date("d/m/y h:i:s")); $sql = "truncate catalogsearch_fulltext;"; $mysqli = Mage::getSingleton('core/resource')->getConnection('core_write'); $mysqli->query($sql); $process = Mage::getModel('index/process')->load(7); $process->reindexAll(); Mage::log("Finished Rebuilding Search Index At: " . date("d/m/y h:i:s"));
$date = date("Y-m-d");// current date
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");
chmod go-w /var/empty/sshd;chmod go-w /var/empty
getStore()->getId();
if (Mage::app()->useCache('config') && $collection = Mage::app()->loadCache($cacheKey)) {
$prod = unserialize($collection);
} else {
$prod = Mage::getModel()->getCollection;
....
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache(serialize($prod), $cacheKey, array('config'));
}
}
$stores = Mage::getModel('core/store')->getCollection();
foreach( $stores as $store ){
$url = Mage::getModel('core/url') ->setStore($store)->getUrl('');
echo $url."\n";
}
SELECT entity_id, count( * )
FROM catalog_category_flat_store_x
GROUP BY entity_id
ORDER BY count( * ) DESC
LIMIT 0 , 30
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>
$filter = Mage::getModel('core/email_template_filter');
$vars = array( 'value'=>'toto');
$filter->setVariables( $vars );
$filterdResult = $filter->filter( ' Text Text Text Text Text {{var value}} Text Text Text Text ' );
Redirect 301 /oldpage.html http://www.yoursite.com/redirectpage.html
Redirect 301 /redirectpage2.html http://www.yoursite.com/folder/
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod o+w var var/.htaccess includes includes/config.php app/etc
chmod 550 pear
chmod -R o+w med
<?php getQuote();
$total = $quote->getGrandTotal();
// format total in order to have a user friendly price
$total = $this->helper('checkout')->formatPrice($total); ?>
protected function _sendFile($pdfPath) {
if (! is_file ( $pdfPath ) || ! is_readable ( $pdfPath )) {
throw new Exception ( );
}
$this->getResponse ()
->setHttpResponseCode ( 200 )
->setHeader ( 'Pragma', 'public', true )
->setHeader ( 'Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true )
/* View in browser */
//->setHeader ( 'Content-type', 'application/pdf', true )
/* Download */
->setHeader ( 'Content-type', 'application/force-download' )
->setHeader ( 'Content-Length', filesize($pdfPath) )
->setHeader ('Content-Disposition', 'inline' . '; filename=' . basename($pdfPath) );
$this->getResponse ()->clearBody ();
$this->getResponse ()->sendHeaders ();
readfile ( $pdfPath );
//exit(0);
}
$text = <<<TXT
text here
TXT;
$model = Mage::getModel('checkout/agreement');
$model->setName ();
$model->setContent ( $text );
//$model->setContentHeight ();
$model->setCheckboxText ();
$model->setIsActive (1);
$model->setIsHtml (1);
$model->save();
Mage::helpet('core/url')->getCurrentUrl()
Mage::helpet('core/url')->getHomeUrl()
jQuery(".link-view").toggle(
function () {
// Show treatment
},
function () {
// hidden treatment
}
);
30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log
* * * * * command to be executed
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
export EDITOR=vi ;to specify a editor to open crontab file.
crontab -e Edit your crontab file, or create one if it doesn't already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.)
strlen()
. However, there is a faster method. Take a look at the following code example:$string = 'testing';
if(isset($string[6]))
echo "The string '$string' is at least 7 characters long.";
else
echo "The string '$string' is less than 7 characters long.";
$string
value like an array by passing an integer value to isset()
. If that number plus one is greater than or equal to the number of characters in the string, it will return true. You need to add one because it is zero based.Echo
like a Functionecho
, you needed to use periods. But you can actually treat echo
like a function and use commas instead (it is also faster). Take a look at the following code:$string1 = 'test-string1';
$string2 = 'test-string2';
$string3 = 'test-string3';
echo 'String #1: ', $string1, '
';
echo 'String #2: ', $string2, '
';
echo 'String #3: ', $string3, '
';
$var1 = 'nameOfVariable';
$nameOfVariable = 'This is the value I want!!!';
echo $$var1;
ob_start();
echo 'Print to the screen!!!';
$getContent = ob_get_contents();
ob_end_clean();
// Do whatever you want...
// Do something with the printed content (only if you want)...
echo 'Now: ' . $getContent;
$reponse = new Varien_Object( );...$reponse->setTimeserver( Mage::getModel('core/locale')->storeTimeStamp( Mage::app()->getStore() ) );... ... ...$this->getResponse()->setBody ( $reponse->toJson() );