Get the shop id

$this->context->shop->id;
Shop::getContextShopID();

Get context (a shop, a group or all shops)

if(Shop::getContext() == Shop::CONTEXT_SHOP){}
if(Shop::getContext() == Shop::CONTEXT_GROUP){}
if(Shop::getContext() == Shop::CONTEXT_ALL)

Get actual shop ids (if you’re in a group or a shop)

Shop::getContextListShopID(); // [1,2,3]
$sql = 'object.id_shop IN ('.join(Shop::getContextListShopID(),',').')';