I'm looking for an explaination about column "Position"
in table "Catalog_Category_Product"
.
I dont understand what is 0 and 1 in that column, and what does it for?
Thanks for reading. Have a good day 🙂
EDIT 1:
Maybe i'm not clear enough when asking the question, so…
I'm trying to do "banner_slider" follow the structure of "catalog_category_product"
C:\xampp\htdocs\magento\vendor\magento\module-catalog\Block\Adminhtml\Category\AssignProducts.php
So in that code, i debug with xdebug phpstorm and realize that position="1" show in "yes", but in the database it have position="0" as well. I dont know what it does .. That's what i'm wondering
Here is what i debug:
public function getProductsJson()
{
$products = $this->getCategory()->getProductsPosition();
if (!empty($products)) {
return $this->jsonEncoder->encode($products);
}
return '{}';
}
After running that code, they render throught this in "getProductsJson()" function:
C:\xampp\htdocs\magento\vendor\magento\module-catalog\view\adminhtml\templates\catalog\category\edit\assign_products.phtml
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var \Magento\Catalog\Block\Adminhtml\Category\AssignProducts $block */
/** @var \Magento\Catalog\Block\Adminhtml\Category\Tab\Product $blockGrid */
$blockGrid = $block->getBlockGrid();
$gridJsObjectName = $blockGrid->getJsObjectName();
?>
<?= $block->getGridHtml() ?>
<input type="hidden" name="category_products" id="in_category_products" data-form-part="category_form" value="" />
<script type="text/x-magento-init">
{
"*": {
"Magento_Catalog/catalog/category/assign-products": {
"selectedProducts": <?= /* @escapeNotVerified */ $block->getProductsJson() ?>,
"gridJsObjectName": <?= /* @escapeNotVerified */ '"' . $gridJsObjectName . '"' ?: '{}' ?>
}
}
}
</script>
<!-- @todo remove when "UI components" will support such initialization -->
<script>
require('mage/apply/main').apply();
</script>
Best Answer
Category products display based on set position. You can check product position in admin >> Catalog >> Categories >> Select any category >> Product In Category.
You can check below reference screenshots, admin and front.
Admin :
Front :