In Opencart 3 under PHP 8 how do I call module to show in another page - module

I have seen on this site the post re calling a module on needed page. I have tried to use this code to solve a problem. This code does not appear to work for me.
What I have is a module that places a label over each product depending on its status. It works well on products throughout site. However I have a module which calls all products on to one page. I want the label to appear on the products on this all products page.
Banner on product
The code I used in catalog/controller for the all product extension from previous post here was (382 is the label module number):
$this->load->model('382');
$my_variable = $this->model_setting_module->getModule('382');
$data['any_variable'] = $my_variable['any_variable'];
On Template page:
{{ any_variable }}
How can I get the module to be apply the label to the custom all products page?
As always help appreciated

Create new module with name: "my_module" and you can call it in your "another_module" controller file:
$data['my_module'] = $this->load->controller('extension/module/my_module');
and in corresponding "another_module" template file you can retrieve it:
{{ my_module }}

Related

Vue Storefront: Display labels for custom attribute filter instead of option id

I am trying to figure out from couple of days how to display label for filters on category page. As mentioned in document I have added attribute inside config.products.defaultFilters[] and the filter have started showing there.
I have color and brand filters. For color filters I have mapped color id to color name in config.products.colorMappings so it is displaying correctly there. But for brand I can do the same but it is a static solution so every time admin adds new brand I will need to add its mapping and build the storefront again.
I have tried to check their forum but nothing useful. I checked Vue Storefront vuex catalog and category-next stores for hint but cannot find anything related there.
The label for option under brand_filter should be readable but it is showing that brand attribute option's id
Ok, after spending couple of days finding solution to this problem, I finally got a hint from this answer.
I am using theme vsf-capybara, and according to its guide, to setup I generated a local.json from generate-local-config.js and I merged configuration manually from that local.json to config/local.json file. Prior to this there was no filter named brand or color added already to the main config file.
The config property responsible for the filter labels to be incorrect was entities.attribute.loadByAttributeMetadata and it was set to true I changed it to false because core/module/catalog/CatalogModule has one action attribute/list needs to be dispatched for application use. So if entities.attribute.loadByAttributeMetadata in config/local.json is set to true, this action will not be dispatched. Here is the excerpt from CatalogModule:
if (!config.entities.attribute.loadByAttributeMetadata) {
await store.dispatch('attribute/list', { // loading attributes for application use
filterValues: uniq([...config.products.defaultFilters, ...config.entities.productListWithChildren.includeFields])
})
}

Display message in checkout if a product from categoy X or Y is in the basket

I'm going to edit the shipping.tpl file of my Prestashop theme and what I need to do is to show a text if product from categoy X or Y is already in the basket.
Any ideas on how to get this conditional statement working in Prestashop?
Use CartController or classes Cart to check if your product from a category is already in the cart.
CartController will use for display cart page so you can use the message controller error or warning, as you want
$this->warning[] = 'message';
$this->error[] = 'message error';
Cart classes will be used to check if the user try to add a product from category

Creating module on prestashop

i need to create a module on prestashop on product page , im new in prestashop idk how to do that .
This module should be on bottom of page ,it contains product technical description
Can someone tell me how to do that
Ps : i know nothing about prestashop Hooks ....
Thanks in advance!
There is one hook that may fit you.
displayProductFooter
First you have to add the hook registration in your module install function
public function install()
{
...
$this->registerHook('displayProductFooter');
}
Then create a function to display the content in the hook
Save the content you want to display and use the return to send a string with all the HTML you want to print in the product footer.
In the params you will also find some useful variables like the product ID.
public function hookDisplayProductFooter($params)
{
// Your content here
return $output;
}
The same procedure should work with any other hook (as long as it's a display hook)

Clicking through a jquery dropdown menu using VBA / href=javascript:void(0)

I'm trying to make a macro that logs into a website, and starts pulling reports. Problem is, as I'm parsing through the html, I see a button exactly like the one on this page: https://www.exratione.com/2011/12/a-dark-style-for-chosen-selects/
where the href is a java void and the class is a generic "chzn-single" same as that website's button.
Any suggestions?
I'm trying this but no luck:
Set Clickme = IE.document.getElementsByClassName("chzn-single chzn-default")(0)
Clickme.Click
Also, which I don't think makes much sense:
IE.Document.getElementById("typeSelector").Value = "Revenue"
IE.Navigate "javascript:void(0)"
You haven't provided any HTML to go with this. If it is like that which you are showing in the other link then IE.document.getElementsByClassName("chzn-single chzn-default")(0) won't work because the class name is incorrect. It should be just chzn-single.
For the page you have linked, there are two clickable links with class of chzn-single.
I would use a CSS class selector to target them:
For the first:
IE.document.querySelector("a.chzn-single").Click
For the second:
IE.document.querySelectorAll("a.chzn-single").item(1).Click

Facebook Like Box social plugin doesn't work with Turbolinks

I'm using the Like Box social plugin (https://developers.facebook.com/docs/reference/plugins/like-box/) and it works great.
Problem is that I'm using it within a Rails 4 application with Turbolinks. Whenever I reload a page, the like box shows up. If I click on any link, the next page loads and the Like Box doesn't show up.
I tried this already but didn't worked =/
http://reed.github.io/turbolinks-compatibility/facebook.html
Any ideas on how to solve this problem?
The link you have posted in original question is quite nice. It asks us to create three functions:
1) saveFacebookRoot: This is needed so that the div#fb-root can be restored at a later point. This is called upon page:fetch. page:fetch is called while the DoM is still of the old page. i.e: new page has not replaced the old page
2) restoreFacebookRoot: This is needed to that the div#fb-root can be appended back to the page. It is called on page:change. page:change is called when the new DoM is available.
3) There is minor typo in there. We need to call this in page:load
FB.XFBML.parse() // Correct
Instead of :
FB?.XFBML.parse() // InCorrect
Remember that when the page is first reloaded, only the page:change is called out of these three.
The trick here is the use of global variables fb_root and fb_events_bound. These must be accessible in all other pages, but this is the reason why we hate turbolinks in the first place.
References: http://reed.github.io/turbolinks-compatibility/facebook.html
Install observejs:
gem 'observejs'
Then add tag to the widget:
<div as="FB" class="fb-comments" data-href="<%= request.original_url %>"></div>
Then create a new script in javascripts folder (fb.coffee in my example):
ObserveJS.bind 'FB', class
root: document.createElement('div')
#::root.id = 'fb-root'
loaded: =>
if !document.body.contains(#root)
document.body.appendChild(#root)
if FB?
FB.XFBML.parse()
else
#initialize()
initialize: =>
js = document.createElement('script')
script = document.getElementsByTagName('script')[0]
js = document.createElement('script')
js.id = 'facebook-jssdk'
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=YOUR_APP_ID&version=VERSION_OF_API"
script.parentNode.insertBefore(js, script)
Include the js files in your application.js
//= require observejs
//= require fb