Jump to content

Extend Manufacturer with new fields - object and Twig theme


Recommended Posts

Hi all,

I am using Presta 1.7.7.7, I would like to extend manufacturer object with few new text fields which I want to use in product page template later.

Based on these docs: https://devdocs.prestashop.com/1.7/modules/concepts/templating/admin-views/

I created new file under this path: PRESTA_DIR/modules/extrafields/views/PrestaShop/Admin/Sell/Catalog/Manufacturer/Blocks/form.html.twig

Inside of the file I put this code:

{% extends 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer/Blocks:form.html.twig' %}

{% block manufacturer_form_rest %}
Hello world!
{% endblock %}


also, I created class override: PRESTA_DIR/override/classes/Manufacturer.php

Inside of this file I put this code:

<?php

class Manufacturer extends ManufacturerCore {

    public $photo_url;

    public function __construct($id_manufacturer = null, $id_lang = null) {
        self::$definition['fields']['photo_url'] = array('type' => self::TYPE_STRING);
        parent::__construct($id_manufacturer, $id_lang);
    }
}

Basically - nothing works. I cannot see "Hello world!" on manufacturer editing screen.

I understand that I should also take care of new column in database but first I would like to fix this issue.

Do you have any experience with creating new fields for manufacturer on Presta 1.7? What else should I try?

Link to comment
Share on other sites

44 minutes ago, Daresh said:

Check out the module for additional category description:

You can create additional fields for manufacturers the same way, without messing with twig templates or making overrides.

Hi Daresh, thanks for this.

I am just wondering if there are any replacement hooks (for example hookActionAdminCategoriesFormModifier) which I could use for Manufacturer. Presta 1.7 documentation is a joke 😕

Edited by limera1n (see edit history)
Link to comment
Share on other sites

23 hours ago, Daresh said:

Yes: hookActionAdminManufacturersFormModifier

I have managed to add new field to Manufacturer edit screen by modifying hooks names ('Categories' keywords changed to 'Manufacturers' etc.), but still few more issues:

  • [PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerException kod 0]: Cannot update manufacturer with id "2"

    this is what I get after trying to update Manufacturer, Symfony debug shows nothing

  • what is the best way to access these values from template level?

Edited by limera1n (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...