fbpx
  Wednesday, 10 June 2020
  8 Replies
  1.8K Visits
  Subscribe
The problem is this I started working on the override of the product detail view before your last changes and now I need to merge my changes and yours and I realized that you added some functions that I don't understand use.
For example, is there an array $listingsByType that seems empty what should it contain and why is it empty? I see that there is a function that under quantity management should make something linked to an overrides default_listings.php come out but how should it work?

Another question I have arranged the default_sellers.php view graphically but you have told us that it is possible to sort the offers by price or other criteria but I can't find anything in the code to manage the ordering how can I do?

Giovanni
Accepted Answer
Ok for the issue of sorting sellers by price in default_sellers.php as I don't want to change the model and have problems with each update because the change is overwritten, from your indications I made the changes in the override view, perhaps not the maximum of the optimization so if you have any suggestions let me know, here is the code:

use Joomla\Utilities\ArrayHelper;
/** @var SellaciousViewProduct $this */
$sellers = $this->item->get('sellers');
foreach ($sellers as $seller) {
$seller->sales_price = $seller->price->sales_price;
}
$sellers = ArrayHelper::sortObjects($sellers, 'sales_price');


This should be fine for now.


After sorting by price, if I wanted to order the sellers as a second criterion for feedback, how should I change the code?


For sorting in multiple criteria, you can do it like below:


$sellers = ArrayHelper::sortObjects($sellers, array( 'sales_price', 'criteria_2', 'criteria_3'));


But you need to know which property to want to use.
Hello Giovanni,

Hope you're doing well.

$listingsByType contains the number of new/used listings for a product and default_listings.php layout shows the products for new/used listings.

Regarding sellers in default_sellers.php, you would have to code the sorting on components/com_sellacious/models/product.php inside getItemSellers method -

Inside the $sellerUids loop, put following after line 692:


$obj->sales_price = $obj->price->sales_price;


And put this after foreach loop ends after line 699:


$sellers = ArrayHelper::sortObjects($sellers, 'sales_price');


This will sort sellers by price in ascending order.
Hope this helps.

Regards,
Aditya
3 years ago
·
#4586
Ok clear thanks, but because $listingsByType is now empty if there are various offers for the product I'm looking at?

https://passalibro.martcommerce.net/index.php?option=com_sellacious&view=product&p=P12038V0S872

in fact being the array empty even if I recover your code I don't see anything under the quantities.
3 years ago
·
#4587
And for question of sort offers of sellers on default_sellers.php your suggestion is to make a modification to the model but this then creates a problem with each update, isn't there a way in the override view?
3 years ago
·
#4589
Ok for the issue of sorting sellers by price in default_sellers.php as I don't want to change the model and have problems with each update because the change is overwritten, from your indications I made the changes in the override view, perhaps not the maximum of the optimization so if you have any suggestions let me know, here is the code:

use Joomla\Utilities\ArrayHelper;
/** @var SellaciousViewProduct $this */
$sellers = $this->item->get('sellers');
foreach ($sellers as $seller) {
$seller->sales_price = $seller->price->sales_price;
}
$sellers = ArrayHelper::sortObjects($sellers, 'sales_price');
Ok for the issue of sorting sellers by price in default_sellers.php as I don't want to change the model and have problems with each update because the change is overwritten, from your indications I made the changes in the override view, perhaps not the maximum of the optimization so if you have any suggestions let me know, here is the code:

use Joomla\Utilities\ArrayHelper;
/** @var SellaciousViewProduct $this */
$sellers = $this->item->get('sellers');
foreach ($sellers as $seller) {
$seller->sales_price = $seller->price->sales_price;
}
$sellers = ArrayHelper::sortObjects($sellers, 'sales_price');


This should be fine for now.
3 years ago
·
#4676
Ok for the issue of sorting sellers by price in default_sellers.php as I don't want to change the model and have problems with each update because the change is overwritten, from your indications I made the changes in the override view, perhaps not the maximum of the optimization so if you have any suggestions let me know, here is the code:

use Joomla\Utilities\ArrayHelper;
/** @var SellaciousViewProduct $this */
$sellers = $this->item->get('sellers');
foreach ($sellers as $seller) {
$seller->sales_price = $seller->price->sales_price;
}
$sellers = ArrayHelper::sortObjects($sellers, 'sales_price');


This should be fine for now.


After sorting by price, if I wanted to order the sellers as a second criterion for feedback, how should I change the code?
Accepted Answer
Ok for the issue of sorting sellers by price in default_sellers.php as I don't want to change the model and have problems with each update because the change is overwritten, from your indications I made the changes in the override view, perhaps not the maximum of the optimization so if you have any suggestions let me know, here is the code:

use Joomla\Utilities\ArrayHelper;
/** @var SellaciousViewProduct $this */
$sellers = $this->item->get('sellers');
foreach ($sellers as $seller) {
$seller->sales_price = $seller->price->sales_price;
}
$sellers = ArrayHelper::sortObjects($sellers, 'sales_price');


This should be fine for now.


After sorting by price, if I wanted to order the sellers as a second criterion for feedback, how should I change the code?


For sorting in multiple criteria, you can do it like below:


$sellers = ArrayHelper::sortObjects($sellers, array( 'sales_price', 'criteria_2', 'criteria_3'));


But you need to know which property to want to use.
3 years ago
·
#4700
Ok thanks, all clear, I modified it like this:
use Joomla\Utilities\ArrayHelper;
use Sellacious\Price\PriceHelper;

/** @var SellaciousViewProduct $this */
$sellers = $this->item->get('sellers');
foreach ($sellers as $seller) {
$seller->sales_price = $seller->price->sales_price;
$seller->rating = $seller->seller_rating->rating;
}
$sellers = ArrayHelper::sortObjects($sellers, array( 'sales_price', 'rating'));
  • Page :
  • 1
There are no replies made for this post yet.
Be one of the first to reply to this post!
  • +1 (408) 821-8283
  • Email hello@sellacious.com