Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

How to select all product of speified vendor?

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 04-24-2015, 06:06 AM
 
Roman Prisiazhniuk Roman Prisiazhniuk is offline
 

Member
  
Join Date: Apr 2015
Posts: 17
 

Default How to select all product of speified vendor?

Product is linked to a vendor through vendor_id attribute in product table, there is no vendor_id property in \XLite\Model\Product, so how can I select all products of specified vendor?
__________________
xcart 4.4.1, 5
Reply With Quote

The following user thanks Roman Prisiazhniuk for this useful post:
totaltec (04-24-2015)
  #2  
Old 05-04-2015, 03:29 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: How to select all product of speified vendor?

Actually, Multivendor module adds vendor property to a product model (see the \XLite\Module\XC\MultiVendor\Model\Product class), which means that you can pull products by vendor as follows:

PHP Code:
<?php

include_once('top.inc.php');

$vendor = \XLite\Core\Database::getRepo('XLite\Model\Profile')->find(VENDOR_ID);
$products = \XLite\Core\Database::getRepo('XLite\Model\Product')->findBy(array('vendor' => $vendor));

foreach (
$products as $product) {
    echo 
$product->getName();
}

where VENDOR_ID must be replaced with actual vendor name.

If you can pull $vendor object anyhow else, you can go for it as well.

Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:15 PM.

   

 
X-Cart forums © 2001-2020