View Issue Details

IDProjectCategoryView StatusLast Update
0006919OXID ERP InterfaceOXID ERP Interface - subpublic2019-06-05 17:43
Reporteralfredbez Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.1.0 
Fixed in Version3.2.0 
Summary0006919: OXERPSetArticleCategory does not delete mappings in subshops
DescriptionOXERPSetArticleCategory (with the flag blDeleteOld) deletes only mappings in the root-shop, but creates mappings in subshops.

You can of cource Login in the subshop and make an OXERPSetArticleCategory Request to delete old mappings in that shop, but that looks more like a workaround to me.
Steps To ReproducePrepare the Shops

1. Install a fresh Enterprise Edition
2. Activate the ERP module.
3. Create a second shop, activate the checkbox "Shop inherits all inheritable items (products, discounts etc) from it's parent shop." and set shop 1 as parent.
4. Do the following SOAP requests:

+===================================================================================+
| 1. Login (OXERPLogin)                                                             |
+===================================================================================+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oxer="OXERPService">
   <soapenv:Header/>
   <soapenv:Body>
      <oxer:OXERPLogin>
         <oxer:sUserName>yourusername</oxer:sUserName>
         <oxer:sPassword>yourpassword</oxer:sPassword>
         <oxer:iShopID>1</oxer:iShopID>
         <oxer:iLanguage>0</oxer:iLanguage>
      </oxer:OXERPLogin>
   </soapenv:Body>
</soapenv:Envelope>

+===================================================================================+
| 2. add article art1 to shop 1 & 2 (OXERPSetArticle)                               |
+===================================================================================+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oxer="OXERPService">
   <soapenv:Header/>
   <soapenv:Body>
      <oxer:OXERPSetArticle>
         <oxer:sSessionID>yoursessionid</oxer:sSessionID>
         <oxer:aArticle>
            <oxer:OXERPType>
               <oxer:aResult>
                  <oxer:ArrayOfString>
                    <oxer:string>OXID</oxer:string>
                    <oxer:string>art1</oxer:string>
                  </oxer:ArrayOfString>
                  <oxer:ArrayOfString>
                    <oxer:string>OXINHERITEDSHOPIDS</oxer:string>
                    <oxer:string>a:2:{i:0;i:1;i:1;i:2;}</oxer:string>
                  </oxer:ArrayOfString>
               </oxer:aResult>
               <oxer:blResult>true</oxer:blResult>
            </oxer:OXERPType>
         </oxer:aArticle>
      </oxer:OXERPSetArticle>
   </soapenv:Body>
</soapenv:Envelope>

mysql> SELECT OXMAPID,OXID,OXTIMESTAMP FROM oxarticles ORDER BY OXTIMESTAMP DESC LIMIT 1;
+---------+------+---------------------+
| OXMAPID | OXID | OXTIMESTAMP         |
+---------+------+---------------------+
|   50313 | art1 | 2018-11-08 10:53:53 |
+---------+------+---------------------+
1 row in set (0.04 sec)

mysql> SELECT * FROM oxarticles2shop WHERE OXMAPOBJECTID = '50313';
+----------+---------------+---------------------+
| OXSHOPID | OXMAPOBJECTID | OXTIMESTAMP         |
+----------+---------------+---------------------+
|        1 |         50313 | 2018-11-08 10:53:53 |
|        2 |         50313 | 2018-11-08 10:53:53 |
+----------+---------------+---------------------+
2 rows in set (0.00 sec)

