- Posts: 28
- Thank you received: 0
Adding a filter plugin
Or is there filter plugins?
Please Log in or Create an account to join the conversation.
In fact, you can extend any class in the folders classes and helpers of the backend like that. You can find more information here:
www.hikashop.com/forum/2-general-talk-ab...custom-features.html
Please Log in or Create an account to join the conversation.
Something like this.
Please Log in or Create an account to join the conversation.
You can have such code in your plugin:
Please Log in or Create an account to join the conversation.
Basically I am trying to look for a URL variable (eg &something=true) and do a query to generate my own list of products instead of what the current page is doing.
I try to override GetProductList to intercept the output but it doesn't change anything.
I need to be able to generate a list of products and apply the same 'listing_img_desc.php' templates to the output to keep it all looking the same.
Please Log in or Create an account to join the conversation.
Another solution could be to edit the view "product / listing_div" and add code like:
That way, you can have the desired products thanks to an url parameter, filters are not mandatory.
Please Log in or Create an account to join the conversation.
And the pagination will be wrong wont it?
I am trying to use the helper API but I don't know if this would be the correct way to get product id #66.
Please Log in or Create an account to join the conversation.
For the pagination, you can change the "$this->pageInfo" PHP object values.
To get the products from ids, you can use that code:
Please Log in or Create an account to join the conversation.
With hikashop_get('class.product') the prices come out as $0.00
Please Log in or Create an account to join the conversation.
In each entry of the $productClass->products array, you have a "prices" attribute which itself is an array of all the prices of the product.
That way, you can access the prices of the products and use them.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Could you do a var_dump of the prices attribute ?
What do you get ?
The currencyHelper->format function call that you see in a lot of views is just to display the price_value of the price nicely, but the amount is already in there. So it's not necessary to use it.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
So the price is not 0. You can see there that the price is 8.63636:
take.ms/MSDA2
You can access it like that:
Please Log in or Create an account to join the conversation.
Do I need to replace $this->rows[x]->prices, with the ones from each new row too?
Please Log in or Create an account to join the conversation.
I've reread the whole thread but I couldn't find any mention of "replacing" from us.
Xavier gave you some code on how to get the products data based on the ids of the products.
You then replied that the prices where 0.
We then asked for a var_dump of the products in order to check on that, as that should not happen.
And in the var_dump you provided, the price is not 0.
So I'm a bit lost. I don't understand what replacing you're trying to do, where your trying to do it, or why you're trying to do it ?
Please Log in or Create an account to join the conversation.
// Replace the content of $this->rows
$this->rows = $products;
I am trying to replace the product list with a new product list of specific product IDs that I select from the database while keeping the same template style.
Please Log in or Create an account to join the conversation.
The problem is that the getProducts function gives you the data of the product taken from the database.
It doesn't compute all the prices based on the tax rules, the discount rules, etc.
Thus the system might try to use a price which handle been computed if you just copy the rows "as is".
So what you can do is call the getPrices function of the class.currency for each product so that it will compute the prices for them to be displayed by the view of the frontend.
Please Log in or Create an account to join the conversation.
Otherwise I have to get products, get prices, get images, get badges and some other steps I am not aware of that will cause problems later.
Why can't I use hikashop::get('helper.product'); for this? - I don't know how to use it but it doesn't seem to work.
BTW getPrices() is wrong, you need to use getListingPrices() for consistent layout
Please Log in or Create an account to join the conversation.
Well, the getProducts function is the closest we have of a function to easily load all the data of a bunch of products.
It is used for the export, copy and mass action systems, which don't require any calculation of the prices.
It's either that, or you basically have to do all the queries and processing manually, like in the listing function of the components/com_hikashop/views/product/view.html.php file.
Why there is no easy function to do that same thing in the class.product ? Well that's because the only place where that is needed is in that view file so there was no point in moving the code in the class.
Please Log in or Create an account to join the conversation.