Developing a Custom Component for 1C-Bitrix
Sometimes site needs custom functionality that doesn't fit standard Bitrix components. Custom component development creates reusable, maintainable components tailored to project needs.
Component Structure
local/components/vendor/mycomponent/
├── class.php # Main component class
├── .description.php # Component metadata
├── template.php # Default template
├── ajax.php # AJAX handler
└── lang/
├── en/
│ └── component.php
└── ru/
└── component.php
Example: Custom Product Card
class MyProductCard extends CBitrixComponent
{
public function executeComponent()
{
$product = \Bitrix\Catalog\ProductTable::getById($this->arParams['PRODUCT_ID'])->fetch();
$this->arResult['PRODUCT'] = $product;
$this->arResult['RATING'] = $this->getRating($product['ID']);
$this->includeComponentTemplate();
}
}
Component Parameters
Define parameters users can configure in admin:
- PRODUCT_ID — which product to display
- SHOW_PRICE — yes/no
- SHOW_RATING — yes/no
- CACHE_TIME — caching duration
Templates
Component can have multiple templates (default, grid, list). Admin selects template when adding component to page.
Development Timeline
| Stage | Duration |
|---|---|
| Simple component (product card) | 3–5 days |
| Intermediate (filters, sorting) | 8–10 days |
| Complex (real-time updates, API) | 14–18 days |