+===================================================================================+
| 3. create categories cat1 & cat2 in shop 1 & 2 (OXERPSetCategory)                 |
+===================================================================================+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oxer="OXERPService">
   <soapenv:Header/>
   <soapenv:Body>
      <oxer:OXERPSetCategory>
         <oxer:sSessionID>yoursessionid</oxer:sSessionID>
         <oxer:aCategory>
            <oxer:OXERPType>
               <oxer:aResult>
                  <oxer:ArrayOfString>
                                        <oxer:string>OXID</oxer:string>
                                        <oxer:string>cat1</oxer:string>
                  </oxer:ArrayOfString>
                  <oxer:ArrayOfString>
                      <oxer:string>OXINHERITEDSHOPIDS</oxer:string>
                      <oxer:string>a:2:{i:0;i:1;i:1;i:2;}</oxer:string>
                  </oxer:ArrayOfString>
               </oxer:aResult>
               <oxer:blResult>true</oxer:blResult>
            </oxer:OXERPType>
            <oxer:OXERPType>
               <oxer:aResult>
                  <oxer:ArrayOfString>
                                        <oxer:string>OXID</oxer:string>
                                        <oxer:string>cat2</oxer:string>
                  </oxer:ArrayOfString>
                  <oxer:ArrayOfString>
                      <oxer:string>OXINHERITEDSHOPIDS</oxer:string>
                      <oxer:string>a:2:{i:0;i:1;i:1;i:2;}</oxer:string>
                  </oxer:ArrayOfString>
               </oxer:aResult>
               <oxer:blResult>true</oxer:blResult>
            </oxer:OXERPType>
         </oxer:aCategory>
      </oxer:OXERPSetCategory>
   </soapenv:Body>
</soapenv:Envelope>

mysql> SELECT OXID,OXMAPID,OXTIMESTAMP FROM oxcategories ORDER BY OXTIMESTAMP DESC LIMIT 2;
+------+---------+---------------------+
| OXID | OXMAPID | OXTIMESTAMP         |
+------+---------+---------------------+
| cat2 |    1680 | 2018-11-08 11:10:06 |
| cat1 |    1679 | 2018-11-08 11:10:06 |
+------+---------+---------------------+
2 rows in set (0.01 sec)

mysql> SELECT * FROM oxcategories2shop WHERE OXMAPOBJECTID >= 1679;
+----------+---------------+---------------------+
| OXSHOPID | OXMAPOBJECTID | OXTIMESTAMP         |
+----------+---------------+---------------------+
|        1 |          1679 | 2018-11-08 11:10:06 |
|        2 |          1679 | 2018-11-08 11:10:06 |
|        1 |          1680 | 2018-11-08 11:10:05 |
|        2 |          1680 | 2018-11-08 11:10:06 |
+----------+---------------+---------------------+
4 rows in set (0.00 sec)

+===================================================================================+
| 4. assign article to category cat1 (OXERPSetArticleCategory)                      |
+===================================================================================+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oxer="OXERPService">
   <soapenv:Header/>
   <soapenv:Body>
      <oxer:OXERPSetArticleCategory>
         <oxer:sSessionID>yoursessionid</oxer:sSessionID>
         <oxer:sArticleID>art1</oxer:sArticleID>
         <oxer:aCategoryID>
            <oxer:OXERPType>
               <oxer:aResult>
                  <oxer:ArrayOfString>
                     <oxer:string>OXID</oxer:string>
                     <oxer:string>cat1</oxer:string>
                  </oxer:ArrayOfString>
               </oxer:aResult>
               <oxer:blResult>true</oxer:blResult>
            </oxer:OXERPType>
         </oxer:aCategoryID>
         <oxer:blDeleteOld>true</oxer:blDeleteOld>
      </oxer:OXERPSetArticleCategory>
   </soapenv:Body>
</soapenv:Envelope>

mysql> SELECT * FROM oxobject2category WHERE OXOBJECTID LIKE 'art%';
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
| OXID                             | OXSHOPID | OXOBJECTID | OXCATNID | OXPOS | OXTIME     | OXTIMESTAMP         |
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
| 5300c69df42f1f66011005894f22ccb5 |        2 | art1       | cat1     |     0 | 1541672388 | 2018-11-08 11:19:48 |
| d11822f715a0eba46aea406cbfacdf8c |        1 | art1       | cat1     |     0 | 1541672387 | 2018-11-08 11:19:48 |
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
2 rows in set (0.00 sec)

