Page 1 of 3

Can I view only products from a single store?

Posted: Wed Oct 18, 2017 9:11 am
by kelemvor
Hi,

I'm setting up a MultiStore store and I'm wondering if there's a way that when I'm in the admin section, if I can choose to only view products, categories, etc for a specific store at a time. It seems like when I go to Products, I'm viewing every products across all my stores which is overwhelming. I don't see a Store option in the filter area on the sides so not sure if there's a way to do that.

Thanks.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 12:37 am
by bumcarks
Hello kelemvor,
There is no option filter products, category based on store. What is your opencart version.
I will create a module that will give an option to filter based on store. Please massage on my PM

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 12:39 am
by straightlight
This extension may provide what you need: https://www.opencart.com/index.php?rout ... n_id=23049 . Even though it has been coded for v2.x releases of Opencart, a few tweaks can be done to make it work in v3.x releases.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 12:55 am
by kelemvor
I saw that one but since I'm just testing things for a side project, I don't want to spend $20 for what should be included functionality.
I did find this other one and sent an email asking about v3 compatibility but didn't hear back yet.
https://www.opencart.com/index.php?rout ... n_id=18735

Otherwise maybe I'll just uninstall and put an old version back on since there's more support for them.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 1:01 am
by labeshops
I used the mod admin quick product edit which lets me do that a lot more.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 2:12 am
by straightlight
kelemvor wrote:
Thu Oct 19, 2017 12:55 am
I saw that one but since I'm just testing things for a side project, I don't want to spend $20 for what should be included functionality.
I did find this other one and sent an email asking about v3 compatibility but didn't hear back yet.
https://www.opencart.com/index.php?rout ... n_id=18735

