Post by haxcop » Mon Mar 27, 2023 8:46 pm

Hello, I have created an ocmod to enable and disable Manufacturers to appear on the manufacturer page with the following code but I still get the manufacturer showing in it.
I added a new column in the manufacturer table as `status` - `tinyint(1)`
This code emulates the category methods and set to 1 for enable and 0 to disable

What am i missing to stop showing the manufacturer in the manufacturer page if is currently in Disable [0] status?

I have tested trying setting a mysql trigger to update `manufacturer_to_store` `manufacturer_id`='123' `store_id` = '99' but this only witll throw a not found when selecting the manufacturer and the idea is just to never show it if it's status is = '0'

Thanks

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>enable disable manufacturer</name>
    <version>1</version>
    <author>haxcop</author>
    <lik>link</lik>
    <code>123</code>
    <description>enable and disable manufacturers</description>
    <!--model-->
    <!--1-->
    <file path="admin/model/catalog/manufacturer.php">
        <operation info="This add the query Manufacturer model class " error="log">
            <search><![CDATA[. "', sort_order = '"]]></search>
            <add position="replace"><![CDATA[. "', status = '" . (int)$data['status']. "', sort_order = '"]]>
    </add>
        </operation>
    </file>
    <!--Catalog-->
    <file path="admin/controller/catalog/manufacturer.php">
        <operation info=" This will create two new methods in the Manufacturer controller class - enable and disable. " error="log">
            <search><![CDATA[if (isset($this->request->post['manufacturer_seo_url'])) {]]></search>
            <add position="before"><![CDATA[		//!SECTION Manufacturer status
		if (isset($this->request->post['status'])) {
			$data['status'] = $this->request->post['status'];
		} elseif (!empty($manufacturer_info)) {
			$data['status'] = $manufacturer_info['status'];
		} else {
			$data['status'] = true;
		}
		//!SECTION end]]></add>
        </operation>
    </file>
    <!--Form-->
    <file path="admin/view/template/catalog/manufacturer_form.twig">
        <operation info="add the status select form at the manufacturer form" error="log">
            <search><![CDATA[<div class="tab-pane" id="tab-seo">]]></search>
            <add position="before"><![CDATA[<div class="form-group">
                <label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
                <div class="col-sm-10">
                  <select name="status" id="input-status" class="form-control">
                    {% if status %}
                    <option value="1" selected="selected">{{ text_enabled }}</option>
                    <option value="0">{{ text_disabled }}</option>
                    {% else %}
                    <option value="1">{{ text_enabled }}</option>
                    <option value="0" selected="selected">{{ text_disabled }}</option>
                    {% endif %}
                  </select>
                </div>
              </div>
              ]]></add>
        </operation>
    </file>
    <!--Language-->
    <file path="admin/language/en-gb/catalog/manufacturer.php">
        <operation>
            <search><![CDATA[ $_['column_action']     = 'Action'; ]]></search>
            <add position="after "><![CDATA[// STATUS
                    $_['column_status']     = 'Status';
$_['text_enable']     = 'Enable';
$_['text_disable']     = 'Disable';]]></add>
        </operation>
    </file>
</modification>
Last edited by haxcop on Tue Mar 28, 2023 8:34 pm, edited 1 time in total.

New member

Posts

Joined
Tue Jan 14, 2014 9:38 pm
Location - Dublin

Post by xxvirusxx » Mon Mar 27, 2023 11:46 pm

where is the code for Catalog side?

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by haxcop » Tue Mar 28, 2023 12:07 am

xxvirusxx wrote:
Mon Mar 27, 2023 11:46 pm
where is the code for Catalog side?
I'm not adding new files I'm currently adding the modification to the current opencart 3.0.3.8 files...
AFAIK unselecting the store from the manufacturer form will remove the row in the table `manufacturer_to_store` related to the selected manufacturer, so, when selecting Disable or Enable should perform the same action but that's the code I belive i'm missing here

New member

Posts

Joined
Tue Jan 14, 2014 9:38 pm
Location - Dublin

Post by by mona » Tue Mar 28, 2023 12:18 am

Don't you think you should change the model queries on the catalog side to cater for the status field ?

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by haxcop » Tue Mar 28, 2023 12:29 am

by mona wrote:
Tue Mar 28, 2023 12:18 am
Don't you think you should change the model queries on the catalog side to cater for the status field ?
Yes I do belive so, and I noticed the `manufacturer_to_store` later after I submit my question here, so I see the condition is set automatically copy the `manufacturer_id` and `store_id` to the table mentioned before, but i'm looking for help here to make it not redundant or interfere between the methods already in place, than when selected to Enable will enable it to the default store and set status 1 and for Disabled to remove the row from the `..._to_store` and set status 0. as well as when selected the checkbox manually to assign it to the store (as it's currently by default)

New member

Posts

Joined
Tue Jan 14, 2014 9:38 pm
Location - Dublin

Post by xxvirusxx » Tue Mar 28, 2023 12:36 am

Last edited by xxvirusxx on Tue Mar 28, 2023 4:58 am, edited 1 time in total.

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by haxcop » Tue Mar 28, 2023 1:44 am

No, I actually only modified the admin/.../manufacturer php and twig files not the catalog/../ area

It's neccesary also?

New member

Posts

Joined
Tue Jan 14, 2014 9:38 pm
Location - Dublin

Post by xxvirusxx » Tue Mar 28, 2023 4:59 am

haxcop wrote:
Tue Mar 28, 2023 1:44 am
It's neccesary also?
Of course. You don't want to display on catalog side only enabled manufacturers?

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by haxcop » Tue Mar 28, 2023 5:19 am

xxvirusxx wrote:
Tue Mar 28, 2023 4:59 am
haxcop wrote:
Tue Mar 28, 2023 1:44 am
It's neccesary also?
Of course. You don't want to display on catalog side only enabled manufacturers?
Exactly, well let me check it out thanks for the TIP ;D - Will come back later for the results or If I still have doubts. Thanks again

New member

Posts

Joined
Tue Jan 14, 2014 9:38 pm
Location - Dublin

Post by haxcop » Tue Mar 28, 2023 8:33 pm

haxcop wrote:
Tue Mar 28, 2023 5:19 am
xxvirusxx wrote:
Tue Mar 28, 2023 4:59 am
haxcop wrote:
Tue Mar 28, 2023 1:44 am
It's neccesary also?
Of course. You don't want to display on catalog side only enabled manufacturers?
Exactly, well let me check it out thanks for the TIP ;D - Will come back later for the results or If I still have doubts. Thanks again
I did the mod but this still showing the manufacturers in the page, only result in Brand not found after a click into it...

As the function seems redundant with the actual function of the store selection but with a different visual,. I have decided is better to use a MySQL Trigger to just delete the manufacturer_id row from the table manufacturer_to_store if no product is assigned to such manufacturer for a clean .

Thanks for your time and support

New member

Posts

Joined
Tue Jan 14, 2014 9:38 pm
Location - Dublin
Who is online

Users browsing this forum: No registered users and 95 guests