Php – read all files and folders from a directory
Read all files and folders from a directory using scandir: $dir = “/temp”; $files = scandir($dir); print_r($files); Read all files and folders from a directory…
Read all files and folders from a directory using scandir: $dir = “/temp”; $files = scandir($dir); print_r($files); Read all files and folders from a directory…
Create user with mysql command: CREATE USER ‘username’@’localhost’ IDENTIFIED BY ‘password’; Add all privilleges to databases for user: GRANT ALL ON *.* TO ‘username’@’localhost’;
Export database into a file with shell command: mysqldump -u USERNAME -p PASSWORD database > filename.ext; Import database from a file with shell command: mysql…
Display a magento block in CMS Page: {{block id=’block_id’}} {{block type=’module/package_classname’ template=’path/to/template.phtml’}} Escapes all HTML tags in the value of the var attribute, except for…
Get attribute collection: $attribute = $_product->getResource()->getAttribute(‘attribute_name’); Get attribute type: $attribute->getAttributeType(); Get attribute Label: $attribute->getFrontendLabel(); Get attribute default value: $attribute->getDefaultValue(); Check if the attribute is visible:…
This code can be used to get all images for product: $_product = Mage::getModel(‘catalog/product’); $_product->load($product_id); // Get image gallery $_gallery = $_product->getMediaGalleryImages(); // Go through…
Go to “CMS – Manage Pages” and select the page do you want to display the products from the list of pages. Use next code…
Print an array elements in smarty template: {$my_array|print_r}
To run a script in command line: php test.php or php -f test.php To run a script in command line with parameters: php test.php param1…
To view php script execution time insert next code into your script. Insert next code at the top of the page: <?php $mtime = microtime();…