Otherwise maybe I'll just uninstall and put an old version back on since there's more support for them.
See if this VQMod file works for version 3.0.2.0 of Opencart:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
  <id>Multi Shop Product Filter</id>
  <version>2.0</version>
  <vqmver>2.2.1</vqmver>
  <author>Jason Clark (mithereal@gmail.com)</author>
  
  <file name="admin/controller/catalog/product.php">        
    <operation>
      <search position="after"><![CDATA[
		  protected function getList() {
		  ]]></search>
      <add><![CDATA[
		  if (isset($this->request->get['filter_store'])) {
			$filter_store = $this->request->get['filter_store'];
		} else {
			$filter_store = null;
		}
		  ]]></add>
    </operation>
  
   <operation>
      <search position="after"><![CDATA[
		  public function index() {
		  ]]></search>
      <add><![CDATA[
		  $this->load->language('module/store_filter');
		  ]]></add>
    </operation>
       
    <operation>
      <search position="after"><![CDATA[
		  protected function getList() {
		  ]]></search>
      <add><![CDATA[
		  if (isset($this->request->get['filter_store'])) {
			$filter_store = $this->request->get['filter_store'];
		} else {
			$filter_store = null;
		}
		  ]]></add>
    </operation>
     
    <operation>
      <search position="before"><![CDATA[
		 $product_total = $this->model_catalog_product->getTotalProducts($filter_data);
		  ]]></search>
      <add><![CDATA[
		  $filter_data['filter_store']   = $filter_store;
		  ]]></add>
    </operation>
  
    <operation>
      <search position="after"><![CDATA[
		  $data['products'][] = array(
		  ]]></search>
      <add><![CDATA[
		  'store'      => $result['store_id'],
		  ]]></add>
    </operation>
   
    <operation>
      <search position="before"><![CDATA[
if (is_file(DIR_IMAGE . $result['image'])) {
		  ]]></search>
      <add><![CDATA[
		  if(!isset($result['store_id'])){
          $result['store_id'] = 0;
                    }
		  ]]></add>
    </operation>
     
    <operation>
      <search position="after"><![CDATA[
		  $this->load->model('setting/store');
		  ]]></search>
      <add><![CDATA[
		  $data['column_store'] = $this->language->get('column_store');
		  ]]></add>
    </operation>
     
    <operation>
      <search position="before"><![CDATA[
		  if ($order == 'ASC') {
		  ]]></search>
      <add><![CDATA[
		  if (isset($this->request->get['filter_store'])) {
			$url .= '&filter_store=' . $this->request->get['filter_store'];
		}
		  ]]></add>
    </operation>
  
    <operation>
      <search position="after"><![CDATA[
$data['sort_order'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.sort_order' . $url, true);
		  ]]></search>
      <add><![CDATA[
      $data['sort_store'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.sort_store' . $url, true);

		  ]]></add>
    </operation>
        
    <operation>
      <search position="after"><![CDATA[
		  $data['filter_status'] = $filter_status;
		  ]]></search>
      <add><![CDATA[
		  $data['filter_store'] = $filter_store;
		  ]]></add>
    </operation>
      
    <operation>
      <search position="after"><![CDATA[
		  $data['stores'] = array();
		  ]]></search>
      <add><![CDATA[
		 $data['entry_store'] = $this->language->get('entry_store');
		  ]]></add>
    </operation>
     
    <operation>
      <search position="before"><![CDATA[ 
           $this->response->setOutput($this->load->view('catalog/product_list', $data));
		  ]]></search>
      <add><![CDATA[
		 $this->load->model('setting/store');
		 
		 $data['stores'] = array();

		 $data['stores'][] = array(
			'store_id' => 0,
			'name'     => $this->config->get('config_name') . $this->language->get('text_default'),
			'url'      => $this->config->get('config_secure') ? HTTPS_CATALOG : HTTP_CATALOG,
			'edit'     => $this->url->link('setting/setting', 'user_token=' . $this->session->data['user_token'], true)
		 );

		 $results = $this->model_setting_store->getStores();

		 foreach ($results as $result) {
			$data['stores'][] = array(
				'store_id' => $result['store_id'],
				'name'     => $result['name'],
				'url'      => $result['url'],
				'edit'     => $this->url->link('setting/store/edit', 'user_token=' . $this->session->data['user_token'] . '&store_id=' . $result['store_id'], true)
			);
		 }
		  ]]></add>
		 
    </operation>
   
    <operation>
      <search position="replace"><![CDATA[ 
          $pagination->url = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}', true);
		  ]]></search>
      <add><![CDATA[

		if (isset($this->request->get['filter_store'])) {
                           $pagination->url = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}'.'&filter_store='.$this->request->get['filter_store'], 'SSL');
			} else {
                            $pagination->url = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}', true);
                       }
	
		  ]]></add>
		 
    </operation>
  </file>

  <file name="admin/model/catalog/product.php">
<operation>
<search position="after"><![CDATA[
$sql = "SELECT COUNT(DISTINCT p.product_id) AS total FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)";
]]></search>
<add><![CDATA[
$sql .= " LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id)";
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
$sql = "SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
]]></search>
<add><![CDATA[
$sql = "SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)  LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
]]></add>
</operation>

<operation>
<search position="before"><![CDATA[
if (isset($data['filter_status']) && $data['filter_status'] !== '') {
]]></search>
<add><![CDATA[
if (isset($data['filter_store'])) {
$sql .= " AND p2s.store_id = '" . (int)$data['filter_store'] . "'";
}
]]></add>
</operation>
</file>

  <file name="admin/view/template/catalog/product_list.twig">        
    <operation>
      <search position="before"><![CDATA[
		   <td class="text-right">{{ column_action }}</td>
		  ]]></search>
      <add><![CDATA[
		 <td class="text-left">{% if sort == 'p.store' %} <a href="{{ sort_store }}" class="{{ order|lower }}">{{ column_store }}</a> {% else %} <a href="{{ sort_store }}">{{ column_store }}</a> {% endif %}</td>
		  ]]></add>
    </operation>
   
    <operation>
      <search position="before"><![CDATA[
		               <button type="button" id="button-filter" class="btn btn-default"><i class="fa fa-filter"></i> {{ button_filter }}</button>

		  ]]></search>
      <add><![CDATA[
		    <div class="col-sm-4">
              <div class="form-group">
                <label class="control-label" for="input-store">{{ entry_store }}</label>
                <select name="filter_store" id="input-store" class="form-control">
              <option value="*">All</option>
                  {% for store in stores %}
					{% if filter_store and filter_store == store.store_id %}
						<option value="{{ store.store_id }}" selected="selected">{{ store.name }}</option>
					{% else %}
					    <option value="{{ store.store_id }}">{{ store.name }}</option>
					{% endif %}
				  {% endfor %}
                </select>
              </div>
              </div>
		  ]]></add>
    </operation>
     
    <operation>
      <search position="after"><![CDATA[
                  <td class="text-left">{{ product.status }}</td>

		  ]]></search>
      <add><![CDATA[
		<td class="text-left">
  {% for store in stores %}
	 {% if product.store == store.store_id %} 
          {{ store.name }}
     {% endif %}
  {% endfor %}
 </td>
		  ]]></add>
    </operation>
      
    <operation>
      <search position="before"><![CDATA[
                  var filter_status = $('select[name=\'filter_status\']').val();

		  ]]></search>
      <add><![CDATA[
		var filter_store = $('select[name=\'filter_store\']').val();

	if(filter_store != '*') {
		url += '&filter_store=' + encodeURIComponent(filter_store);
	}
		  ]]></add>
    </operation>
  </file>


</modification>
However, you must use the latest version of VQMod to ensure its functionality.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 2:39 am
by kelemvor
I just got this store setup yesterday. Didn't even get VQMod installed yet. I'll go find it. :)

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 4:38 am
by kelemvor
OK, I pasted in that VQMod as an XML file but it doesn't appear to have done anything. I don't get any errors in the GUI but I also don't see any changes to the Products page.

When I use VQMod Manager and check the Error Log, it does show this error:

Code: Select all

---------- Date: 2017-10-18 20:33:18 ~ IP : 74.202.241.130 ----------
REQUEST URI : /admin/index.php?route=catalog/product
MOD DETAILS:
   modFile   : /home/awhatmom/opencart/vqmod/xml/storefilter.xml
   id        : Multi Shop Product Filter
   version   : 2.0
   vqmver    : 2.2.1
   author    : Jason Clark (mithereal@gmail.com)

File Name    : admin/controller/catalog/product.php(0)
VQModObject::applyMod - SEARCH NOT FOUND (ABORTING MOD): $data['column_status'] = $this->language->get('column_status');

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 4:57 am
by straightlight
Thanks, XML updated.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 7:46 am
by kelemvor
Now getting:

Code: Select all

---------- Date: 2017-10-18 23:45:32 ~ IP : 72.135.237.17 ----------
REQUEST URI : /admin/index.php?route=catalog/product
MOD DETAILS:
   modFile   : /home/awhatmom/opencart/vqmod/xml/storefilter.xml
   id        : Multi Shop Product Filter
   version   : 2.0
   vqmver    : 2.2.1
   author    : Jason Clark (mithereal@gmail.com)

File Name    : admin/controller/catalog/product.php(0)
VQModObject::applyMod - SEARCH NOT FOUND (ABORTING MOD): $data['sort_order'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.sort_order' . $url, true);
----------------------------------------------------------------------

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 7:51 am
by straightlight
Thanks, XML updated.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 8:20 am
by kelemvor
Thanks yet again. Here's the latest.
If there's an easier way of doing this, let me know. ;)

Code: Select all

File Name    : admin/controller/catalog/product.php(0)
VQModObject::applyMod - SEARCH NOT FOUND (ABORTING MOD): $data['column_status'] = $this->language->get('column_status');
Hmm, that's the same as the first one. maybe it didn't upload right. trying agian...

Yep, same error as up above.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 8:40 am
by straightlight
Even I don't understand this time how that one came back ... :-\

XML updated.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 8:44 am
by kelemvor

Code: Select all

File Name    : admin/controller/catalog/product.php(0)
VQModObject::applyMod - SEARCH NOT FOUND (ABORTING MOD): $data['entry_status'] = $this->language->get('entry_status');

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 8:54 am
by straightlight
Updated.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 9:11 am
by kelemvor
When I go to the Catalog | Products page, I get this:

Code: Select all

Notice: Undefined property: Proxy::getSettingbyKey in /home/awhatmom/opencart/vqmod/vqcache/vq2-admin_controller_catalog_product.php on line 539
VQMod Manager shows:

Code: Select all

File Name    : admin/model/catalog/product.php(0)
VQModObject::applyMod - SEARCH NOT FOUND (ABORTING MOD): if (isset($data['filter_status']) && !is_null($data['filter_status'])) {

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 9:25 am
by straightlight
Updated.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 9:34 am
by kelemvor
Line number changed but same errors
Oh, and it's an offset instead of a property.

Code: Select all

Notice: Undefined offset: 0 in /home/awhatmom/opencart/vqmod/vqcache/vq2-admin_controller_catalog_product.php on line 541

Code: Select all

File Name    : admin/model/catalog/product.php(0)
VQModObject::applyMod - SEARCH NOT FOUND (ABORTING MOD): if (isset($data['filter_status']) && !is_null($data['filter_status'])) {
:)

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 9:36 am
by straightlight
You'd need to post the line 541 of that file where the undefined offset is located. As for the 2nd error, this time, it does not come from my XML but possibly from another contribution. To make sure, clear all caches.

Re: Can I view only products from a single store?

Posted: Thu Oct 19, 2017 10:09 am
by kelemvor
Cleared both OC caches and the VQ cache. Still get this error on the Products page:

Code: Select all

Notice: Undefined offset: 0 in /home/awhatmom/opencart/vqmod/vqcache/vq2-admin_controller_catalog_product.php on line 541
However, VQModManager isn't showing any VQ errors.

Here's a link to the file listed above.
https://www.dropbox.com/s/elw7p5w1oblum ... t.php?dl=0