PHP – Delete files by pattern

Martin Zeller php 1 Comment

If you want to delete files by pattern (e.g. “*.txt”) in a directory, you can do this with the php function glob! [php]$files = glob(‘/path/to/files/*.txt’); // finds all txt files in the directory /path/to/files/ foreach($files as $file) unlink($file);[/php] With this method you can also delete all files of a directory – with pattern *.*

Client localisation with zend framework

Martin Zeller php Leave a Comment

If you want to find out the language or country of the clients browser, do it this way: [php]<?php require_once ‘Zend/Locale.php’; $locale = new Zend_Locale(); echo $locale->toString(); ?>[/php] But be aware! This way you only get the localisation of the clients browser. And this is configurable by the user. The code above will give you output like this: [text]de_AT[/text] or …

Magento: Warning in Mage/Eav/Model/Entity/Abstract.php ?

Martin Zeller Magento 1 Comment

All you want to do is saving a product like this? [php]$api = new Mage_Catalog_Model_Product_Api(); $productData = array(); $productData[‘visibility’] = Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE; $productData[‘status’] = Mage_Catalog_Model_Product_Status::STATUS_DISABLED; $api->update($product->getId(), $productData);[/php] Or maybe without the API? [php]$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE); $product->setStatus(Mage_Catalog_Model_Product_Status::STATUS_DISABLED); $product->save();[/php] And all you get is an error like this? [text]Warning: Invalid argument supplied for foreach() in /opt/lampp/htdocs/whlid/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 972 #0 /opt/lampp/htdocs/whlid/app/code/core/Mage/Eav/Model/Entity/Abstract.php(972): mageCoreErrorHandler(2, ‘Invalid argumen…’, ‘/opt/lampp/htdo…’, …