In PrestaShop, replacing the ObjectModel is a common way to extend core entities such as Customers, Products or Orders without changing the core files.

In this guide, we will cover a real world implementation:
Added a blacklist flag to customers by exclusion Customer Object Model.

What Will You Build

By the end of this tutorial, you will:

  • Add a new field is_black_listed at the customer’s table
  • Extend Customer Object Model
  • Set default values ​​for new customers
  • Store everything safely for upgrades in the module

Step 1: Create a Module Structure

Create the following folder structure:

modules/
└── customerblacklist/
    ├── customerblacklist.php
    ├── classes/
    │   └── CustomerBlackListInstall.php
    └── override/
        └── classes/
            └── Customer.php

Step 2: Add a New Column to the Customers Table

We first extend the database schema by adding new columns.

classes/CustomerBlackListInstall.php

class CustomerBlackListInstall
{
    public function addColumn()
    {
        return Db::getInstance()->execute(
            'ALTER TABLE `' . _DB_PREFIX_ . 'customer`
             ADD COLUMN `is_black_listed` TINYINT(1) NOT NULL DEFAULT 0'
        );
    }

    public function removeColumn()
    {
        return Db::getInstance()->execute(
            'ALTER TABLE `' . _DB_PREFIX_ . 'customer`
             DROP COLUMN `is_black_listed`'
        );
    }
}

Step 3: Replace Customer ObjectModel

Now we expand the core Customer model.

override/classes/Customer.php

class Customer extends CustomerCore
{
    public $is_black_listed;

    public function __construct($id = null)
    {
        self::$definition['fields']['is_black_listed'] = [
            'type' => self::TYPE_BOOL,
            'validate' => 'isBool',
            'default' => 1,
        ];

        parent::__construct($id);

        if (!$this->id) {
            $this->is_black_listed = 1;
        }
    }
}

What’s going on here?

  • We expand CustomerCore
  • Add a new field to $definition
  • Set default values ​​for new customers

Step 4: Create Main Module File

customer blacklist.php

class Customerblacklist extends Module
{
    public function __construct()
    {
        $this->name = 'customerblacklist';
        $this->version = '1.0.0';
        $this->author = 'Webkul';
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = 'Customer Blacklist';
        $this->description = 'Adds blacklist flag to customers';
    }

    public function install()
    {
        require_once __DIR__ . '/classes/CustomerBlackListInstall.php';
        $installer = new CustomerBlackListInstall();

        return parent::install() && $installer->addColumn();
    }

    public function uninstall()
    {
        require_once __DIR__ . '/classes/CustomerBlackListInstall.php';
        $installer = new CustomerBlackListInstall();

        return parent::uninstall() && $installer->removeColumn();
    }
}

Step 5: Install and Enable Override

  1. Go to Module Manager
  2. Upload and install the module
  3. Clear cache:
    • Advanced Parameters → Performance
  4. Ensure:

Verify the Implementation

After installing the module, you can verify that the new columns have been added and are working correctly.

  1. Register new customers from the storefront or back office.
  2. Navigate to:
    Advanced Parameters → Database → SQL Manager
  3. Click “Add new SQL query” and use the following query:
SELECT id_customer, firstname, lastname, email, is_black_listed FROM ps_customer;
  1. Run the query.

As a result, you will see the newly added column is_black_listed.
For newly created customers, the value will be set automatically based on the default value specified in the override.

SQL Table

Results

Now:

  • New field is_black_listed added to customers
  • Default value = 1
  • Can be accessed via $customer->is_black_listed
  • When a new customer is created, the is_black_listed field is filled with the desired data according to the replacement.

Conclusion

Replacing the ObjectModel in PrestaShop allows you to extend the core entity in a way that is clean and safe to upgrade.

In this example, we succeeded:

  • Extended Customer model
  • Add custom database fields
  • Controlled default behavior

The same approach can be used to:

  • Add custom product attributes
  • Extending order logic
  • Improve customer data

That’s all about this blog. Hope this helps you.

If you face any problem or have any doubts with the above process, feel free to contact us via the comments section.

Additionally, you can explore our Prestashop Development Services and a wide range of quality Prestashop Modules.

If in doubt, contact us at [email protected]

PakarPBN

A Private Blog Network (PBN) is a collection of websites that are controlled by a single individual or organization and used primarily to build backlinks to a “money site” in order to influence its ranking in search engines such as Google. The core idea behind a PBN is based on the importance of backlinks in Google’s ranking algorithm. Since Google views backlinks as signals of authority and trust, some website owners attempt to artificially create these signals through a controlled network of sites.

In a typical PBN setup, the owner acquires expired or aged domains that already have existing authority, backlinks, and history. These domains are rebuilt with new content and hosted separately, often using different IP addresses, hosting providers, themes, and ownership details to make them appear unrelated. Within the content published on these sites, links are strategically placed that point to the main website the owner wants to rank higher. By doing this, the owner attempts to pass link equity (also known as “link juice”) from the PBN sites to the target website.

The purpose of a PBN is to give the impression that the target website is naturally earning links from multiple independent sources. If done effectively, this can temporarily improve keyword rankings, increase organic visibility, and drive more traffic from search results.

Jasa Backlink

Download Anime Batch

Similar Posts