View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006905 | OXID eShop (all versions) | 4.01. Database handling | public | 2018-09-21 13:47 | 2022-09-20 12:04 |
Reporter | michael_keiluweit | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | no change required | ||
Product Version | 6.1.0 | ||||
Summary | 0006905: The view table oxarticle does contain the price of the parent shop, not the price of oxfield2shop. | ||||
Description | If a sub shop has a different price for an inherited article, then the price will be stored in oxfield2shop. So if you call the object you will get the individual price. But if you use the view mechanic by itself, then you will get the price of the parent shop as the view tables contains the price of the parent shop. Since our training course part 3 states that it is safe to use the view functionality for getting sub shop specific information the framework should store the own price in the view table of the sub shop, not the original one. | ||||
Steps To Reproduce | 1. Goto admin 2. Create a new shop 3. Let the new shop inherit everything from a parent shop 4. change to the new shop 5. activate it 6. change one price of an article 7. call the details page of the article, see the new price. 8. have a look into the database. The view table oxv_oxarticle_2 will have the value of the original price. | ||||
Additional Information | From our training course: - Bei Datenbankabfragen innerhalb von eigenen Erweiterungen mu?ssen wir uns nicht explizit um die Shop-Zugeho?rigkeit der Datensa?tze ku?mmern. - Es ist lediglich darauf zu achten, dass die korrekte View angesprochen wird. - Zu diesem Zweck gibt es eine Funktion, die in oxfunctions de niert wird: getViewName([Tabellenname]) —> Liefert den Namen der entsprechenden View zuru?ck Translation: - It's not necessary to make sure to which shop the data belongs. - You only have to check that you call the correct view. - So use the function getViewName($tableName) -> it returns the name of the view table | ||||
Tags | Validation | ||||
Theme | Not defined | ||||
Browser | Not defined | ||||
PHP Version | Not defined | ||||
Database Version | Not defined | ||||
related to | 0006137 | closed | OXACTIVE in oxfield2shop is not used |
|
Test script. Adapt the path to the bootstrap file. Also be sure that there is an article with the used oxid. I used the demodata to reproduce it.<?php require_once '../bootstrap.php'; // view price $sql = 'select oxprice from ' . getViewName('oxarticles') . ' where oxartnum = 1402'; $db = \OxidEsales\EshopCommunity\Core\DatabaseProvider::getDb(); $viewPrice = $db->getOne($sql); // object price $oxid = '05848170643ab0deb9914566391c0c63'; $article = oxNew(\OxidEsales\Eshop\Application\Model\Article::class); $article->load($oxid); $objectPrice = $article->getPrice()->getBruttoPrice(); // debug output echo 'Shop id: ' . \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId(); echo ''; echo 'Price from view table: ' . $viewPrice; echo ''; echo 'Price from article object: ' . $objectPrice; Call the script with the parameter "shp=1" and "shp=2" to see the different. |
|
The View tables where introduced for the language handling and not to represent business logic. - MK |