View Issue Details

IDProjectCategoryView StatusLast Update
0006905OXID eShop (all versions)4.01. Database handlingpublic2022-09-20 12:04
Reportermichael_keiluweit Assigned To 
Status closedResolutionno change required 
Product Version6.1.0 
Summary0006905: The view table oxarticle does contain the price of the parent shop, not the price of oxfield2shop.
DescriptionIf 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 Reproduce1. 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 InformationFrom 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

- 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

ThemeNot defined
BrowserNot defined
PHP VersionNot defined
Database VersionNot defined


related to 0006137 closed OXACTIVE in oxfield2shop is not used 



2018-09-21 14:15

administrator   ~0012628

Last edited: 2018-09-21 14:19

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.

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);
$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.


2022-09-20 12:04

administrator   ~0014318

The View tables where introduced for the language handling and not to represent business logic.
- MK