File Permission in Magento 2, OSX MAMP

I was struggling with file permission of Magento 2 in Mac’s MAMP. Finally got the solution. If I use _www I need sudo command for magento CLI which I did not want. otherwise every time I had to set 777 when delete all the temp files.
so I set permission for user and group. It works:

sudo chown -R _www:staff var/ pub/

Even Better solution that will work perfectly is here:
change the apache user and group same as Mac User and Group:
on /etc/apaache2/httpd.conf (or this file can be different location according to your apache installation)

sudo vi /etc/apache2/httpd.conf

find the User and Group, normally it is _www and _www. change it to:

User YOUR-MAC-USER
Group staff

from next time there should not be any permission problem.

How to find customers with attributes and user defined attributes in Magento?

In Magento, Customer model has an option addAttributeToFilter which helps to filter customers by attributes. For example, If We would like to get customers collections with group_id(Customer group) 3, we can use as following

$customers  = Mage::getModel('customer/customer')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('group_id', array('eq' => 123123))
    ->load();

for user defined attribute is also same. Here customer_number is user-defined attribute:

$customers  = Mage::getModel('customer/customer')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('customer_number', array('eq' => 123123))
    ->load();

Multiple attributes also can used with “AND” Condition

$customers  = Mage::getModel('customer/customer')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('customer_number', array('eq' => 123123))
    ->addAttributeToFilter('group_id', array('eq' => 3))
    ->load();

Following work for OR condtion for two attributes:

$customers  = Mage::getModel('customer/customer')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter(
   array(
     array('customer_number', array('eq' => 123123))
     array('group_id', array('eq' => 3))
    )
    ->load();

For individual afterwards:

foreach ($customers as $customer)
{
   var_dump($customer->getData());
}

If the attribute is unique value then We can directly get Row:

$customer  = Mage::getModel('customer/customer')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('customer_number', array('eq' => 123123))
    ->addAttributeToFilter('group_id', array('eq' => 3))
    ->load()
    ->getFirstItem();

Finally, If we need only selected attributes like firstname, lastname and email:

$customers  = Mage::getModel('customer/customer')
   ->getCollection()
   ->addAttributeToSelect('firstname')
   ->addAttributeToSelect('lastname')
   ->addAttributeToSelect('email');
   ->addAttributeToFilter('group_id', array('eq' => 3))
   ->load();

OroCRM: Fatal error: Uncaught exception ‘RuntimeException’ with message ‘The php executable could not be found, add it to your PATH environment variable and try again’

It is very common error in OROCRM “The PHP executable not found” :

Fatal error: Uncaught exception ‘RuntimeException’ with message ‘The php executable could not be found, add it to your PATH environment variable and try again’

It can be fixed by changing to Production environment from development. Following line at web/app.php

$kernel = new AppKernel('prod', false);

to

$kernel = new AppKernel('prod', true);