Fixed: Cannot install sample data in Magento 2, even with authentication keys stored in auth.json

If you’ve tried installing the Magento 2 sample data using the CLI tool, you may get the following message:

# sudo bin/magento sampledata:deploy
./composer.json has been updated
Loading composer repositories with package information

The '' URL required authentication.
You must be using the interactive console to authenticate

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [packages1] ... [packagesN]

There is an error during sample data deployment.

The solution documented on the Magento 2 Developer hub is to switch to your Magento 2 base directory and run composer update, which will ask for your Magento Connect authentication keys and then store them for you in your ~/.composer/auth.json file.

What happens, however, when you’ve already done that and you still get the same error? Well then you have to start doing your research, which will bring you to this bug report.

Since I cloned from master and the bug has only been fixed in develop (as of this writing), the only solution if you want to install the sample data is to manually apply the patch referenced in the bug report yourself.

Once that was done, sample data installation proceeded with no problems.

Fixed: Postcode validation does not work in Admin Create Order screen

Edition: Magento Community

Recently I hit upon a problem where, in the Admin Create Order screen (Admin > Sales > Orders > Create New Order), I selected a postcode-optional country and left the postcode field blank, but Magento was still validating the field and spitting out an error message:

Billing Address: "Zip/Postal Code" is a required value.
Shipping Address: "Zip/Postal Code" is a required value.

So why was Magento trying to validate a field that it shouldn’t?

After much digging, it turned out that the postcode attribute of the customer_address entity was missing the data_model Mage_Customer_Model_Attribute_Data_Postcode, which is what checks the config and tells Magento to validate the postcode or not.

Fixing it then was rather simple – just add the class group name ‘customer/attribute_data_postcode’ to the data_model field in the customer_eav_attribute table of the database.

Fixed: Uncaught SoapFault exception: [HTTP] Error Fetching http headers using PHP SOAP

For me this error was caused by having logical errors in the PHP script that my SOAP service was calling.

$client = new SoapClient('', array('trace' => 1));
$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');

$session = $client->login('username', 'password');

try {
$result = $client->call(
echo "
echo "</pre>
} catch (SoapFault $e) {
echo $e->getMessage()


To debug a SOAP service, pass the XDEBUG cookie by setting it to the SOAP request:
$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');
Don’t use the browser bookmarklet if you’ve got one of those.

Magento: Create Free Shipping Rule

In Admin panel:

  1. Create a new Shopping Cart Price Rule.
  2. On the conditions tab, specify your conditions.
  3. On the Actions tab, set ‘Free Delivery’ to something other than ‘No’
  4. Save rule.
  5. Enable Free Shipping shipping method in System > Configuration.
  6. Set Minimum Order Amount to something ridiculously high.
  7. Save configuration.
  8. Test your rule.

Install Magento over SSH

Installing the sample data (this has to be done first, if you want it)

tar -zxvf magento-sample-data-
mv magento-sample-data-* magento/media/
mv magento-sample-data- magento/data.sql
chmod -R o+w media var
mysql -h DBHOST -u DBUSER -pDBPASS DBNAME < data.sql chmod o+w var var/.htaccess app/etc rm -rf magento/ magento-sample-data- magento- magento-sample-data- data.sql

Installing Magento

tar -zxvf magento-
mv magento/* magento/.htaccess .
chmod -R o+w media var
chmod o+w app/etc
rm -rf magento/ magento-

Five Minute Guide: Join data from two tables in one collection using filters

Let’s say you have related information in two separate tables in Magento, e.g. news articles and authors. You can get a collection of news items easily enough with:
But how can you get the author information in the same collection? Here’s where collection filters come in handy. They basically allow you to add joins to a collection.

In your Block class, instantiate the collection and call the filter, passing the author ID:

class News_Block_Article_List extends Mage_Core_Block_Template {

* Get all articles associated with author
* @param $authorId
public function getArticles( $authorId ) {
return Mage::getModel( 'news/articles' )->getCollection()->addAuthorFilter( $authorId );

Then define the addAuthorFilter() method in your Resource Model:

class News_Model_Resource_Article_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {

* Filter news articles by author
* @param $authorId
* @return $this
public function addAuthorFilter( $authorId ) {
$this ->addFilter( 'author_id', array( 'eq' => $authorId), 'public');

return $this;

* Hook for operations before rendering filters
protected function _renderFiltersBefore() {
if ( $this->getFilter( 'author_id' ) ) {
array( 'na' => $this->getTable( 'news/authors' ) ),
array( '*' )