+===================================================================================+
| 5. assign article to category cat2 with delete-old-flag (OXERPSetArticleCategory) |
+===================================================================================+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oxer="OXERPService">
   <soapenv:Header/>
   <soapenv:Body>
      <oxer:OXERPSetArticleCategory>
         <oxer:sSessionID>yoursessionid</oxer:sSessionID>
         <oxer:sArticleID>art1</oxer:sArticleID>
         <oxer:aCategoryID>
            <oxer:OXERPType>
               <oxer:aResult>
                  <oxer:ArrayOfString>
                     <oxer:string>OXID</oxer:string>
                     <oxer:string>cat2</oxer:string>
                  </oxer:ArrayOfString>
               </oxer:aResult>
               <oxer:blResult>true</oxer:blResult>
            </oxer:OXERPType>
         </oxer:aCategoryID>
         <oxer:blDeleteOld>true</oxer:blDeleteOld>
      </oxer:OXERPSetArticleCategory>
   </soapenv:Body>
</soapenv:Envelope>

mysql> SELECT * FROM oxobject2category WHERE OXOBJECTID LIKE 'art%';
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
| OXID                             | OXSHOPID | OXOBJECTID | OXCATNID | OXPOS | OXTIME     | OXTIMESTAMP         |
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
| 5300c69df42f1f66011005894f22ccb5 |        2 | art1       | cat1     |     0 | 1541672388 | 2018-11-08 11:19:48 |
| 7a58b06653298660710253786600e43f |        2 | art1       | cat2     |     0 | 1541672424 | 2018-11-08 11:20:24 |
| e579fb29312172d8bdd71b7dcdee5499 |        1 | art1       | cat2     |     0 | 1541672423 | 2018-11-08 11:20:24 |
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
3 rows in set (0.00 sec)

===============================================================================================================
=> mapping (article art1 to category cat1) does not exist in shop 1 (correct), but does exist in shop 2 (wrong)
===============================================================================================================
TagsNo tags attached.

Activities

QA

2018-11-08 14:47

administrator   ~0012672

Last edited: 2018-11-08 14:48

Hello alfredbez

first of all: Thank you for the very detailed steps to reproduce the behavior.

I copy pasted the requests to do the very same steps. But when executing the query

SELECT * FROM oxobject2category WHERE OXOBJECTID LIKE 'art%'


I get a different result. Just one record:

MySQL [oxid]> SELECT * FROM oxobject2category WHERE OXOBJECTID LIKE 'art%';
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
| OXID                             | OXSHOPID | OXOBJECTID | OXCATNID | OXPOS | OXTIME     | OXTIMESTAMP         |
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
| d11822f715a0eba46aea406cbfacdf8c |        1 | art1       | cat1     |     0 | 1541684335 | 2018-11-08 14:38:55 |
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
1 row in set (0.00 sec)

MySQL [oxid]> 


Also the next step returns only one record:

MySQL [oxid]> SELECT * FROM oxobject2category WHERE OXOBJECTID LIKE 'art%'; 
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
| OXID                             | OXSHOPID | OXOBJECTID | OXCATNID | OXPOS | OXTIME     | OXTIMESTAMP         |
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
| e579fb29312172d8bdd71b7dcdee5499 |        1 | art1       | cat2     |     0 | 1541684565 | 2018-11-08 14:42:45 |
+----------------------------------+----------+------------+----------+-------+------------+---------------------+
1 row in set (0.00 sec)

MySQL [oxid]> 



Therefore I can't reproduce the case. Do I miss something, besides the provided steps to reproduce?

Best,
michael_keiluweit

QA

2018-11-09 14:01

administrator   ~0012676

Added Steps 1 - 4 of preparing the shop in the "steps to reproduce" section.

-MK

alfredbez

2018-11-09 14:04

reporter   ~0012677

Here's the PR: https://github.com/OXID-eSales/erp/pull/26