I have requirement to show all customer attributes on Catalog price Rule Form. You can see attached image for more clarity. enter image description here

enter image description here

How i can get customer attribute collection and how i can display in catalogrule section you can see in screen-shot. Thanks In Advance

1 Answer 1


We need to create customer model object instance and load the all attributes with that attribute.

Please check this following test code, this will help you .

namespace Custom\Test\Model\Config\Source;

use Magento\Customer\Model;

class Customers implements \Magento\Framework\Option\ArrayInterface

    protected $customerFactory;

    public function __construct(
        \Magento\Customer\Model\Customer $customerFactory
    ) {
        $this->customerFactory = $customerFactory;

    public function toOptionArray( $isMultiselect = false)
        $customer_attributes = $this->customerFactory->getAttributes();

        $attributesArrays = array();

           foreach($customer_attributes as $cal=>$val){
               $attributesArrays[] = array(
                   'label' => $cal,
                   'value' => $val

        return $attributesArrays;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.